Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/Jobs/CheckSiteHealth.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function handle(): void
}

// Available version is not newer, exit
if (version_compare($latestVersion, $this->site->cms_version, "<")) {
if (version_compare($latestVersion, $this->site->cms_version, "<=")) {
return;
}

Expand Down
22 changes: 19 additions & 3 deletions tests/Unit/Jobs/CheckSiteHealthTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use App\TUF\TufFetcher;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Queue;
use PHPUnit\Framework\Attributes\DataProvider;
use Tests\TestCase;

class CheckSiteHealthTest extends TestCase
Expand All @@ -35,7 +36,8 @@ public function testCheckSiteHealthUpdatesDbRow()
$object->handle();
}

public function testCheckHealthTriggersUpdateJobIfNewerVersionIsAvailable()
#[DataProvider('updateNecessityProvider')]
public function testCheckHealthTriggersUpdateJobIfRequired($currentVersion, $doUpdate)
{
Queue::fake();

Expand All @@ -50,14 +52,28 @@ public function testCheckHealthTriggersUpdateJobIfNewerVersionIsAvailable()
->disableOriginalConstructor()
->getMock();

$tufMock->method('getLatestVersionForBranch')->willReturn("2.0.0");
$tufMock->method('getLatestVersionForBranch')->willReturn($currentVersion);

App::bind(TufFetcher::class, fn () => $tufMock);

$object = new CheckSiteHealth($siteMock);
$object->handle();

Queue::assertPushed(UpdateSite::class);
if ($doUpdate) {
Queue::assertPushed(UpdateSite::class);
} else {
Queue::assertNotPushed(UpdateSite::class);
}
}

public static function updateNecessityProvider(): array
{
return [
['0.9.1', false],
['1.0.0', false],
['1.0.1', true],
['2.0.0', true]
];
}

protected function getSiteMock($healthMock)
Expand Down