test fixes

Signed-off-by: Andy Miller <rhuk@mac.com>
This commit is contained in:
Andy Miller
2025-11-09 13:11:17 +00:00
parent 0764e37c8b
commit 73d3a90c0b
3 changed files with 16 additions and 10 deletions

View File

@@ -404,7 +404,7 @@ class SelfupgradeCommand extends GpmCommand
$isMajorMinorUpgrade = $preflight['is_major_minor_upgrade'] ?? false;
// Fall back to calculating it if not provided (for backwards compatibility)
if (!isset($preflight['is_major_minor_upgrade'])) {
if (!isset($preflight['is_major_minor_upgrade']) && $this->upgrader) {
$local = $this->upgrader->getLocalVersion();
$remote = $this->upgrader->getRemoteVersion();
$localParts = explode('.', $local);
@@ -418,8 +418,8 @@ class SelfupgradeCommand extends GpmCommand
$isMajorMinorUpgrade = ($localMajor !== $remoteMajor) || ($localMinor !== $remoteMinor);
}
$local = $this->upgrader->getLocalVersion();
$remote = $this->upgrader->getRemoteVersion();
$local = $this->upgrader ? $this->upgrader->getLocalVersion() : 'unknown';
$remote = $this->upgrader ? $this->upgrader->getRemoteVersion() : 'unknown';
$io->newLine();
$io->writeln('<yellow>The following packages need updating before Grav upgrade:</yellow>');

View File

@@ -106,7 +106,7 @@ class StubSafeUpgradeService extends SafeUpgradeService
parent::__construct([]);
}
public function preflight(): array
public function preflight(?string $targetVersion = null): array
{
return $this->report;
}

View File

@@ -18,7 +18,8 @@ class SelfupgradeCommandTest extends \PHPUnit\Framework\TestCase
$result = $command->runHandle([
'plugins_pending' => [],
'psr_log_conflicts' => [],
'warnings' => []
'warnings' => [],
'is_major_minor_upgrade' => false
]);
self::assertTrue($result);
@@ -34,7 +35,8 @@ class SelfupgradeCommandTest extends \PHPUnit\Framework\TestCase
$result = $command->runHandle([
'plugins_pending' => ['foo' => ['type' => 'plugin', 'current' => '1', 'available' => '2']],
'psr_log_conflicts' => ['bar' => ['requires' => '^1.0']],
'warnings' => ['pending']
'warnings' => ['pending'],
'is_major_minor_upgrade' => true
]);
self::assertFalse($result);
@@ -51,7 +53,8 @@ class SelfupgradeCommandTest extends \PHPUnit\Framework\TestCase
$result = $command->runHandle([
'plugins_pending' => ['foo' => ['type' => 'plugin', 'current' => '1', 'available' => '2']],
'psr_log_conflicts' => [],
'warnings' => []
'warnings' => [],
'is_major_minor_upgrade' => true
]);
self::assertFalse($result);
@@ -67,7 +70,8 @@ class SelfupgradeCommandTest extends \PHPUnit\Framework\TestCase
$result = $command->runHandle([
'plugins_pending' => [],
'psr_log_conflicts' => ['foo' => ['requires' => '^1.0']],
'warnings' => []
'warnings' => [],
'is_major_minor_upgrade' => false
]);
self::assertFalse($result);
@@ -93,7 +97,8 @@ class SelfupgradeCommandTest extends \PHPUnit\Framework\TestCase
$result = $command->runHandle([
'plugins_pending' => [],
'psr_log_conflicts' => ['foo' => ['requires' => '^1.0']],
'warnings' => []
'warnings' => [],
'is_major_minor_upgrade' => false
]);
self::assertTrue($result);
@@ -110,7 +115,8 @@ class SelfupgradeCommandTest extends \PHPUnit\Framework\TestCase
$result = $command->runHandle([
'plugins_pending' => [],
'psr_log_conflicts' => ['foo' => ['requires' => '^1.0']],
'warnings' => []
'warnings' => [],
'is_major_minor_upgrade' => false
]);
self::assertTrue($result);