Page Menu
Home
DevCentral
Search
Configure Global Search
Log In
Files
F22589775
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
Sat, Jan 31, 17:43 (22 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3398163
Default Alt Text
(1 KB)
Attached To
Mode
rKERUALD Keruald libraries development repository
Attached
Detach File
Event Timeline
Log In to Comment