HashesTest::testGenerate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 14
rs 9.9332
c 0
b 0
f 0
1
<?php declare(strict_types = 1);
2
3
namespace Apicart\Utils\Tests\Hashes;
4
5
use Apicart\Utils\Hashes\Hashes;
6
use PHPUnit\Framework\TestCase;
7
8
final class HashesTest extends TestCase
9
{
10
11
	public function testGenerate(): void
12
	{
13
		$hash = Hashes::generate();
14
		self::assertTrue(strlen($hash) === 32);
15
		self::assertTrue((bool) preg_match('#^[a-z0-9]{32}$#', $hash));
16
17
		$anotherHash = Hashes::generate();
18
		self::assertTrue(strlen($anotherHash) === 32);
19
		self::assertTrue((bool) preg_match('#^[a-z0-9]{32}$#', $anotherHash));
20
		self::assertNotSame($hash, $anotherHash);
21
22
		$customHash = Hashes::generate(10, 'A-Z');
23
		self::assertTrue(strlen($customHash) === 10);
24
		self::assertTrue((bool) preg_match('#^[A-Z]{10}$#', $customHash));
25
	}
26
27
}
28