Skip to content

Commit da85356

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
# Conflicts: # tests/src/TestCase.php
2 parents 928bda1 + b023052 commit da85356

File tree

6 files changed

+58
-64
lines changed

6 files changed

+58
-64
lines changed

tests/src/Feature/Commands/ExecuteImportJobTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,16 @@
1919
->expectsOutput('No pending jobs found.')
2020
->assertExitCode(Command::SUCCESS);
2121
});
22-
22+
2323
it('handles job execution failure', function () {
2424
$job = createImportJobWithFakeFile('test.csv');
25-
25+
2626
$this->artisan($this->command)
2727
->expectsOutput("Executing job {$job->getKey()} ...")
2828
->assertExitCode(Command::SUCCESS);
29-
29+
3030
$job->refresh();
31-
31+
3232
expect($job->failed_at)->not->toBeNull();
3333
});
3434

tests/src/Feature/Commands/PruneModelTest.php

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@
2424
$jobs = Import::factory()->count(5)->isCompleted()->create([
2525
'created_at' => now()->subDays(ImportDataHelper::retrieveClearanceDaysInterval() + 1),
2626
]);
27-
27+
2828
$this->assertDatabaseCount(app(Import::class), count($jobs));
29-
29+
3030
$this->artisan($this->command)->assertExitCode(Command::SUCCESS);
31-
31+
3232
// Assert that the jobs were deleted
3333
$this->assertDatabaseCount(app(Import::class), 0);
3434
});
@@ -39,86 +39,85 @@
3939

4040
it('has no versions to cleanup', function () {
4141
$model = ContentVersion::factory()->avoidToClean(false)->create();
42-
42+
4343
// Run the command
4444
$this->artisan($this->command)->assertExitCode(Command::SUCCESS);
4545
});
4646

4747
it('cleans up versions', function () {
4848
// Create some versions to cleanup
4949
$modelClass = ContentVersion::class;
50-
50+
5151
$model = new $modelClass;
52-
52+
5353
$this->travel(-31)->days();
5454
$oldVersion = $modelClass::factory()->avoidToClean(false)->create();
5555
$this->travelBack();
56-
56+
5757
$this->travel(-29)->days();
5858
$newVersion = $modelClass::factory()->avoidToClean(false)->create();
5959
$this->travelBack();
60-
60+
6161
// Run the command
6262
$this->artisan($this->command)->assertExitCode(Command::SUCCESS);
63-
63+
6464
// Assert the old version is deleted and the new one is not
6565
$this->assertDatabaseMissing($model, ['id' => $oldVersion->id]);
6666
$this->assertDatabaseHas($model, ['id' => $newVersion->id]);
6767
});
68-
68+
6969
it('cleans up versions with avoid to clean', function () {
7070
// Create some versions to cleanup
7171
$modelClass = ContentVersion::class;
72-
72+
7373
$model = new $modelClass;
74-
74+
7575
$this->travel(-31)->days();
7676
$oldVersion = $modelClass::factory()->avoidToClean(true)->create();
7777
$this->travelBack();
78-
78+
7979
$this->travel(-29)->days();
8080
$newVersion = $modelClass::factory()->avoidToClean(false)->create();
8181
$this->travelBack();
82-
82+
8383
// Run the command
8484
$this->artisan($this->command)->assertExitCode(Command::SUCCESS);
85-
85+
8686
// Assert the old version is deleted and the new one is not
8787
$this->assertDatabaseHas($model, ['id' => $oldVersion->id]);
8888
$this->assertDatabaseHas($model, ['id' => $newVersion->id]);
8989
});
90-
90+
9191
it('cleans up versions with publish log', function () {
9292
// Create some versions to cleanup
9393
$modelClass = ContentVersion::class;
9494
$publishVerionModelClass = ContentPublishVersion::class;
95-
95+
9696
$model = new $modelClass;
9797
$publishVersionModel = new $publishVerionModelClass;
98-
98+
9999
$this->travel(-31)->days();
100100
$oldVersion = $modelClass::factory()->avoidToClean(false)->withPublishLog()->create();
101101
$oldVersionId = $oldVersion->id;
102102
$this->travelBack();
103-
103+
104104
$this->travel(-29)->days();
105105
$newVersion = $modelClass::factory()->avoidToClean(false)->withPublishLog()->create();
106106
$newVersionId = $newVersion->id;
107107
$this->travelBack();
108-
108+
109109
// Run the command
110110
$this->artisan($this->command)->assertExitCode(Command::SUCCESS);
111-
111+
112112
// Assert the old version is deleted and the new one is not
113113
$this->assertDatabaseMissing($model, ['id' => $oldVersionId]);
114114
$this->assertDatabaseHas($model, ['id' => $newVersionId]);
115-
115+
116116
$oldVersionExists = $publishVersionModel::withoutGlobalScopes([])->where('version_id', $oldVersionId)->exists();
117117
$newVersionExists = $publishVersionModel::withoutGlobalScopes([])->where('version_id', $newVersionId)->exists();
118-
118+
119119
expect($oldVersionExists)->toBeFalse();
120120
expect($newVersionExists)->toBeTrue();
121121
});
122122

123-
124-
})->group('feature', 'command', 'content-version');
123+
})->group('feature', 'command', 'content-version');

tests/src/TestCase.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ protected function loadMigrationsFrom($paths): void
153153
$migration = include $path;
154154
$migration->up();
155155
}
156-
}
157-
else {
156+
} else {
158157
parent::loadMigrationsFrom($paths);
159158
}
160159
}

