-
Notifications
You must be signed in to change notification settings - Fork 16
/
FingerprintTaskWithAFingerprintTest.php
37 lines (28 loc) 路 1.23 KB
/
FingerprintTaskWithAFingerprintTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace Castor\Tests\Examples\Fingerprint;
class FingerprintTaskWithAFingerprintTest extends FingerprintedTestCase
{
// fingerprint:task-with-a-fingerprint
public function test(): void
{
// Run for the first time, should run
$this->runProcessAndExpect(__FILE__ . '.output_runnable.txt');
// should not run because the fingerprint is the same
$this->runProcessAndExpect(__FILE__ . '.output_not_runnable.txt');
// change file content, should run
$this->runProcessAndExpect(__FILE__ . '.output_runnable.txt', 'Hello World');
}
private function runProcessAndExpect(string $expectedOutputFilePath, string $withFileContent = 'Hello'): void
{
$filepath = \dirname(__DIR__, 3) . '/examples/fingerprint_file.fingerprint_single';
if (file_exists($filepath)) {
unlink($filepath);
}
file_put_contents($filepath, $withFileContent);
$process = $this->runTask(['fingerprint:task-with-complete-fingerprint-check']);
if (file_exists($expectedOutputFilePath)) {
self::assertStringEqualsFile($expectedOutputFilePath, $process->getOutput());
}
$this->assertSame(0, $process->getExitCode());
}
}