diff --git a/tests/Unit/Repositories/ServerRepositoryTest.php b/tests/Unit/Repositories/ServerRepositoryTest.php index 5eb5098a..580bf6b8 100644 --- a/tests/Unit/Repositories/ServerRepositoryTest.php +++ b/tests/Unit/Repositories/ServerRepositoryTest.php @@ -54,7 +54,7 @@ // ASSERT - All returns both servers $all = $repository->all(); expect($all)->toHaveCount(2) - ->and($all[0])->toBeInstanceOf(ServerDTO::class) + ->and($all[0]->name)->toBe('web1') ->and($all[1]->name)->toBe('web2'); // ACT & ASSERT - Delete diff --git a/tests/Unit/Services/FilesystemServiceTest.php b/tests/Unit/Services/FilesystemServiceTest.php index c11d70cf..eb7b58e3 100644 --- a/tests/Unit/Services/FilesystemServiceTest.php +++ b/tests/Unit/Services/FilesystemServiceTest.php @@ -80,8 +80,9 @@ public function dumpFile(string $filename, $content): void // ACT $result = $service->getCwd(); - // ASSERT - expect($result)->toBeString()->not->toBeEmpty(); + // ASSERT - Should return a valid directory path + expect($result)->toBeString() + ->and($service->isDirectory($result))->toBeTrue('getCwd should return valid directory'); }); it('checks if path is directory', function (string $path, bool $expected) { diff --git a/tests/Unit/Services/VersionServiceTest.php b/tests/Unit/Services/VersionServiceTest.php index 69b281f3..c171024e 100644 --- a/tests/Unit/Services/VersionServiceTest.php +++ b/tests/Unit/Services/VersionServiceTest.php @@ -12,9 +12,9 @@ // ACT $version = $service->getVersion(); - // ASSERT - Version should be a non-empty string - expect($version)->toBeString() - ->and(strlen($version))->toBeGreaterThan(0); + // ASSERT - Version should match valid version patterns (semver, git-describe, branch names, or commit hashes) + expect($version)->toMatch('/^(v?\d+\.\d+\.\d+|dev-|main-|master-|[0-9a-f]{7,40})/') + ->and($version)->not->toBeEmpty(); // ASSERT - If we're in a git repo, git version takes priority over fallback if ($service->isGitRepository(getcwd())) { diff --git a/tests/Unit/TestHelpersTest.php b/tests/Unit/TestHelpersTest.php index 1ae25875..81248e12 100644 --- a/tests/Unit/TestHelpersTest.php +++ b/tests/Unit/TestHelpersTest.php @@ -160,23 +160,26 @@ $service = mockFilesystemService(fileExists: true, fileContent: 'test content', filePath: 'test.txt'); // ACT - $exists = $service->exists('test.txt'); $content = $service->readFile('test.txt'); // ASSERT - expect($exists)->toBeTrue() - ->and($content)->toBe('test content'); + expect($content)->toBe('test content'); }); }); describe('mockCommandContainer', function () { it('creates container with all BaseCommand dependencies bound', function () { - // ACT + // ARRANGE $container = mockCommandContainer(); $command = $container->build(\Bigpixelrocket\DeployerPHP\Tests\Fixtures\TestConsoleCommand::class); + // ACT - Verify command is properly configured and executable + $tester = new \Symfony\Component\Console\Tester\CommandTester($command); + $exitCode = $tester->execute([]); + // ASSERT - expect($command)->toBeInstanceOf(\Bigpixelrocket\DeployerPHP\Tests\Fixtures\TestConsoleCommand::class); + expect($command)->toBeInstanceOf(\Bigpixelrocket\DeployerPHP\Tests\Fixtures\TestConsoleCommand::class) + ->and($exitCode)->toBe(\Symfony\Component\Console\Command\Command::SUCCESS); }); it('allows overriding specific services', function () { diff --git a/tests/Unit/Traits/ConsoleOutputTraitTest.php b/tests/Unit/Traits/ConsoleOutputTraitTest.php index 97c06681..181b3948 100644 --- a/tests/Unit/Traits/ConsoleOutputTraitTest.php +++ b/tests/Unit/Traits/ConsoleOutputTraitTest.php @@ -126,8 +126,7 @@ $output = $this->tester->getDisplay(); // ASSERT - expect($output)->toContain('╭───────') - ->and(strlen($output))->toBeGreaterThan(40); + expect($output)->toContain('╭───────'); }); //