generated from ergebnis/php-package-template
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUuidProviderTest.php
64 lines (51 loc) · 2.18 KB
/
UuidProviderTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
declare(strict_types=1);
/**
* Copyright (c) 2021-2025 Andreas Möller
*
* For the full copyright and license information, please view
* the LICENSE.md file that was distributed with this source code.
*
* @see https://github.com/ergebnis/data-provider
*/
use Ergebnis\DataProvider\Test;
use Ergebnis\DataProvider\UuidProvider;
/**
* @covers \Ergebnis\DataProvider\AbstractProvider
* @covers \Ergebnis\DataProvider\UuidProvider
*/
final class UuidProviderTest extends Test\Unit\AbstractProviderTestCase
{
/**
* @dataProvider \Ergebnis\DataProvider\UuidProvider::arbitrary
*/
public function testArbitraryProvidesUuids(string $value): void
{
self::assertMatchesRegularExpression('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i', $value);
}
public function testArbitraryReturnsGeneratorThatProvidesUuidStrings(): void
{
$specifications = [
'uuid-case-lower' => Test\Util\Specification\Pattern::create('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'),
'uuid-case-upper' => Test\Util\Specification\Pattern::create('/^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/'),
];
$provider = UuidProvider::arbitrary();
self::assertProvidesDataSetsForValuesSatisfyingSpecifications($specifications, $provider);
}
public function testCaseLowerReturnsGeneratorThatProvidesLowerCaseUuid(): void
{
$specifications = [
'uuid-case-lower' => Test\Util\Specification\Pattern::create('/^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/'),
];
$provider = UuidProvider::caseLower();
self::assertProvidesDataSetsForValuesSatisfyingSpecifications($specifications, $provider);
}
public function testCaseUpperReturnsGeneratorThatProvidesUpperCaseUuid(): void
{
$specifications = [
'uuid-case-upper' => Test\Util\Specification\Pattern::create('/^[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}$/'),
];
$provider = UuidProvider::caseUpper();
self::assertProvidesDataSetsForValuesSatisfyingSpecifications($specifications, $provider);
}
}