Passed
Pull Request — master (#147)
by
unknown
09:57
created

AddressChangeTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 6
dl 0
loc 23
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testWhenNewAddressChangeIsPersisted_uuidIsGeneratedAndStored() 0 11 1
A testWhenAddressIdentifierIsUpdated_dataIsProperlyAssigned() 0 8 1
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Store\Tests;
6
7
use PHPUnit\Framework\TestCase;
8
use WMDE\Fundraising\Entities\AddressChange;
9
10
/**
11
 * @covers WMDE\Fundraising\Entities\AddressChange
12
 */
13
class AddressChangeTest extends TestCase {
14
15
	public function testWhenNewAddressChangeIsPersisted_uuidIsGeneratedAndStored() {
16
		$addressChange = new AddressChange();
17
		$entityManager = TestEnvironment::newDefault()->getFactory()->getEntityManager();
18
		$entityManager->persist( $addressChange );
19
		$entityManager->flush();
20
21
		/** @var AddressChange $retrievedAddressChange */
22
		$retrievedAddressChange = $entityManager->getRepository( AddressChange::class )->findOneBy( [] );
23
24
		$this->assertSame( $addressChange->getCurrentIdentifier(), $retrievedAddressChange->getCurrentIdentifier() );
25
	}
26
27
	public function testWhenAddressIdentifierIsUpdated_dataIsProperlyAssigned() {
28
		$addressChange = new AddressChange();
29
		$initialIdentifier = $addressChange->getCurrentIdentifier();
30
		$addressChange->updateAddressIdentifier();
31
32
		$this->assertSame( $initialIdentifier, $addressChange->getPreviousIdentifier() );
33
		$this->assertNotSame( $initialIdentifier, $addressChange->getCurrentIdentifier() );
34
	}
35
}
36