Page MenuHomeDevCentral

No OneTemporary

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

Mime Type
text/x-diff
Expires
Sun, Nov 24, 18:46 (4 h, 49 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2258691
Default Alt Text
(1 KB)

Event Timeline