HashesTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 11
dl 0
loc 17
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGenerate() 0 14 1
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