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 tests/Unit/Repositories/ServerRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions tests/Unit/Services/FilesystemServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/Services/VersionServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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())) {
Expand Down
13 changes: 8 additions & 5 deletions tests/Unit/TestHelpersTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
3 changes: 1 addition & 2 deletions tests/Unit/Traits/ConsoleOutputTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
$output = $this->tester->getDisplay();

// ASSERT
expect($output)->toContain('╭───────')
->and(strlen($output))->toBeGreaterThan(40);
expect($output)->toContain('╭───────');
});

//
Expand Down