File tree Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Expand file tree Collapse file tree 1 file changed +19
-3
lines changed Original file line number Diff line number Diff line change 1010use App \TUF \TufFetcher ;
1111use Illuminate \Support \Facades \App ;
1212use Illuminate \Support \Facades \Queue ;
13+ use PHPUnit \Framework \Attributes \DataProvider ;
1314use Tests \TestCase ;
1415
1516class CheckSiteHealthTest extends TestCase
@@ -35,7 +36,8 @@ public function testCheckSiteHealthUpdatesDbRow()
3536 $ object ->handle ();
3637 }
3738
38- public function testCheckHealthTriggersUpdateJobIfNewerVersionIsAvailable ()
39+ #[DataProvider('updateNecessityProvider ' )]
40+ public function testCheckHealthTriggersUpdateJobIfRequired ($ currentVersion , $ doUpdate )
3941 {
4042 Queue::fake ();
4143
@@ -50,14 +52,28 @@ public function testCheckHealthTriggersUpdateJobIfNewerVersionIsAvailable()
5052 ->disableOriginalConstructor ()
5153 ->getMock ();
5254
53- $ tufMock ->method ('getLatestVersionForBranch ' )->willReturn (" 2.0.0 " );
55+ $ tufMock ->method ('getLatestVersionForBranch ' )->willReturn ($ currentVersion );
5456
5557 App::bind (TufFetcher::class, fn () => $ tufMock );
5658
5759 $ object = new CheckSiteHealth ($ siteMock );
5860 $ object ->handle ();
5961
60- Queue::assertPushed (UpdateSite::class);
62+ if ($ doUpdate ) {
63+ Queue::assertPushed (UpdateSite::class);
64+ } else {
65+ Queue::assertNotPushed (UpdateSite::class);
66+ }
67+ }
68+
69+ public static function updateNecessityProvider (): array
70+ {
71+ return [
72+ ['0.9.1 ' , false ],
73+ ['1.0.0 ' , false ],
74+ ['1.0.1 ' , true ],
75+ ['2.0.0 ' , true ]
76+ ];
6177 }
6278
6379 protected function getSiteMock ($ healthMock )
You can’t perform that action at this time.
0 commit comments