Skip to content

Commit

Permalink
Test validate script runs without failure
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Dec 6, 2018
1 parent 55ac0a4 commit 2dace6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
10 changes: 10 additions & 0 deletions test/unit/Command/CommandTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ protected function getStream():Stream {
return $stream;
}

protected static function assertStreamOutput(
string $message,
Stream $stream
) {
$errorStream = $stream->getOutStream();
$errorStream->rewind();
$contents = $errorStream->fgets();
self::assertStringContainsString($message, $contents);
}

protected static function assertStreamError(
string $message,
Stream $stream
Expand Down
11 changes: 11 additions & 0 deletions test/unit/Command/ValidateCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,15 @@ public function testNotFound() {

self::assertStreamError("crontab file not found at", $stream);
}

public function testRun() {
chdir($this->projectDirectory);
$this->writeCronContents("* * * * * Example::test");

$stream = $this->getStream();
$command = new ValidateCommand($stream);
$command->run(new ArgumentValueList());

self::assertStreamOutput("OK", $stream);
}
}

0 comments on commit 2dace6f

Please sign in to comment.