Passed
Push — master ( 54c197...28c737 )
by wiese
51s
created

SofortPaymentTest::testPersistenceRoundTrip()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 31
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 31
rs 8.8571
cc 1
eloc 18
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 testPersistenceRoundTrip(): 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
		$payment->setConfirmedAt( new DateTime( '2017-07-14T22:00:01Z' ) );
39
		$entityManager->persist( $donation );
40
		$entityManager->flush();
41
42
		/**
43
		 * @var $retrievedPayment SofortPayment
44
		 */
45
		$retrievedPayment = $entityManager->getRepository( SofortPayment::class )
46
			->findOneBy( [] );
47
48
		$this->assertSame( $payment->getId(), $retrievedPayment->getId() );
49
		$this->assertEquals( new DateTime( '2017-07-14T22:00:01Z' ), $retrievedPayment->getConfirmedAt() );
50
	}
51
}
52