Skip to content

Commit

Permalink
Minor change in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
peppeocchi committed Jan 28, 2018
1 parent 82b886b commit b575dec
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 36 deletions.
52 changes: 26 additions & 26 deletions tests/GO/JobOutputFilesTest.php
Expand Up @@ -14,11 +14,11 @@ public function testShouldWriteCommandOutputToSingleFile()
@unlink($outputFile);

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile));
$this->assertFileNotExists($outputFile);
$job->output($outputFile)->run();

sleep(2);
$this->assertTrue(file_exists($outputFile));
$this->assertFileExists($outputFile);

// Content should be 'hi'
$this->assertEquals('hi', file_get_contents($outputFile));
Expand All @@ -39,19 +39,19 @@ public function testShouldWriteCommandOutputToMultipleFiles()
@unlink($outputFile3);

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile1));
$this->assertFalse(file_exists($outputFile2));
$this->assertFalse(file_exists($outputFile3));
$this->assertFileNotExists($outputFile1);
$this->assertFileNotExists($outputFile2);
$this->assertFileNotExists($outputFile3);
$job->output([
$outputFile1,
$outputFile2,
$outputFile3,
])->run();

sleep(2);
$this->assertTrue(file_exists($outputFile1));
$this->assertTrue(file_exists($outputFile2));
$this->assertTrue(file_exists($outputFile3));
$this->assertFileExists($outputFile1);
$this->assertFileExists($outputFile2);
$this->assertFileExists($outputFile3);

$this->assertEquals('hi', file_get_contents($outputFile1));
$this->assertEquals('hi', file_get_contents($outputFile2));
Expand All @@ -74,11 +74,11 @@ public function testShouldWriteFunctionOutputToSingleFile()
@unlink($outputFile);

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile));
$this->assertFileNotExists($outputFile);
$job->output($outputFile)->run();

sleep(2);
$this->assertTrue(file_exists($outputFile));
$this->assertFileExists($outputFile);

$this->assertEquals('Hello World!', file_get_contents($outputFile));

Expand All @@ -99,19 +99,19 @@ public function testShouldWriteFunctionOutputToMultipleFiles()
@unlink($outputFile3);

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile1));
$this->assertFalse(file_exists($outputFile2));
$this->assertFalse(file_exists($outputFile3));
$this->assertFileNotExists($outputFile1);
$this->assertFileNotExists($outputFile2);
$this->assertFileNotExists($outputFile3);
$job->output([
$outputFile1,
$outputFile2,
$outputFile3,
])->run();

sleep(2);
$this->assertTrue(file_exists($outputFile1));
$this->assertTrue(file_exists($outputFile2));
$this->assertTrue(file_exists($outputFile3));
$this->assertFileExists($outputFile1);
$this->assertFileExists($outputFile2);
$this->assertFileExists($outputFile3);

$this->assertEquals('Hello', file_get_contents($outputFile1));
$this->assertEquals('Hello', file_get_contents($outputFile2));
Expand All @@ -130,11 +130,11 @@ public function testShouldWriteFunctionReturnToSingleFile()
$outputFile = __DIR__ . '/../tmp/output1.log';

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile));
$this->assertFileNotExists($outputFile);
$job->output($outputFile)->run();

sleep(2);
$this->assertTrue(file_exists($outputFile));
$this->assertFileExists($outputFile);

$this->assertEquals('Hello World!', file_get_contents($outputFile));

Expand All @@ -155,19 +155,19 @@ public function testShouldWriteFunctionReturnToMultipleFiles()
@unlink($outputFile3);

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile1));
$this->assertFalse(file_exists($outputFile2));
$this->assertFalse(file_exists($outputFile3));
$this->assertFileNotExists($outputFile1);
$this->assertFileNotExists($outputFile2);
$this->assertFileNotExists($outputFile3);
$job->output([
$outputFile1,
$outputFile2,
$outputFile3,
])->run();

sleep(2);
$this->assertTrue(file_exists($outputFile1));
$this->assertTrue(file_exists($outputFile2));
$this->assertTrue(file_exists($outputFile3));
$this->assertFileExists($outputFile1);
$this->assertFileExists($outputFile2);
$this->assertFileExists($outputFile3);

$this->assertEquals('Hello World!', file_get_contents($outputFile1));
$this->assertEquals('Hello World!', file_get_contents($outputFile2));
Expand All @@ -188,11 +188,11 @@ public function testShouldWriteFunctionOutputAndReturnToFile()
$outputFile = __DIR__ . '/../tmp/output1.log';

// Test fist that the file doesn't exist yet
$this->assertFalse(file_exists($outputFile));
$this->assertFileNotExists($outputFile);
$job->output($outputFile)->run();

sleep(2);
$this->assertTrue(file_exists($outputFile));
$this->assertFileExists($outputFile);

$this->assertEquals('Hello World!', file_get_contents($outputFile));

Expand Down
18 changes: 9 additions & 9 deletions tests/GO/JobTest.php
Expand Up @@ -172,11 +172,11 @@ public function testShouldCreateLockFileIfOnlyOne()

@unlink($lockFile);

$this->assertFalse(file_exists($lockFile));
$this->assertFileNotExists($lockFile);

$job->onlyOne()->run();

$this->assertTrue(file_exists($lockFile));
$this->assertFileExists($lockFile);
}

public function testShouldCreateLockFilesInCustomPath()
Expand All @@ -190,11 +190,11 @@ public function testShouldCreateLockFilesInCustomPath()

@unlink($lockFile);

$this->assertFalse(file_exists($lockFile));
$this->assertFileNotExists($lockFile);

$job->onlyOne($tmpDir)->run();

$this->assertTrue(file_exists($lockFile));
$this->assertFileExists($lockFile);
}

public function testShouldRemoveLockFileAfterRunningClosures()
Expand All @@ -209,7 +209,7 @@ public function testShouldRemoveLockFileAfterRunningClosures()

$job->onlyOne($tmpDir)->run();

$this->assertFalse(file_exists($lockFile));
$this->assertFileNotExists($lockFile);
}

public function testShouldRemoveLockFileAfterRunningCommands()
Expand All @@ -225,11 +225,11 @@ public function testShouldRemoveLockFileAfterRunningCommands()

sleep(1);

$this->assertTrue(file_exists($lockFile));
$this->assertFileExists($lockFile);

sleep(5);

$this->assertFalse(file_exists($lockFile));
$this->assertFileNotExists($lockFile);
}

public function testShouldKnowIfOverlapping()
Expand Down Expand Up @@ -291,7 +291,7 @@ public function testShouldRunIfOverlappingCallbackReturnsTrue()
// The job should run now as the function should now return true,
// while it's still being executed
$lockFile = $tmpDir . '/' . $job->getId() . '.lock';
$this->assertTrue(file_exists($lockFile));
$this->assertFileExists($lockFile);
$this->assertTrue($job->run());
}

Expand All @@ -308,7 +308,7 @@ public function testShouldAcceptTempDirInConfiguration()

sleep(1);

$this->assertTrue(file_exists($tmpDir . '/' . $job->getId() . '.lock'));
$this->assertFileExists($tmpDir . '/' . $job->getId() . '.lock');
}

public function testWhenMethodShouldBeChainable()
Expand Down
2 changes: 1 addition & 1 deletion tests/GO/SchedulerTest.php
Expand Up @@ -138,7 +138,7 @@ public function testShouldPassParametersToAFunction()

@unlink($outputFile);

$this->assertFalse(file_exists($outputFile));
$this->assertFileNotExists($outputFile);

$scheduler->run();

Expand Down

0 comments on commit b575dec

Please sign in to comment.