a new unittest for prefix

This commit is contained in:
Philipp Holzer 2018-07-09 22:15:11 +02:00
parent a84c94e94b
commit e5c767d809
No known key found for this signature in database
GPG key ID: 58160D7D6AF942B6

View file

@ -7,10 +7,11 @@ use PHPUnit\Framework\TestCase;
class SystemTest extends TestCase class SystemTest extends TestCase
{ {
private function assertGuid($guid, $length) private function assertGuid($guid, $length, $prefix = '')
{ {
print $guid; print $guid;
$this->assertRegExp("/^[a-z0-9]{" . $length . "}?$/", $guid); $length -= strlen($prefix);
$this->assertRegExp("/^" . $prefix . "[a-z0-9]{" . $length . "}?$/", $guid);
} }
function testGuidWithoutParameter() function testGuidWithoutParameter()
@ -28,4 +29,9 @@ class SystemTest extends TestCase
$guid = System::createGUID(64); $guid = System::createGUID(64);
$this->assertGuid($guid, 64); $this->assertGuid($guid, 64);
} }
function testGuidWithPrefix() {
$guid = System::createGUID(23, 'test');
$this->assertGuid($guid, 23, 'test');
}
} }