Skip to content

Commit

Permalink
Adds integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
raphaelstolt committed May 7, 2024
1 parent af2f7ed commit 994ea98
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/Domain/PackageAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ private function checkCliBinaryDirectoryExistence(): ViolationStatus
return ViolationStatus::True;
}

$this->alternateStepStatus('cli-binary', ViolationStatus::True);
$this->alternateStepStatus('cli-binary', ViolationStatus::False);

return ViolationStatus::False;
}
Expand Down
18 changes: 17 additions & 1 deletion tests/Feature/AnalyseCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,24 @@
$this->artisan('analyse '.$this->temporaryDirectory)->expectsOutputToContain('Ran 16 analysis steps');
});

it('has violations in output', function () {
it('has success emoji for successful analyse step', function () {
$this->artisan('analyse '.$this->temporaryDirectory)->expectsOutputToContain('');
});

it('has violations in output and fails', function () {
$this->artisan('analyse '.$this->temporaryDirectory)->expectsOutputToContain('optimiseable aspects')->assertExitCode(
Command::FAILURE
);
});

it('can alternate command failure state', function () {
$this->artisan('analyse '.$this->temporaryDirectory.' --violations-threshold=16')->assertExitCode(Command::SUCCESS);
});

it('writes a HTML report if desired', function () {
$this->artisan('analyse '.$this->temporaryDirectory.' --write-report')->expectsOutputToContain('Writing package analysis report to');
});

it('has its expected options', function () {
$this->artisan('analyse --help')->expectsOutputToContain('--write-report', '--violations-threshold[=VIOLATIONS-THRESHOLD]');
});
2 changes: 1 addition & 1 deletion tests/Unit/PackageAnalyserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
new PackageAnalyser($nonExistentPackageDirectory);
})->throws(NonExistentPackageDirectory::class, sprintf("Provided package directory '%s' does not exist", '/tmp/non-existent-package-directory'));

test('violations have status ViolationStatus::False', function () {
test('violations have default status ViolationStatus::False', function () {
$packageAnalyser = new PackageAnalyser('/tmp');
$violations = $packageAnalyser->getViolations();
foreach ($violations as $violation) {
Expand Down

0 comments on commit 994ea98

Please sign in to comment.