|
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
|
|
|
|