Passed
Push — master ( d2c98a...701a91 )
by wiese
37s
created

testPaymentWithOnlyId_isPersisted()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 9.4285
cc 1
eloc 11
nc 1
nop 0
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace WMDE\Fundraising\Store\Tests;
6
7
use DateTime;
8
use PHPUnit\Framework\TestCase;
9
use WMDE\Fundraising\Entities\Donation;
10
use WMDE\Fundraising\Entities\DonationPayments\SofortPayment;
11
12
/**
13
 * @covers \WMDE\Fundraising\Entities\DonationPayments\SofortPayment
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class SofortPaymentTest extends TestCase {
19
20
	public function testPaymentWithOnlyId_isPersisted(): void {
21
		$donation = new Donation();
22
		$payment = new SofortPayment();
23
		$donation->setPayment( $payment );
24
25
		$entityManager = TestEnvironment::newDefault()->getFactory()->getEntityManager();
26
		$entityManager->persist( $donation );
27
		$entityManager->flush();
28
29
		/**
30
		 * @var $retrievedPayment SofortPayment
31
		 */
32
		$retrievedPayment = $entityManager->getRepository( SofortPayment::class )
33
			->findOneBy( [] );
34
35
		$this->assertSame( $payment->getId(), $retrievedPayment->getId() );
36
		$this->assertNull( $retrievedPayment->getConfirmedAt() );
37
	}
38
39
	public function testPaymentWithIdAndConfirmedAt_isPersisted(): void {
40
		$donation = new Donation();
41
		$payment = new SofortPayment();
42
		$payment->setConfirmedAt( new DateTime( '2017-07-14T22:00:01Z' ) );
43
		$donation->setPayment( $payment );
44
45
		$entityManager = TestEnvironment::newDefault()->getFactory()->getEntityManager();
46
		$entityManager->persist( $donation );
47
		$entityManager->flush();
48
49
		/**
50
		 * @var $retrievedPayment SofortPayment
51
		 */
52
		$retrievedPayment = $entityManager->getRepository( SofortPayment::class )
53
			->findOneBy( [] );
54
55
		$this->assertSame( $payment->getId(), $retrievedPayment->getId() );
56
		$this->assertEquals( new DateTime( '2017-07-14T22:00:01Z' ), $retrievedPayment->getConfirmedAt() );
57
	}
58
}
59