tests/src/Unit/Models/ContentTest.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
'slug' => 'test-content',
2121
]);
2222
$content->refresh();
23-
23+
2424
$contentKey = $content->getKey();
25-
25+
2626
// Assert
2727
$this->assertDatabaseHas('content', ['id' => $contentKey]);
2828
$this->assertDatabaseHas('content_versions', ['content_id' => $contentKey]);
2929
$this->assertDatabaseHas('nestable_trees', ['nestable_id' => $contentKey, 'nestable_type' => $content->getMorphClass()]);
30-
30+
3131
// Create publish version
3232
$status = ContentStatusManifest::getOption('publish');
3333
$content->status = $status->getValue();
@@ -38,14 +38,13 @@
3838
]);
3939
$content->setPublishableState($status->getName());
4040
$content->save();
41-
41+
4242
$content->refresh();
43-
43+
4444
$this->assertDatabaseHas('content_publish_version', ['content_id' => $contentKey]);
4545
});
46-
46+
4747
it('create or delete related routes and paths', function () {
48-
4948

5049
$webTypeDocumentType = DocumentType::factory()->create()->refresh();
5150
$content = Content::factory()->create([
@@ -59,7 +58,7 @@
5958
$this->assertDatabaseHas('content', ['id' => $contentId]);
6059
$this->assertDatabaseHas('content_paths', ['key' => $contentId]);
6160
$this->assertDatabaseHas('content_routes', ['content_id' => $contentId]);
62-
61+
6362
// Act 1: soft delete
6463
$content->delete();
6564

@@ -76,7 +75,7 @@
7675
$this->assertDatabaseMissing('content_paths', ['key' => $contentId]);
7776
$this->assertDatabaseMissing('content_routes', ['content_id' => $contentId]);
7877
});
79-
78+
8079
it('deletes children if parent is deleted', function () {
8180
// Arrange
8281
$parent = Content::factory()->create([
@@ -88,34 +87,33 @@
8887
'parent_id' => $parent->id,
8988
]);
9089
$child->refresh();
91-
90+
9291
// Act
9392
$parent->delete();
94-
93+
9594
// Assert
9695
$this->assertSoftDeleted('content', ['id' => $child->id]);
9796
});
98-
97+
9998
it('deletes content versions and nestable tree if content is deleted', function () {
10099
// Arrange
101100
$content = Content::factory()->havePropertyData([
102101
'test' => 'test',
103102
])->create(['slug' => 'test-force-delete']);
104103
$content->refresh();
105-
104+
106105
// Assert 1
107106
$this->assertDatabaseHas('content', ['id' => $content->id]);
108107
$this->assertDatabaseHas('content_versions', ['content_id' => $content->id]);
109108
$this->assertDatabaseHas('nestable_trees', ['nestable_id' => $content->id, 'nestable_type' => $content->getMorphClass()]);
110-
109+
111110
// Act
112111
$content->forceDelete();
113-
112+
114113
// Assert 2
115114
$this->assertDatabaseMissing('content', ['id' => $content->id]);
116115
$this->assertDatabaseMissing('content_versions', ['content_id' => $content->id]);
117116
$this->assertDatabaseMissing('nestable_trees', ['content_id' => $content->id]);
118117
});
119118

120-
121-
})->group('unit', 'model');
119+
})->group('unit', 'model');

tests/src/Unit/Models/DocumentTypeTest.php

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,14 @@
77

88
uses(TestCase::class);
99

10-
1110
describe('document type model', function () {
1211

1312
it('throws an exception when deleting a document type with content', function () {
1413
$this->expectException(\Exception::class);
1514
$this->expectExceptionMessage('Cannot delete this document type because it has content.');
16-
15+
1716
$documentType = DocumentType::factory(['category' => 'web'])->create();
18-
17+
1918
$content = Content::factory([
2019
'title' => ['en' => 1],
2120
'slug' => '1',
@@ -25,17 +24,16 @@
2524
])->create();
2625
$content->preloadContentVersionData();
2726
$content->save();
28-
27+
2928
$documentType->delete();
3029
});
31-
30+
3231
it('does not throw an exception when deleting a document type without content', function () {
3332
$documentType = DocumentType::factory(['category' => 'web'])->create();
34-
33+
3534
$documentType->delete();
36-
35+
3736
expect(true)->toBeTrue(); // If no exception is thrown, the test passes
3837
});
3938

40-
41-
})->group('unit', 'model');
39+
})->group('unit', 'model');

tests/src/Unit/Models/LanguageTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,18 @@
2020
expect($newDefaultLanguage->fresh()->is_default)->toBeTrue();
2121

2222
});
23-
23+
2424
it('can delete related content routes', function () {
2525
$en = Language::factory()->create(['code' => 'en', 'is_default' => true]);
2626
$fr = Language::factory()->create(['code' => 'fr', 'is_default' => false]);
2727

2828
$content = Content::factory()
2929
->has(ContentRoute::factory()->state([
30-
'language_id' => $fr->getKey(),
30+
'language_id' => $fr->getKey(),
3131
'uri' => 'abc',
3232
]), 'routes')
3333
->create();
34-
34+
3535
expect($content->routes->count())->toBe(1);
3636

3737
$fr->delete();
@@ -40,13 +40,13 @@
4040

4141
expect($content->routes->count())->toBe(0);
4242
});
43-
43+
4444
it('throws exception for default language when deleting', function () {
4545
$this->expectException(\Exception::class);
4646
$this->expectExceptionMessage('Cannot delete default language');
47-
47+
4848
$language = Language::factory()->create(['is_default' => true]);
4949
$language->delete();
5050
});
51-
52-
})->group('unit', 'model');
51+
52+
})->group('unit', 'model');

0 commit comments

Comments
 (0)