]> git.mxchange.org Git - friendica.git/commitdiff
a new unittest for prefix
authorPhilipp Holzer <admin@philipp.info>
Mon, 9 Jul 2018 20:15:11 +0000 (22:15 +0200)
committerPhilipp Holzer <admin@philipp.info>
Mon, 9 Jul 2018 20:15:11 +0000 (22:15 +0200)
tests/src/Core/SystemTest.php

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