Passed
Push — master ( e32ade...233249 )
by Jeroen De
03:39
created

SofortPaymentTest::testPersistenceRoundTrip()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
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 PHPUnit\Framework\TestCase;
8
use WMDE\Fundraising\Entities\Donation;
9
use WMDE\Fundraising\Entities\DonationPayments\SofortPayment;
10
11
/**
12
 * @covers \WMDE\Fundraising\Entities\DonationPayments\SofortPayment
13
 *
14
 * @licence GNU GPL v2+
15
 * @author Jeroen De Dauw < [email protected] >
16
 */
17
class SofortPaymentTest extends TestCase {
18
19
	private const BANK_TRANSFER_CODE = 'W-Q-ABCDEZ';
20
21
	public function testPersistenceRoundTrip() {
22
		$donation = new Donation();
23
		$payment = new SofortPayment( self::BANK_TRANSFER_CODE );
24
		$donation->setPayment( $payment );
25
		$entityManager = TestEnvironment::newDefault()->getFactory()->getEntityManager();
26
27
		$entityManager->persist( $donation );
28
		$entityManager->flush();
29
		/**
30
		 * @var $retrievedPayment SofortPayment
31
		 */
32
		$retrievedPayment = $entityManager->getRepository( SofortPayment::class )
33
			->findOneByBankTransferCode( self::BANK_TRANSFER_CODE );
34
35
		$this->assertSame( self::BANK_TRANSFER_CODE, $retrievedPayment->getBankTransferCode() );
36
		$this->assertSame( $payment->getId(), $retrievedPayment->getId() );
37
	}
38
39
}
40