102 lines
2.7 KiB
PHP
102 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use App\Console\Commands\Jabali\UpgradeCommand;
|
|
use Tests\TestCase;
|
|
|
|
class UpgradeCommandTest extends TestCase
|
|
{
|
|
public function test_composer_runs_when_lock_changed(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertTrue(
|
|
$command->exposesShouldRunComposer(['composer.lock'], false, true)
|
|
);
|
|
}
|
|
|
|
public function test_composer_runs_when_vendor_missing(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertTrue(
|
|
$command->exposesShouldRunComposer([], false, false)
|
|
);
|
|
}
|
|
|
|
public function test_composer_skips_without_changes(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertFalse(
|
|
$command->exposesShouldRunComposer(['routes/web.php'], false, true)
|
|
);
|
|
}
|
|
|
|
public function test_npm_runs_when_resources_change(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertTrue(
|
|
$command->exposesShouldRunNpm(['resources/css/app.css'], false, true, true)
|
|
);
|
|
}
|
|
|
|
public function test_npm_runs_when_manifest_missing(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertTrue(
|
|
$command->exposesShouldRunNpm([], false, false, true)
|
|
);
|
|
}
|
|
|
|
public function test_npm_skips_when_no_package_json(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertFalse(
|
|
$command->exposesShouldRunNpm([], false, true, false)
|
|
);
|
|
}
|
|
|
|
public function test_migrations_run_when_migration_changes(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertTrue(
|
|
$command->exposesShouldRunMigrations(['database/migrations/2026_01_24_000001.php'], false)
|
|
);
|
|
}
|
|
|
|
public function test_migrations_skip_without_changes(): void
|
|
{
|
|
$command = new TestableUpgradeCommand;
|
|
|
|
$this->assertFalse(
|
|
$command->exposesShouldRunMigrations(['app/Models/User.php'], false)
|
|
);
|
|
}
|
|
}
|
|
|
|
class TestableUpgradeCommand extends UpgradeCommand
|
|
{
|
|
public function exposesShouldRunComposer(array $changedFiles, bool $force, bool $hasVendor): bool
|
|
{
|
|
return $this->shouldRunComposerInstall($changedFiles, $force, $hasVendor);
|
|
}
|
|
|
|
public function exposesShouldRunNpm(array $changedFiles, bool $force, bool $hasManifest, bool $hasPackageJson): bool
|
|
{
|
|
return $this->shouldRunNpmBuild($changedFiles, $force, $hasManifest, $hasPackageJson);
|
|
}
|
|
|
|
public function exposesShouldRunMigrations(array $changedFiles, bool $force): bool
|
|
{
|
|
return $this->shouldRunMigrations($changedFiles, $force);
|
|
}
|
|
}
|