Completed
Pull Request — master (#10)
by Gabriel
60:20
created

testConstructorAcceptValidUuids()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 10
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\AddressChangeContext\Tests\Unit\Domain\Model;
6
7
use PHPUnit\Framework\TestCase;
8
use WMDE\Fundraising\AddressChangeContext\Domain\Model\AddressChangeId;
9
10
class AddressChangeIdTest extends TestCase {
11
12
	public function testConstructorAcceptValidUuids(): void {
13
		$uuid = '72dfed91-fa40-4af0-9e80-c6010ab29cd1';
14
		$addressChangeId = AddressChangeId::fromString( $uuid );
15
16
		$this->assertSame( $uuid, $addressChangeId->__toString() );
17
	}
18
19
	/**
20
	 * @dataProvider invalidUUIDProvider
21
	 */
22
	public function testPersonalAddressChangeThrowsExceptionsWhenUUIDIsInvalid( string $invalidUUID ): void {
23
		$this->expectException( \InvalidArgumentException::class );
24
		AddressChangeId::fromString( $invalidUUID );
25
	}
26
27
	public function invalidUUIDProvider(): \Generator {
28
		yield [ '' ];
29
		yield [ 'just a string' ];
30
		yield [ '1111222233334444-1111222233334444-1111222233334444-1111222233334444-1111222233334444' ];
31
		yield [ 'e-f-f-e-d' ];
32
		yield [ 'This-is-not-a-UUID' ];
33
	}
34
}
35