php-ipc/tests/Key/FileKeyTest.php

39 lines
870 B
PHP
Raw Permalink Normal View History

2018-04-15 14:41:46 +00:00
<?php
namespace NoccyLabs\Ipc\Key;
class FileKeyTest extends \PhpUnit\Framework\TestCase
{
public function testKeyGenerationFromExistingFile()
{
$keyfile = new FileKey(__FILE__);
$key = $keyfile->getKey();
$this->assertGreaterThan(0, $key);
}
public function testKeyGenerationFromTemporaryFile()
{
$tempfile = "/tmp/key.tmp";
file_exists($tempfile) && unlink($tempfile);
$keyfile = new FileKey($tempfile, "a", true);
$key = $keyfile->getKey();
$this->assertGreaterThan(0, $key);
}
public function testCloningShouldIncreaseProject()
{
$keyfile = new FileKey(__FILE__, "a");
$this->assertEquals("a", $keyfile->getProjectIdentifier());
$keyfile2 = clone $keyfile;
$this->assertEquals("b", $keyfile2->getProjectIdentifier());
}
}