Browse Source

[Nostromo] Improve tests

pull/1/head
Andrés Montañez 8 years ago
parent
commit
ff6d8b174f
  1. 15
      src/Mage/Tests/Runtime/RuntimeTest.php

15
src/Mage/Tests/Runtime/RuntimeTest.php

@ -18,17 +18,26 @@ use Monolog\Handler\TestHandler;
use PHPUnit_Framework_TestCase as TestCase; use PHPUnit_Framework_TestCase as TestCase;
use Psr\Log\LogLevel; use Psr\Log\LogLevel;
use Symfony\Component\Process\Process; use Symfony\Component\Process\Process;
use DateTime;
class RuntimeTest extends TestCase class RuntimeTest extends TestCase
{ {
public function testReleaseIdGeneration() public function testReleaseIdGeneration()
{ {
$releaseId = date('YmdHis'); // Given that this is a time based operation, lets conform that at least the format is right
// and the time diff is less than 2 seconds
$now = new DateTime();
$runtime = new Runtime(); $runtime = new Runtime();
$runtime->generateReleaseId(); $runtime->generateReleaseId();
$releaseId = $runtime->getReleaseId();
$releaseDate = DateTime::createFromFormat('YmdHis', $releaseId);
$this->assertTrue($releaseDate instanceof DateTime);
$this->assertEquals($releaseId, $runtime->getReleaseId()); $dateDiff = $releaseDate->diff($now);
$this->assertLessThanOrEqual(2, $dateDiff->s);
} }
public function testEmptyEnvironmentConfig() public function testEmptyEnvironmentConfig()
@ -65,6 +74,8 @@ class RuntimeTest extends TestCase
$this->assertNotEquals('', $tempFile); $this->assertNotEquals('', $tempFile);
$this->assertTrue(file_exists($tempFile)); $this->assertTrue(file_exists($tempFile));
$this->assertTrue(is_readable($tempFile));
$this->assertTrue(is_writable($tempFile));
$this->assertEquals(0, filesize($tempFile)); $this->assertEquals(0, filesize($tempFile));
} }

Loading…
Cancel
Save