Skip to content

Commit

Permalink
Merge pull request #81 from jolicode/fix-transient-test
Browse files Browse the repository at this point in the history
fixed transcient tests
  • Loading branch information
lyrixx authored May 31, 2023
2 parents 7a4a660 + 7bed9d1 commit 22e280a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 13 deletions.
36 changes: 31 additions & 5 deletions tests/Examples/ParallelSleepTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Castor\Tests\Examples;

use Castor\Tests\TaskTestCase;
use PHPUnit\Framework\ExpectationFailedException;

class ParallelSleepTest extends TaskTestCase
{
Expand All @@ -12,11 +13,36 @@ public function test(): void
$process = $this->runTask(['parallel:sleep', '--sleep5', '0', '--sleep7', '0', '--sleep10', '0']);

$this->assertSame(0, $process->getExitCode());
$this->assertStringEqualsFile(__FILE__ . '.output.txt', $process->getOutput());
if (file_exists(__FILE__ . '.err.txt')) {
$this->assertStringEqualsFile(__FILE__ . '.err.txt', $process->getErrorOutput());
} else {
$this->assertSame('', $process->getErrorOutput());

$startWith = <<<'OUTPUT'
sleep 0
sleep 0
re sleep 0
sleep 0
OUTPUT;

try {
$this->assertStringStartsWith($startWith, $process->getOutput());
} catch (ExpectationFailedException) {
// The order of the fibers might be different. So we try another
// order.
$startWith = <<<'OUTPUT'
sleep 0
sleep 0
sleep 0
re sleep 0
OUTPUT;
$this->assertStringStartsWith($startWith, $process->getOutput());
}

$endWith = <<<'OUTPUT'
Foo: foo
Bar: bar
Sleep 10: sleep 0
Duration: 0

OUTPUT;
$this->assertStringEndsWith($endWith, $process->getOutput());
$this->assertSame('', $process->getErrorOutput());
}
}
8 changes: 0 additions & 8 deletions tests/Examples/ParallelSleepTest.php.output.txt

This file was deleted.

0 comments on commit 22e280a

Please sign in to comment.