Skip to content

Commit 76a9cd6

Browse files
committed
fix tests
1 parent d428653 commit 76a9cd6

File tree

4 files changed

+26
-5
lines changed

4 files changed

+26
-5
lines changed

app/Jobs/CheckSiteHealth.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ public function handle(): void
4343
$this->site->save();
4444

4545
// Check if conditions are met
46-
// @phpstan-ignore-next-line
4746
if (!$this->site->update_requirement_state) {
4847
return;
4948
}

app/RemoteSite/Responses/HealthCheck.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function __construct(
1212
public string $db_version,
1313
public string $cms_version,
1414
public string $server_os,
15-
public bool $update_requirement_state
15+
public ?bool $update_requirement_state = null
1616
) {
1717
}
1818
}

database/migrations/2025_05_18_143851_add_update_requirement_state_to_sites_table.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
use Illuminate\Database\Schema\Blueprint;
55
use Illuminate\Support\Facades\Schema;
66

7-
return new class extends Migration
8-
{
7+
return new class extends Migration {
98
/**
109
* Run the migrations.
1110
*/

tests/Unit/Jobs/UpdateSiteTest.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,28 @@ public function testJobQuitsIfNoUpdateIsAvailable()
5959
$this->assertTrue(true);
6060
}
6161

62+
public function testJobQuitsIfRequirementsArentMet()
63+
{
64+
$site = $this->getSiteMock(
65+
[
66+
'checkHealth' => $this->getHealthCheckMock(['update_requirement_state' => false])
67+
]
68+
);
69+
70+
Log::spy();
71+
72+
$object = new UpdateSite($site, "1.0.1");
73+
$object->handle();
74+
75+
Log::shouldHaveReceived('info')
76+
->once()
77+
->withArgs(function ($message) {
78+
return str_contains($message, 'Site does not meet requirements, abort');
79+
});
80+
81+
$this->assertTrue(true);
82+
}
83+
6284
public function testJobQuitsIfWeDetectALoopForAVersion()
6385
{
6486
$site = $this->getSiteMock([], null, 6);
@@ -241,7 +263,8 @@ protected function getHealthCheckMock($overrides = [])
241263
"db_type" => "mysqli",
242264
"db_version" => "1.0.0",
243265
"cms_version" => "1.0.0",
244-
"server_os" => "Joomla OS 1.0.0"
266+
"server_os" => "Joomla OS 1.0.0",
267+
"update_requirement_state" => true
245268
];
246269

247270
return HealthCheck::from([

0 commit comments

Comments
 (0)