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 });
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 ' );
0 commit comments