Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F11726365
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/tests/Identifiers/RandomTest.php b/tests/Identifiers/RandomTest.php
index 0188a9e..75ebe88 100644
--- a/tests/Identifiers/RandomTest.php
+++ b/tests/Identifiers/RandomTest.php
@@ -1,46 +1,54 @@
<?php
declare(strict_types=1);
namespace Keruald\OmniTools\Tests\Identifiers;
use Keruald\OmniTools\Identifiers\Random;
use Phpunit\Framework\TestCase;
class RandomTest extends TestCase {
+ ///
+ /// Tests
+ ///
+
public function testGenerateHexadecimalHash () : void {
$hash = Random::generateHexHash();
$this->assertEquals(
32, strlen($hash),
"$hash size must be 32 characters"
);
$this->assertRegExp("/[0-9a-f]{32}/", $hash);
}
public function testHexadecimalHashesAreUnique() : void {
$this->assertNotEquals(
Random::generateHexHash(),
Random::generateHexHash()
);
}
/**
* @dataProvider provideRandomStringFormats
*/
public function testRandomString($format, $re, $len) : void {
$string = Random::generateString($format);
$this->assertEquals($len, strlen($format));
$this->assertRegExp($re, $string);
}
+ ///
+ /// Data providers
+ ///
+
public function provideRandomStringFormats() : iterable {
yield ["AAA111", "/^[A-Z]{3}[0-9]{3}$/", 6];
yield ["AAA123", "/^[A-Z]{3}[0-9]{3}$/", 6];
yield ["ABC123", "/^[A-Z]{3}[0-9]{3}$/", 6];
yield ["", "/^$/", 0];
}
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Fri, Sep 19, 03:04 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2990683
Default Alt Text
(1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment