|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare( strict_types = 1 ); |
|
4
|
|
|
|
|
5
|
|
|
namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Unit\Domain\Model; |
|
6
|
|
|
|
|
7
|
|
|
use RuntimeException; |
|
8
|
|
|
use WMDE\Fundraising\Frontend\MembershipContext\Tests\Data\ValidMembershipApplication; |
|
9
|
|
|
|
|
10
|
|
|
/** |
|
11
|
|
|
* @covers \WMDE\Fundraising\Frontend\MembershipContext\Domain\Model\Application |
|
12
|
|
|
* |
|
13
|
|
|
* @license GNU GPL v2+ |
|
14
|
|
|
* @author Jeroen De Dauw < [email protected] > |
|
15
|
|
|
*/ |
|
16
|
|
|
class ApplicationTest extends \PHPUnit\Framework\TestCase { |
|
17
|
|
|
|
|
18
|
|
|
public function testIdIsNullWhenNotAssigned(): void { |
|
19
|
|
|
$this->assertNull( ValidMembershipApplication::newDomainEntity()->getId() ); |
|
20
|
|
|
} |
|
21
|
|
|
|
|
22
|
|
|
public function testCanAssignIdToNewDonation(): void { |
|
23
|
|
|
$donation = ValidMembershipApplication::newDomainEntity(); |
|
24
|
|
|
|
|
25
|
|
|
$donation->assignId( 42 ); |
|
26
|
|
|
$this->assertSame( 42, $donation->getId() ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function testCannotAssignIdToDonationWithIdentity(): void { |
|
30
|
|
|
$donation = ValidMembershipApplication::newDomainEntity(); |
|
31
|
|
|
$donation->assignId( 42 ); |
|
32
|
|
|
|
|
33
|
|
|
$this->expectException( RuntimeException::class ); |
|
34
|
|
|
$donation->assignId( 43 ); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
public function testNewApplicationHasExpectedDefaults(): void { |
|
38
|
|
|
$application = ValidMembershipApplication::newDomainEntity(); |
|
39
|
|
|
|
|
40
|
|
|
$this->assertNull( $application->getId() ); |
|
41
|
|
|
$this->assertFalse( $application->isCancelled() ); |
|
42
|
|
|
$this->assertFalse( $application->needsModeration() ); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
public function testCancellationResultsInCancelledApplication(): void { |
|
46
|
|
|
$application = ValidMembershipApplication::newDomainEntity(); |
|
47
|
|
|
$application->cancel(); |
|
48
|
|
|
|
|
49
|
|
|
$this->assertTrue( $application->isCancelled() ); |
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testMarkForModerationResultsInApplicationThatNeedsModeration(): void { |
|
53
|
|
|
$application = ValidMembershipApplication::newDomainEntity(); |
|
54
|
|
|
$application->markForModeration(); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertTrue( $application->needsModeration() ); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
} |