@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\DonationContext\Tests\Unit\Domain\Model; |
| 6 | 6 | |
@@ -17,15 +17,15 @@ discard block |
||
| 17 | 17 | /** |
| 18 | 18 | * @dataProvider privatePersonProvider |
| 19 | 19 | */ |
| 20 | - public function testGivenPersonName_determineFullNameReturnsFullName( string $expectedValue, array $data ): void { |
|
| 20 | + public function testGivenPersonName_determineFullNameReturnsFullName(string $expectedValue, array $data): void { |
|
| 21 | 21 | $personName = DonorName::newPrivatePersonName(); |
| 22 | 22 | |
| 23 | - $personName->setCompanyName( $data['company'] ); |
|
| 24 | - $personName->setFirstName( $data['firstName'] ); |
|
| 25 | - $personName->setLastName( $data['lastName'] ); |
|
| 26 | - $personName->setTitle( $data['title'] ); |
|
| 23 | + $personName->setCompanyName($data['company']); |
|
| 24 | + $personName->setFirstName($data['firstName']); |
|
| 25 | + $personName->setLastName($data['lastName']); |
|
| 26 | + $personName->setTitle($data['title']); |
|
| 27 | 27 | |
| 28 | - $this->assertSame( $expectedValue, $personName->getFullName() ); |
|
| 28 | + $this->assertSame($expectedValue, $personName->getFullName()); |
|
| 29 | 29 | } |
| 30 | 30 | |
| 31 | 31 | public function privatePersonProvider(): array { |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\DonationContext\Tests\Unit\UseCases\AddDonation; |
| 6 | 6 | |
@@ -30,22 +30,22 @@ discard block |
||
| 30 | 30 | * @param string $expected |
| 31 | 31 | * @param string $url |
| 32 | 32 | */ |
| 33 | - public function testGeneralization( string $url, string $expected ): void { |
|
| 34 | - $generalizer = new ReferrerGeneralizer( 'web', $this->domainMap ); |
|
| 35 | - $this->assertSame( $expected, $generalizer->generalize( $url ) ); |
|
| 33 | + public function testGeneralization(string $url, string $expected): void { |
|
| 34 | + $generalizer = new ReferrerGeneralizer('web', $this->domainMap); |
|
| 35 | + $this->assertSame($expected, $generalizer->generalize($url)); |
|
| 36 | 36 | } |
| 37 | 37 | |
| 38 | 38 | public function urlProvider(): array { |
| 39 | 39 | return [ |
| 40 | - [ 'http://de.wikipedia.org/wiki/Hauptseite', 'de.wikipedia.org' ], |
|
| 41 | - [ 'https://en.wikipedia.org/wiki/Main_Page', 'en.wikipedia.org' ], |
|
| 42 | - [ 'http://www.wikimedia.de/Mitarbeiter', 'wikimedia.de' ], |
|
| 43 | - [ 'https://wikimedia.de/wiki/Hauptseite', 'wikimedia.de' ], |
|
| 44 | - [ 'https://www.wikipedia.de/', 'wikipedia.de' ], |
|
| 45 | - [ 'http://www.wikipedia.de', 'wikipedia.de' ], |
|
| 46 | - [ 'wikipedia.de', 'web' ], |
|
| 47 | - [ 'https://www.google.com/?q=wikimedia+spenden', 'web' ], |
|
| 48 | - [ 'https://ru.wikivoyage.org/wiki/Молдавия', 'ru.wikivoyage.org' ], |
|
| 40 | + ['http://de.wikipedia.org/wiki/Hauptseite', 'de.wikipedia.org'], |
|
| 41 | + ['https://en.wikipedia.org/wiki/Main_Page', 'en.wikipedia.org'], |
|
| 42 | + ['http://www.wikimedia.de/Mitarbeiter', 'wikimedia.de'], |
|
| 43 | + ['https://wikimedia.de/wiki/Hauptseite', 'wikimedia.de'], |
|
| 44 | + ['https://www.wikipedia.de/', 'wikipedia.de'], |
|
| 45 | + ['http://www.wikipedia.de', 'wikipedia.de'], |
|
| 46 | + ['wikipedia.de', 'web'], |
|
| 47 | + ['https://www.google.com/?q=wikimedia+spenden', 'web'], |
|
| 48 | + ['https://ru.wikivoyage.org/wiki/Молдавия', 'ru.wikivoyage.org'], |
|
| 49 | 49 | ]; |
| 50 | 50 | } |
| 51 | 51 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Integration\DataAccess; |
| 6 | 6 | |
@@ -29,32 +29,32 @@ discard block |
||
| 29 | 29 | const MEANINGLESS_APPLICATION_ID = 1337; |
| 30 | 30 | const ID_OF_WRONG_APPLICATION = 42; |
| 31 | 31 | |
| 32 | - private function newAuthorizerWithApplications( string $updateToken = null, |
|
| 33 | - string $accessToken = null, MembershipApplication ...$applications ): ApplicationAuthorizer { |
|
| 32 | + private function newAuthorizerWithApplications(string $updateToken = null, |
|
| 33 | + string $accessToken = null, MembershipApplication ...$applications): ApplicationAuthorizer { |
|
| 34 | 34 | |
| 35 | 35 | $entityManager = TestEnvironment::newInstance()->getFactory()->getEntityManager(); |
| 36 | 36 | |
| 37 | - foreach ( $applications as $application ) { |
|
| 38 | - $entityManager->persist( $application ); |
|
| 37 | + foreach ($applications as $application) { |
|
| 38 | + $entityManager->persist($application); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | $entityManager->flush(); |
| 42 | 42 | |
| 43 | - return new DoctrineApplicationAuthorizer( $entityManager, $updateToken, $accessToken ); |
|
| 43 | + return new DoctrineApplicationAuthorizer($entityManager, $updateToken, $accessToken); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @slowThreshold 400 |
| 48 | 48 | */ |
| 49 | 49 | public function testWhenNoMembershipApplications(): void { |
| 50 | - $this->specify( 'update authorization fails', function() { |
|
| 51 | - $authorizer = $this->newAuthorizerWithApplications( self::CORRECT_UPDATE_TOKEN ); |
|
| 52 | - $this->assertFalse( $authorizer->canModifyApplication( self::MEANINGLESS_APPLICATION_ID ) ); |
|
| 50 | + $this->specify('update authorization fails', function() { |
|
| 51 | + $authorizer = $this->newAuthorizerWithApplications(self::CORRECT_UPDATE_TOKEN); |
|
| 52 | + $this->assertFalse($authorizer->canModifyApplication(self::MEANINGLESS_APPLICATION_ID)); |
|
| 53 | 53 | } ); |
| 54 | 54 | |
| 55 | - $this->specify( 'access authorization fails', function() { |
|
| 56 | - $authorizer = $this->newAuthorizerWithApplications( self::CORRECT_ACCESS_TOKEN ); |
|
| 57 | - $this->assertFalse( $authorizer->canAccessApplication( self::MEANINGLESS_APPLICATION_ID ) ); |
|
| 55 | + $this->specify('access authorization fails', function() { |
|
| 56 | + $authorizer = $this->newAuthorizerWithApplications(self::CORRECT_ACCESS_TOKEN); |
|
| 57 | + $this->assertFalse($authorizer->canAccessApplication(self::MEANINGLESS_APPLICATION_ID)); |
|
| 58 | 58 | } ); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -64,56 +64,56 @@ discard block |
||
| 64 | 64 | public function testWhenApplicationWithTokenExists(): void { |
| 65 | 65 | $application = new MembershipApplication(); |
| 66 | 66 | |
| 67 | - $application->modifyDataObject( function( MembershipApplicationData $data ) { |
|
| 68 | - $data->setUpdateToken( self::CORRECT_UPDATE_TOKEN ); |
|
| 69 | - $data->setAccessToken( self::CORRECT_ACCESS_TOKEN ); |
|
| 67 | + $application->modifyDataObject(function(MembershipApplicationData $data) { |
|
| 68 | + $data->setUpdateToken(self::CORRECT_UPDATE_TOKEN); |
|
| 69 | + $data->setAccessToken(self::CORRECT_ACCESS_TOKEN); |
|
| 70 | 70 | } ); |
| 71 | 71 | |
| 72 | 72 | $this->specify( |
| 73 | 73 | 'given correct application id and correct token, update authorization succeeds', |
| 74 | - function() use ( $application ) { |
|
| 75 | - $authorizer = $this->newAuthorizerWithApplications( self::CORRECT_UPDATE_TOKEN, null, $application ); |
|
| 76 | - $this->assertTrue( $authorizer->canModifyApplication( $application->getId() ) ); |
|
| 74 | + function() use ($application) { |
|
| 75 | + $authorizer = $this->newAuthorizerWithApplications(self::CORRECT_UPDATE_TOKEN, null, $application); |
|
| 76 | + $this->assertTrue($authorizer->canModifyApplication($application->getId())); |
|
| 77 | 77 | } |
| 78 | 78 | ); |
| 79 | 79 | |
| 80 | 80 | $this->specify( |
| 81 | 81 | 'given wrong application id and correct token, update authorization fails', |
| 82 | - function() use ( $application ) { |
|
| 83 | - $authorizer = $this->newAuthorizerWithApplications( self::CORRECT_UPDATE_TOKEN, null, $application ); |
|
| 84 | - $this->assertFalse( $authorizer->canModifyApplication( self::ID_OF_WRONG_APPLICATION ) ); |
|
| 82 | + function() use ($application) { |
|
| 83 | + $authorizer = $this->newAuthorizerWithApplications(self::CORRECT_UPDATE_TOKEN, null, $application); |
|
| 84 | + $this->assertFalse($authorizer->canModifyApplication(self::ID_OF_WRONG_APPLICATION)); |
|
| 85 | 85 | } |
| 86 | 86 | ); |
| 87 | 87 | |
| 88 | 88 | $this->specify( |
| 89 | 89 | 'given correct application id and wrong token, update authorization fails', |
| 90 | - function() use ( $application ) { |
|
| 91 | - $authorizer = $this->newAuthorizerWithApplications( self::WRONG__UPDATE_TOKEN, null, $application ); |
|
| 92 | - $this->assertFalse( $authorizer->canModifyApplication( $application->getId() ) ); |
|
| 90 | + function() use ($application) { |
|
| 91 | + $authorizer = $this->newAuthorizerWithApplications(self::WRONG__UPDATE_TOKEN, null, $application); |
|
| 92 | + $this->assertFalse($authorizer->canModifyApplication($application->getId())); |
|
| 93 | 93 | } |
| 94 | 94 | ); |
| 95 | 95 | |
| 96 | 96 | $this->specify( |
| 97 | 97 | 'given correct application id and correct token, access authorization succeeds', |
| 98 | - function() use ( $application ) { |
|
| 99 | - $authorizer = $this->newAuthorizerWithApplications( null, self::CORRECT_ACCESS_TOKEN, $application ); |
|
| 100 | - $this->assertTrue( $authorizer->canAccessApplication( $application->getId() ) ); |
|
| 98 | + function() use ($application) { |
|
| 99 | + $authorizer = $this->newAuthorizerWithApplications(null, self::CORRECT_ACCESS_TOKEN, $application); |
|
| 100 | + $this->assertTrue($authorizer->canAccessApplication($application->getId())); |
|
| 101 | 101 | } |
| 102 | 102 | ); |
| 103 | 103 | |
| 104 | 104 | $this->specify( |
| 105 | 105 | 'given wrong application id and correct token, access authorization fails', |
| 106 | - function() use ( $application ) { |
|
| 107 | - $authorizer = $this->newAuthorizerWithApplications( null, self::CORRECT_ACCESS_TOKEN, $application ); |
|
| 108 | - $this->assertFalse( $authorizer->canAccessApplication( self::ID_OF_WRONG_APPLICATION ) ); |
|
| 106 | + function() use ($application) { |
|
| 107 | + $authorizer = $this->newAuthorizerWithApplications(null, self::CORRECT_ACCESS_TOKEN, $application); |
|
| 108 | + $this->assertFalse($authorizer->canAccessApplication(self::ID_OF_WRONG_APPLICATION)); |
|
| 109 | 109 | } |
| 110 | 110 | ); |
| 111 | 111 | |
| 112 | 112 | $this->specify( |
| 113 | 113 | 'given correct application id and wrong token, access authorization fails', |
| 114 | - function() use ( $application ) { |
|
| 115 | - $authorizer = $this->newAuthorizerWithApplications( null, self::WRONG_ACCESS_TOKEN, $application ); |
|
| 116 | - $this->assertFalse( $authorizer->canAccessApplication( $application->getId() ) ); |
|
| 114 | + function() use ($application) { |
|
| 115 | + $authorizer = $this->newAuthorizerWithApplications(null, self::WRONG_ACCESS_TOKEN, $application); |
|
| 116 | + $this->assertFalse($authorizer->canAccessApplication($application->getId())); |
|
| 117 | 117 | } |
| 118 | 118 | ); |
| 119 | 119 | } |
@@ -126,17 +126,17 @@ discard block |
||
| 126 | 126 | |
| 127 | 127 | $this->specify( |
| 128 | 128 | 'given correct application id and a token, update authorization fails', |
| 129 | - function() use ( $application ) { |
|
| 130 | - $authorizer = $this->newAuthorizerWithApplications( 'SomeToken', null, $application ); |
|
| 131 | - $this->assertFalse( $authorizer->canModifyApplication( $application->getId() ) ); |
|
| 129 | + function() use ($application) { |
|
| 130 | + $authorizer = $this->newAuthorizerWithApplications('SomeToken', null, $application); |
|
| 131 | + $this->assertFalse($authorizer->canModifyApplication($application->getId())); |
|
| 132 | 132 | } |
| 133 | 133 | ); |
| 134 | 134 | |
| 135 | 135 | $this->specify( |
| 136 | 136 | 'given correct application id and a token, access authorization fails', |
| 137 | - function() use ( $application ) { |
|
| 138 | - $authorizer = $this->newAuthorizerWithApplications( null, 'SomeToken', $application ); |
|
| 139 | - $this->assertFalse( $authorizer->canAccessApplication( $application->getId() ) ); |
|
| 137 | + function() use ($application) { |
|
| 138 | + $authorizer = $this->newAuthorizerWithApplications(null, 'SomeToken', $application); |
|
| 139 | + $this->assertFalse($authorizer->canAccessApplication($application->getId())); |
|
| 140 | 140 | } |
| 141 | 141 | ); |
| 142 | 142 | } |
@@ -151,21 +151,21 @@ discard block |
||
| 151 | 151 | self::CORRECT_ACCESS_TOKEN |
| 152 | 152 | ); |
| 153 | 153 | |
| 154 | - $this->specify( 'update authorization fails', function() use ( $authorizer ) { |
|
| 155 | - $this->assertFalse( $authorizer->canModifyApplication( self::MEANINGLESS_APPLICATION_ID ) ); |
|
| 154 | + $this->specify('update authorization fails', function() use ($authorizer) { |
|
| 155 | + $this->assertFalse($authorizer->canModifyApplication(self::MEANINGLESS_APPLICATION_ID)); |
|
| 156 | 156 | } ); |
| 157 | 157 | |
| 158 | - $this->specify( 'access authorization fails', function() use ( $authorizer ) { |
|
| 159 | - $this->assertFalse( $authorizer->canAccessApplication( self::MEANINGLESS_APPLICATION_ID ) ); |
|
| 158 | + $this->specify('access authorization fails', function() use ($authorizer) { |
|
| 159 | + $this->assertFalse($authorizer->canAccessApplication(self::MEANINGLESS_APPLICATION_ID)); |
|
| 160 | 160 | } ); |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | 163 | private function getThrowingEntityManager(): EntityManager { |
| 164 | - $entityManager = $this->getMockBuilder( EntityManager::class ) |
|
| 164 | + $entityManager = $this->getMockBuilder(EntityManager::class) |
|
| 165 | 165 | ->disableOriginalConstructor()->getMock(); |
| 166 | 166 | |
| 167 | - $entityManager->method( $this->anything() ) |
|
| 168 | - ->willThrowException( new ORMException() ); |
|
| 167 | + $entityManager->method($this->anything()) |
|
| 168 | + ->willThrowException(new ORMException()); |
|
| 169 | 169 | |
| 170 | 170 | return $entityManager; |
| 171 | 171 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Integration\DataAccess; |
| 6 | 6 | |
@@ -32,45 +32,45 @@ discard block |
||
| 32 | 32 | /** |
| 33 | 33 | * @dataProvider validTrackingDataProvider |
| 34 | 34 | */ |
| 35 | - public function testValidTrackingDataIsProperlyApplied( string $campaignCode, string $keyword ): void { |
|
| 35 | + public function testValidTrackingDataIsProperlyApplied(string $campaignCode, string $keyword): void { |
|
| 36 | 36 | $application = ValidMembershipApplication::newDoctrineEntity(); |
| 37 | - $this->persistApplication( $application ); |
|
| 37 | + $this->persistApplication($application); |
|
| 38 | 38 | |
| 39 | 39 | $this->newMembershipApplicationTracker()->trackApplication( |
| 40 | 40 | $application->getId(), |
| 41 | - $this->newMembershipApplicationTrackingInfo( $campaignCode, $keyword ) |
|
| 41 | + $this->newMembershipApplicationTrackingInfo($campaignCode, $keyword) |
|
| 42 | 42 | ); |
| 43 | 43 | |
| 44 | - $storedApplication = $this->getApplicationById( $application->getId() ); |
|
| 44 | + $storedApplication = $this->getApplicationById($application->getId()); |
|
| 45 | 45 | |
| 46 | - $this->assertSame( $keyword, $storedApplication->getDecodedData()['confirmationPage'] ); |
|
| 47 | - $this->assertSame( $campaignCode, $storedApplication->getDecodedData()['confirmationPageCampaign'] ); |
|
| 46 | + $this->assertSame($keyword, $storedApplication->getDecodedData()['confirmationPage']); |
|
| 47 | + $this->assertSame($campaignCode, $storedApplication->getDecodedData()['confirmationPageCampaign']); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | public function validTrackingDataProvider(): array { |
| 51 | 51 | return [ |
| 52 | - [ 'campaignCode', 'keyword' ], |
|
| 53 | - [ '', 'keyword', 'keyword' ], |
|
| 54 | - [ 'campaignCode', '' ], |
|
| 55 | - [ '', '' ], |
|
| 52 | + ['campaignCode', 'keyword'], |
|
| 53 | + ['', 'keyword', 'keyword'], |
|
| 54 | + ['campaignCode', ''], |
|
| 55 | + ['', ''], |
|
| 56 | 56 | ]; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - private function persistApplication( MembershipApplication $application ): void { |
|
| 60 | - $this->entityManager->persist( $application ); |
|
| 59 | + private function persistApplication(MembershipApplication $application): void { |
|
| 60 | + $this->entityManager->persist($application); |
|
| 61 | 61 | $this->entityManager->flush(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - private function getApplicationById( int $applicationId ): MembershipApplication { |
|
| 65 | - return $this->entityManager->find( MembershipApplication::class, $applicationId ); |
|
| 64 | + private function getApplicationById(int $applicationId): MembershipApplication { |
|
| 65 | + return $this->entityManager->find(MembershipApplication::class, $applicationId); |
|
| 66 | 66 | } |
| 67 | 67 | |
| 68 | 68 | private function newMembershipApplicationTracker(): ApplicationTracker { |
| 69 | - return new DoctrineApplicationTracker( $this->entityManager ); |
|
| 69 | + return new DoctrineApplicationTracker($this->entityManager); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - private function newMembershipApplicationTrackingInfo( string $campaignCode, string $keyword ): MembershipApplicationTrackingInfo { |
|
| 73 | - return new MembershipApplicationTrackingInfo( $campaignCode, $keyword ); |
|
| 72 | + private function newMembershipApplicationTrackingInfo(string $campaignCode, string $keyword): MembershipApplicationTrackingInfo { |
|
| 73 | + return new MembershipApplicationTrackingInfo($campaignCode, $keyword); |
|
| 74 | 74 | } |
| 75 | 75 | |
| 76 | 76 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Integration\DataAccess; |
| 6 | 6 | |
@@ -39,141 +39,141 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function testValidMembershipApplicationGetPersisted(): void { |
| 42 | - $this->newRepository()->storeApplication( ValidMembershipApplication::newDomainEntity() ); |
|
| 42 | + $this->newRepository()->storeApplication(ValidMembershipApplication::newDomainEntity()); |
|
| 43 | 43 | |
| 44 | 44 | $expectedDoctrineEntity = ValidMembershipApplication::newDoctrineEntity(); |
| 45 | - $expectedDoctrineEntity->setId( self::MEMBERSHIP_APPLICATION_ID ); |
|
| 45 | + $expectedDoctrineEntity->setId(self::MEMBERSHIP_APPLICATION_ID); |
|
| 46 | 46 | |
| 47 | - $this->assertDoctrineEntityIsInDatabase( $expectedDoctrineEntity ); |
|
| 47 | + $this->assertDoctrineEntityIsInDatabase($expectedDoctrineEntity); |
|
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | private function newRepository(): ApplicationRepository { |
| 51 | - return new DoctrineApplicationRepository( $this->entityManager ); |
|
| 51 | + return new DoctrineApplicationRepository($this->entityManager); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | - private function assertDoctrineEntityIsInDatabase( DoctrineApplication $expected ): void { |
|
| 55 | - $actual = $this->getApplicationFromDatabase( $expected->getId() ); |
|
| 54 | + private function assertDoctrineEntityIsInDatabase(DoctrineApplication $expected): void { |
|
| 55 | + $actual = $this->getApplicationFromDatabase($expected->getId()); |
|
| 56 | 56 | |
| 57 | - $this->assertNotNull( $actual->getCreationTime() ); |
|
| 58 | - $actual->setCreationTime( null ); |
|
| 57 | + $this->assertNotNull($actual->getCreationTime()); |
|
| 58 | + $actual->setCreationTime(null); |
|
| 59 | 59 | |
| 60 | - $this->assertEquals( $expected->getDecodedData(), $actual->getDecodedData() ); |
|
| 60 | + $this->assertEquals($expected->getDecodedData(), $actual->getDecodedData()); |
|
| 61 | 61 | |
| 62 | - $this->assertEquals( $expected, $actual ); |
|
| 62 | + $this->assertEquals($expected, $actual); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - private function getApplicationFromDatabase( int $id ): DoctrineApplication { |
|
| 66 | - $applicationRepo = $this->entityManager->getRepository( DoctrineApplication::class ); |
|
| 67 | - $donation = $applicationRepo->find( $id ); |
|
| 68 | - $this->assertInstanceOf( DoctrineApplication::class, $donation ); |
|
| 65 | + private function getApplicationFromDatabase(int $id): DoctrineApplication { |
|
| 66 | + $applicationRepo = $this->entityManager->getRepository(DoctrineApplication::class); |
|
| 67 | + $donation = $applicationRepo->find($id); |
|
| 68 | + $this->assertInstanceOf(DoctrineApplication::class, $donation); |
|
| 69 | 69 | return $donation; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | 72 | public function testIdGetsAssigned(): void { |
| 73 | 73 | $application = ValidMembershipApplication::newDomainEntity(); |
| 74 | 74 | |
| 75 | - $this->newRepository()->storeApplication( $application ); |
|
| 75 | + $this->newRepository()->storeApplication($application); |
|
| 76 | 76 | |
| 77 | - $this->assertSame( self::MEMBERSHIP_APPLICATION_ID, $application->getId() ); |
|
| 77 | + $this->assertSame(self::MEMBERSHIP_APPLICATION_ID, $application->getId()); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function testWhenPersistenceFails_domainExceptionIsThrown(): void { |
| 81 | 81 | $donation = ValidMembershipApplication::newDomainEntity(); |
| 82 | 82 | |
| 83 | - $repository = new DoctrineApplicationRepository( ThrowingEntityManager::newInstance( $this ) ); |
|
| 83 | + $repository = new DoctrineApplicationRepository(ThrowingEntityManager::newInstance($this)); |
|
| 84 | 84 | |
| 85 | - $this->expectException( StoreMembershipApplicationException::class ); |
|
| 86 | - $repository->storeApplication( $donation ); |
|
| 85 | + $this->expectException(StoreMembershipApplicationException::class); |
|
| 86 | + $repository->storeApplication($donation); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | public function testWhenMembershipApplicationInDatabase_itIsReturnedAsMatchingDomainEntity(): void { |
| 90 | - $this->storeDoctrineApplication( ValidMembershipApplication::newDoctrineEntity() ); |
|
| 90 | + $this->storeDoctrineApplication(ValidMembershipApplication::newDoctrineEntity()); |
|
| 91 | 91 | |
| 92 | 92 | $expected = ValidMembershipApplication::newAutoConfirmedDomainEntity(); |
| 93 | - $expected->assignId( self::MEMBERSHIP_APPLICATION_ID ); |
|
| 93 | + $expected->assignId(self::MEMBERSHIP_APPLICATION_ID); |
|
| 94 | 94 | |
| 95 | 95 | $this->assertEquals( |
| 96 | 96 | $expected, |
| 97 | - $this->newRepository()->getApplicationById( self::MEMBERSHIP_APPLICATION_ID ) |
|
| 97 | + $this->newRepository()->getApplicationById(self::MEMBERSHIP_APPLICATION_ID) |
|
| 98 | 98 | ); |
| 99 | 99 | } |
| 100 | 100 | |
| 101 | - private function storeDoctrineApplication( DoctrineApplication $application ): void { |
|
| 102 | - $this->entityManager->persist( $application ); |
|
| 101 | + private function storeDoctrineApplication(DoctrineApplication $application): void { |
|
| 102 | + $this->entityManager->persist($application); |
|
| 103 | 103 | $this->entityManager->flush(); |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function testWhenEntityDoesNotExist_getEntityReturnsNull(): void { |
| 107 | - $this->assertNull( $this->newRepository()->getApplicationById( self::ID_OF_APPLICATION_NOT_IN_DB ) ); |
|
| 107 | + $this->assertNull($this->newRepository()->getApplicationById(self::ID_OF_APPLICATION_NOT_IN_DB)); |
|
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | public function testWhenReadFails_domainExceptionIsThrown(): void { |
| 111 | - $repository = new DoctrineApplicationRepository( ThrowingEntityManager::newInstance( $this ) ); |
|
| 111 | + $repository = new DoctrineApplicationRepository(ThrowingEntityManager::newInstance($this)); |
|
| 112 | 112 | |
| 113 | - $this->expectException( GetMembershipApplicationException::class ); |
|
| 114 | - $repository->getApplicationById( self::ID_OF_APPLICATION_NOT_IN_DB ); |
|
| 113 | + $this->expectException(GetMembershipApplicationException::class); |
|
| 114 | + $repository->getApplicationById(self::ID_OF_APPLICATION_NOT_IN_DB); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | public function testWhenApplicationAlreadyExists_persistingCausesUpdate(): void { |
| 118 | 118 | $repository = $this->newRepository(); |
| 119 | 119 | $originalApplication = ValidMembershipApplication::newDomainEntity(); |
| 120 | 120 | |
| 121 | - $repository->storeApplication( $originalApplication ); |
|
| 121 | + $repository->storeApplication($originalApplication); |
|
| 122 | 122 | |
| 123 | 123 | // It is important a new instance is created here to test "detached entity" handling |
| 124 | 124 | $newApplication = ValidMembershipApplication::newDomainEntity(); |
| 125 | - $newApplication->assignId( $originalApplication->getId() ); |
|
| 126 | - $newApplication->getApplicant()->changeEmailAddress( new EmailAddress( '[email protected]' ) ); |
|
| 125 | + $newApplication->assignId($originalApplication->getId()); |
|
| 126 | + $newApplication->getApplicant()->changeEmailAddress(new EmailAddress('[email protected]')); |
|
| 127 | 127 | |
| 128 | - $repository->storeApplication( $newApplication ); |
|
| 128 | + $repository->storeApplication($newApplication); |
|
| 129 | 129 | |
| 130 | - $doctrineApplication = $this->getApplicationFromDatabase( $newApplication->getId() ); |
|
| 130 | + $doctrineApplication = $this->getApplicationFromDatabase($newApplication->getId()); |
|
| 131 | 131 | |
| 132 | - $this->assertSame( '[email protected]', $doctrineApplication->getApplicantEmailAddress() ); |
|
| 132 | + $this->assertSame('[email protected]', $doctrineApplication->getApplicantEmailAddress()); |
|
| 133 | 133 | } |
| 134 | 134 | |
| 135 | 135 | public function testWriteAndReadRoundtrip(): void { |
| 136 | 136 | $repository = $this->newRepository(); |
| 137 | 137 | $application = ValidMembershipApplication::newAutoConfirmedDomainEntity(); |
| 138 | 138 | |
| 139 | - $repository->storeApplication( $application ); |
|
| 139 | + $repository->storeApplication($application); |
|
| 140 | 140 | |
| 141 | 141 | $this->assertEquals( |
| 142 | 142 | $application, |
| 143 | - $repository->getApplicationById( self::MEMBERSHIP_APPLICATION_ID ) |
|
| 143 | + $repository->getApplicationById(self::MEMBERSHIP_APPLICATION_ID) |
|
| 144 | 144 | ); |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | public function testWhenPersistingDeletedApplication_exceptionIsThrown(): void { |
| 148 | 148 | $application = ValidMembershipApplication::newDomainEntity(); |
| 149 | - $application->assignId( self::ID_OF_APPLICATION_NOT_IN_DB ); |
|
| 149 | + $application->assignId(self::ID_OF_APPLICATION_NOT_IN_DB); |
|
| 150 | 150 | |
| 151 | 151 | $repository = $this->newRepository(); |
| 152 | 152 | |
| 153 | - $this->expectException( StoreMembershipApplicationException::class ); |
|
| 154 | - $repository->storeApplication( $application ); |
|
| 153 | + $this->expectException(StoreMembershipApplicationException::class); |
|
| 154 | + $repository->storeApplication($application); |
|
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | public function testWhenPersistingApplicationWithModerationFlag_doctrineApplicationHasFlag(): void { |
| 158 | 158 | $application = ValidMembershipApplication::newDomainEntity(); |
| 159 | 159 | $application->markForModeration(); |
| 160 | 160 | |
| 161 | - $this->newRepository()->storeApplication( $application ); |
|
| 162 | - $doctrineApplication = $this->getApplicationFromDatabase( $application->getId() ); |
|
| 161 | + $this->newRepository()->storeApplication($application); |
|
| 162 | + $doctrineApplication = $this->getApplicationFromDatabase($application->getId()); |
|
| 163 | 163 | |
| 164 | - $this->assertTrue( $doctrineApplication->needsModeration() ); |
|
| 165 | - $this->assertFalse( $doctrineApplication->isCancelled() ); |
|
| 164 | + $this->assertTrue($doctrineApplication->needsModeration()); |
|
| 165 | + $this->assertFalse($doctrineApplication->isCancelled()); |
|
| 166 | 166 | } |
| 167 | 167 | |
| 168 | 168 | public function testWhenPersistingApplicationWithCancelledFlag_doctrineApplicationHasFlag(): void { |
| 169 | 169 | $application = ValidMembershipApplication::newDomainEntity(); |
| 170 | 170 | $application->cancel(); |
| 171 | 171 | |
| 172 | - $this->newRepository()->storeApplication( $application ); |
|
| 173 | - $doctrineApplication = $this->getApplicationFromDatabase( $application->getId() ); |
|
| 172 | + $this->newRepository()->storeApplication($application); |
|
| 173 | + $doctrineApplication = $this->getApplicationFromDatabase($application->getId()); |
|
| 174 | 174 | |
| 175 | - $this->assertFalse( $doctrineApplication->needsModeration() ); |
|
| 176 | - $this->assertTrue( $doctrineApplication->isCancelled() ); |
|
| 175 | + $this->assertFalse($doctrineApplication->needsModeration()); |
|
| 176 | + $this->assertTrue($doctrineApplication->isCancelled()); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | public function testWhenPersistingCancelledModerationApplication_doctrineApplicationHasFlags(): void { |
@@ -181,63 +181,63 @@ discard block |
||
| 181 | 181 | $application->markForModeration(); |
| 182 | 182 | $application->cancel(); |
| 183 | 183 | |
| 184 | - $this->newRepository()->storeApplication( $application ); |
|
| 185 | - $doctrineApplication = $this->getApplicationFromDatabase( $application->getId() ); |
|
| 184 | + $this->newRepository()->storeApplication($application); |
|
| 185 | + $doctrineApplication = $this->getApplicationFromDatabase($application->getId()); |
|
| 186 | 186 | |
| 187 | - $this->assertTrue( $doctrineApplication->needsModeration() ); |
|
| 188 | - $this->assertTrue( $doctrineApplication->isCancelled() ); |
|
| 187 | + $this->assertTrue($doctrineApplication->needsModeration()); |
|
| 188 | + $this->assertTrue($doctrineApplication->isCancelled()); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | public function testGivenDoctrineApplicationWithModerationAndCancelled_domainEntityHasFlags(): void { |
| 192 | 192 | $doctrineApplication = ValidMembershipApplication::newDoctrineEntity(); |
| 193 | - $doctrineApplication->setStatus( DoctrineApplication::STATUS_CANCELED + DoctrineApplication::STATUS_MODERATION ); |
|
| 193 | + $doctrineApplication->setStatus(DoctrineApplication::STATUS_CANCELED + DoctrineApplication::STATUS_MODERATION); |
|
| 194 | 194 | |
| 195 | - $this->storeDoctrineApplication( $doctrineApplication ); |
|
| 196 | - $application = $this->newRepository()->getApplicationById( $doctrineApplication->getId() ); |
|
| 195 | + $this->storeDoctrineApplication($doctrineApplication); |
|
| 196 | + $application = $this->newRepository()->getApplicationById($doctrineApplication->getId()); |
|
| 197 | 197 | |
| 198 | - $this->assertTrue( $application->needsModeration() ); |
|
| 199 | - $this->assertTrue( $application->isCancelled() ); |
|
| 198 | + $this->assertTrue($application->needsModeration()); |
|
| 199 | + $this->assertTrue($application->isCancelled()); |
|
| 200 | 200 | } |
| 201 | 201 | |
| 202 | 202 | public function testGivenDoctrineApplicationWithModerationFlag_domainEntityHasFlag(): void { |
| 203 | 203 | $doctrineApplication = ValidMembershipApplication::newDoctrineEntity(); |
| 204 | - $doctrineApplication->setStatus( DoctrineApplication::STATUS_MODERATION ); |
|
| 204 | + $doctrineApplication->setStatus(DoctrineApplication::STATUS_MODERATION); |
|
| 205 | 205 | |
| 206 | - $this->storeDoctrineApplication( $doctrineApplication ); |
|
| 207 | - $application = $this->newRepository()->getApplicationById( $doctrineApplication->getId() ); |
|
| 206 | + $this->storeDoctrineApplication($doctrineApplication); |
|
| 207 | + $application = $this->newRepository()->getApplicationById($doctrineApplication->getId()); |
|
| 208 | 208 | |
| 209 | - $this->assertTrue( $application->needsModeration() ); |
|
| 210 | - $this->assertFalse( $application->isCancelled() ); |
|
| 209 | + $this->assertTrue($application->needsModeration()); |
|
| 210 | + $this->assertFalse($application->isCancelled()); |
|
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | public function testGivenDoctrineApplicationWithCancelledFlag_domainEntityHasFlag(): void { |
| 214 | 214 | $doctrineApplication = ValidMembershipApplication::newDoctrineEntity(); |
| 215 | - $doctrineApplication->setStatus( DoctrineApplication::STATUS_CANCELED ); |
|
| 215 | + $doctrineApplication->setStatus(DoctrineApplication::STATUS_CANCELED); |
|
| 216 | 216 | |
| 217 | - $this->storeDoctrineApplication( $doctrineApplication ); |
|
| 218 | - $application = $this->newRepository()->getApplicationById( $doctrineApplication->getId() ); |
|
| 217 | + $this->storeDoctrineApplication($doctrineApplication); |
|
| 218 | + $application = $this->newRepository()->getApplicationById($doctrineApplication->getId()); |
|
| 219 | 219 | |
| 220 | - $this->assertFalse( $application->needsModeration() ); |
|
| 221 | - $this->assertTrue( $application->isCancelled() ); |
|
| 220 | + $this->assertFalse($application->needsModeration()); |
|
| 221 | + $this->assertTrue($application->isCancelled()); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | public function testGivenDoctrineApplicationWithCancelledFlag_initialStatusIsPreserved(): void { |
| 225 | 225 | $application = ValidMembershipApplication::newDomainEntity(); |
| 226 | 226 | $application->cancel(); |
| 227 | 227 | |
| 228 | - $this->newRepository()->storeApplication( $application ); |
|
| 229 | - $doctrineApplication = $this->getApplicationFromDatabase( $application->getId() ); |
|
| 228 | + $this->newRepository()->storeApplication($application); |
|
| 229 | + $doctrineApplication = $this->getApplicationFromDatabase($application->getId()); |
|
| 230 | 230 | |
| 231 | - $this->assertSame( DoctrineApplication::STATUS_CONFIRMED, $doctrineApplication->getDataObject()->getPreservedStatus() ); |
|
| 231 | + $this->assertSame(DoctrineApplication::STATUS_CONFIRMED, $doctrineApplication->getDataObject()->getPreservedStatus()); |
|
| 232 | 232 | } |
| 233 | 233 | |
| 234 | 234 | public function testGivenCompanyApplication_companyNameIsPersisted(): void { |
| 235 | - $this->newRepository()->storeApplication( ValidMembershipApplication::newCompanyApplication() ); |
|
| 235 | + $this->newRepository()->storeApplication(ValidMembershipApplication::newCompanyApplication()); |
|
| 236 | 236 | |
| 237 | 237 | $expectedDoctrineEntity = ValidMembershipApplication::newDoctrineCompanyEntity(); |
| 238 | - $expectedDoctrineEntity->setId( self::MEMBERSHIP_APPLICATION_ID ); |
|
| 238 | + $expectedDoctrineEntity->setId(self::MEMBERSHIP_APPLICATION_ID); |
|
| 239 | 239 | |
| 240 | - $this->assertDoctrineEntityIsInDatabase( $expectedDoctrineEntity ); |
|
| 240 | + $this->assertDoctrineEntityIsInDatabase($expectedDoctrineEntity); |
|
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Integration\UseCases\HandleSubscriptionPaymentNotification; |
| 6 | 6 | |
@@ -27,20 +27,20 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | public function testWhenRepositoryThrowsException_requestIsNotHandled(): void { |
| 29 | 29 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 30 | - new DoctrineApplicationRepository( ThrowingEntityManager::newInstance( $this ) ), |
|
| 30 | + new DoctrineApplicationRepository(ThrowingEntityManager::newInstance($this)), |
|
| 31 | 31 | new SucceedingAuthorizer(), |
| 32 | 32 | $this->getMailer(), |
| 33 | 33 | new NullLogger() |
| 34 | 34 | ); |
| 35 | - $request = ValidPayPalNotificationRequest::newInstantPayment( 1 ); |
|
| 36 | - $response = $useCase->handleNotification( $request ); |
|
| 37 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 38 | - $this->assertTrue( $response->hasErrors() ); |
|
| 35 | + $request = ValidPayPalNotificationRequest::newInstantPayment(1); |
|
| 36 | + $response = $useCase->handleNotification($request); |
|
| 37 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 38 | + $this->assertTrue($response->hasErrors()); |
|
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function testWhenApplicationDoesNotExist_requestIsNotHandled(): void { |
| 42 | 42 | $fakeRepository = new FakeApplicationRepository(); |
| 43 | - $fakeRepository->storeApplication( ValidMembershipApplication::newDomainEntityUsingPayPal() ); |
|
| 43 | + $fakeRepository->storeApplication(ValidMembershipApplication::newDomainEntityUsingPayPal()); |
|
| 44 | 44 | |
| 45 | 45 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 46 | 46 | $fakeRepository, |
@@ -49,14 +49,14 @@ discard block |
||
| 49 | 49 | new NullLogger() |
| 50 | 50 | ); |
| 51 | 51 | |
| 52 | - $request = ValidPayPalNotificationRequest::newInstantPayment( 667 ); |
|
| 53 | - $response = $useCase->handleNotification( $request ); |
|
| 54 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 52 | + $request = ValidPayPalNotificationRequest::newInstantPayment(667); |
|
| 53 | + $response = $useCase->handleNotification($request); |
|
| 54 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function testWhenAuthorizationFails_requestIsNotHandled(): void { |
| 58 | 58 | $fakeRepository = new FakeApplicationRepository(); |
| 59 | - $fakeRepository->storeApplication( ValidMembershipApplication::newDomainEntityUsingPayPal() ); |
|
| 59 | + $fakeRepository->storeApplication(ValidMembershipApplication::newDomainEntityUsingPayPal()); |
|
| 60 | 60 | |
| 61 | 61 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 62 | 62 | $fakeRepository, |
@@ -65,9 +65,9 @@ discard block |
||
| 65 | 65 | new NullLogger() |
| 66 | 66 | ); |
| 67 | 67 | |
| 68 | - $request = ValidPayPalNotificationRequest::newInstantPayment( 1 ); |
|
| 69 | - $response = $useCase->handleNotification( $request ); |
|
| 70 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 68 | + $request = ValidPayPalNotificationRequest::newInstantPayment(1); |
|
| 69 | + $response = $useCase->handleNotification($request); |
|
| 70 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | 73 | public function testWhenTransactionTypeIsForSubscriptionChanges_requestIsNotHandled(): void { |
@@ -79,17 +79,17 @@ discard block |
||
| 79 | 79 | $this->getMailer(), |
| 80 | 80 | new NullLogger() |
| 81 | 81 | ); |
| 82 | - $response = $useCase->handleNotification( $request ); |
|
| 83 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 82 | + $response = $useCase->handleNotification($request); |
|
| 83 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 84 | 84 | } |
| 85 | 85 | |
| 86 | 86 | public function testGivenSubscriptionPaymentRequest_childDataSetIsCreated(): void { |
| 87 | 87 | $application = ValidMembershipApplication::newConfirmedSubscriptionDomainEntity(); |
| 88 | 88 | |
| 89 | 89 | $fakeRepository = new FakeApplicationRepository(); |
| 90 | - $fakeRepository->storeApplication( $application ); |
|
| 90 | + $fakeRepository->storeApplication($application); |
|
| 91 | 91 | |
| 92 | - $request = ValidPayPalNotificationRequest::newRecurringPayment( $application->getId() ); |
|
| 92 | + $request = ValidPayPalNotificationRequest::newRecurringPayment($application->getId()); |
|
| 93 | 93 | |
| 94 | 94 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 95 | 95 | $fakeRepository, |
@@ -98,34 +98,34 @@ discard block |
||
| 98 | 98 | new NullLogger() |
| 99 | 99 | ); |
| 100 | 100 | |
| 101 | - $response = $useCase->handleNotification( $request ); |
|
| 102 | - $this->assertTrue( $response->notificationWasHandled() ); |
|
| 103 | - $this->assertFalse( $response->hasErrors() ); |
|
| 101 | + $response = $useCase->handleNotification($request); |
|
| 102 | + $this->assertTrue($response->notificationWasHandled()); |
|
| 103 | + $this->assertFalse($response->hasErrors()); |
|
| 104 | 104 | |
| 105 | - $application = $fakeRepository->getApplicationById( $application->getId() ); |
|
| 105 | + $application = $fakeRepository->getApplicationById($application->getId()); |
|
| 106 | 106 | /** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $payment */ |
| 107 | 107 | $payment = $application->getPayment()->getPaymentMethod(); |
| 108 | - $childApplication = $fakeRepository->getApplicationById( $payment->getPayPalData()->getChildPaymentEntityId( ValidPayPalNotificationRequest::TRANSACTION_ID ) ); |
|
| 109 | - $this->assertNotNull( $childApplication ); |
|
| 108 | + $childApplication = $fakeRepository->getApplicationById($payment->getPayPalData()->getChildPaymentEntityId(ValidPayPalNotificationRequest::TRANSACTION_ID)); |
|
| 109 | + $this->assertNotNull($childApplication); |
|
| 110 | 110 | /** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $childPayment */ |
| 111 | 111 | $childPayment = $childApplication->getPayment()->getPaymentMethod(); |
| 112 | - $this->assertEquals( ValidPayPalNotificationRequest::TRANSACTION_ID, $childPayment->getPayPalData()->getPaymentId() ); |
|
| 113 | - $this->assertEquals( $application->getPayment()->getAmount(), $childApplication->getPayment()->getAmount() ); |
|
| 114 | - $this->assertEquals( $application->getApplicant(), $childApplication->getApplicant() ); |
|
| 115 | - $this->assertEquals( $application->getPayment()->getIntervalInMonths(), $childApplication->getPayment()->getIntervalInMonths() ); |
|
| 116 | - $this->assertTrue( $childApplication->isConfirmed() ); |
|
| 112 | + $this->assertEquals(ValidPayPalNotificationRequest::TRANSACTION_ID, $childPayment->getPayPalData()->getPaymentId()); |
|
| 113 | + $this->assertEquals($application->getPayment()->getAmount(), $childApplication->getPayment()->getAmount()); |
|
| 114 | + $this->assertEquals($application->getApplicant(), $childApplication->getApplicant()); |
|
| 115 | + $this->assertEquals($application->getPayment()->getIntervalInMonths(), $childApplication->getPayment()->getIntervalInMonths()); |
|
| 116 | + $this->assertTrue($childApplication->isConfirmed()); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | public function testGivenExistingTransactionId_requestIsNotHandled(): void { |
| 120 | 120 | $application = ValidMembershipApplication::newConfirmedSubscriptionDomainEntity(); |
| 121 | 121 | /** @var PayPalPayment $payment */ |
| 122 | 122 | $payment = $application->getPayment()->getPaymentMethod(); |
| 123 | - $payment->getPayPalData()->addChildPayment( ValidPayPalNotificationRequest::TRANSACTION_ID, 1 ); |
|
| 123 | + $payment->getPayPalData()->addChildPayment(ValidPayPalNotificationRequest::TRANSACTION_ID, 1); |
|
| 124 | 124 | |
| 125 | 125 | $fakeRepository = new FakeApplicationRepository(); |
| 126 | - $fakeRepository->storeApplication( $application ); |
|
| 126 | + $fakeRepository->storeApplication($application); |
|
| 127 | 127 | |
| 128 | - $request = ValidPayPalNotificationRequest::newRecurringPayment( 1 ); |
|
| 128 | + $request = ValidPayPalNotificationRequest::newRecurringPayment(1); |
|
| 129 | 129 | |
| 130 | 130 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 131 | 131 | $fakeRepository, |
@@ -134,31 +134,31 @@ discard block |
||
| 134 | 134 | new NullLogger() |
| 135 | 135 | ); |
| 136 | 136 | |
| 137 | - $response = $useCase->handleNotification( $request ); |
|
| 138 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 137 | + $response = $useCase->handleNotification($request); |
|
| 138 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 139 | 139 | } |
| 140 | 140 | |
| 141 | 141 | /** |
| 142 | 142 | * @return TemplateBasedMailer|\PHPUnit_Framework_MockObject_MockObject |
| 143 | 143 | */ |
| 144 | 144 | private function getMailer(): TemplateBasedMailer { |
| 145 | - return $this->getMockBuilder( TemplateBasedMailer::class )->disableOriginalConstructor()->getMock(); |
|
| 145 | + return $this->getMockBuilder(TemplateBasedMailer::class)->disableOriginalConstructor()->getMock(); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
| 149 | 149 | * @return DonationEventLogger|\PHPUnit_Framework_MockObject_MockObject |
| 150 | 150 | */ |
| 151 | 151 | private function getEventLogger(): DonationEventLogger { |
| 152 | - return $this->createMock( DonationEventLogger::class ); |
|
| 152 | + return $this->createMock(DonationEventLogger::class); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | public function testGivenSubscriptionPaymentRequest_parentDataSetReferencesChildPaymentId(): void { |
| 156 | 156 | $application = ValidMembershipApplication::newConfirmedSubscriptionDomainEntity(); |
| 157 | 157 | |
| 158 | 158 | $fakeRepository = new FakeApplicationRepository(); |
| 159 | - $fakeRepository->storeApplication( $application ); |
|
| 159 | + $fakeRepository->storeApplication($application); |
|
| 160 | 160 | |
| 161 | - $request = ValidPayPalNotificationRequest::newRecurringPayment( $application->getId() ); |
|
| 161 | + $request = ValidPayPalNotificationRequest::newRecurringPayment($application->getId()); |
|
| 162 | 162 | |
| 163 | 163 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 164 | 164 | $fakeRepository, |
@@ -166,22 +166,22 @@ discard block |
||
| 166 | 166 | $this->getMailer(), |
| 167 | 167 | new NullLogger() |
| 168 | 168 | ); |
| 169 | - $useCase->handleNotification( $request ); |
|
| 169 | + $useCase->handleNotification($request); |
|
| 170 | 170 | |
| 171 | 171 | /** @var PayPalPayment $payment */ |
| 172 | 172 | $payment = $application->getPayment()->getPaymentMethod(); |
| 173 | 173 | |
| 174 | - $storedApplication = $fakeRepository->getApplicationById( $application->getId() ); |
|
| 174 | + $storedApplication = $fakeRepository->getApplicationById($application->getId()); |
|
| 175 | 175 | /** @var PayPalPayment $storedpayment */ |
| 176 | 176 | $storedpayment = $storedApplication->getPayment()->getPaymentMethod(); |
| 177 | 177 | |
| 178 | 178 | $this->assertSame( |
| 179 | 179 | 2, |
| 180 | - $storedpayment->getPayPalData()->getChildPaymentEntityId( ValidPayPalNotificationRequest::TRANSACTION_ID ) |
|
| 180 | + $storedpayment->getPayPalData()->getChildPaymentEntityId(ValidPayPalNotificationRequest::TRANSACTION_ID) |
|
| 181 | 181 | ); |
| 182 | 182 | |
| 183 | 183 | $this->assertEquals( |
| 184 | - $payment->getPayPalData()->addChildPayment( ValidPayPalNotificationRequest::TRANSACTION_ID, 2 ), |
|
| 184 | + $payment->getPayPalData()->addChildPayment(ValidPayPalNotificationRequest::TRANSACTION_ID, 2), |
|
| 185 | 185 | $storedpayment->getPayPalData() |
| 186 | 186 | ); |
| 187 | 187 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Unit\Domain\Model; |
| 6 | 6 | |
@@ -20,38 +20,38 @@ discard block |
||
| 20 | 20 | /** |
| 21 | 21 | * @dataProvider invalidIntervalProvider |
| 22 | 22 | */ |
| 23 | - public function testGivenInvalidInterval_constructorThrowsException( int $invalidInterval ): void { |
|
| 24 | - $this->expectException( \InvalidArgumentException::class ); |
|
| 23 | + public function testGivenInvalidInterval_constructorThrowsException(int $invalidInterval): void { |
|
| 24 | + $this->expectException(\InvalidArgumentException::class); |
|
| 25 | 25 | new Payment( |
| 26 | 26 | $invalidInterval, |
| 27 | - Euro::newFromInt( 42 ), |
|
| 28 | - new DirectDebitPayment( new BankData() ) |
|
| 27 | + Euro::newFromInt(42), |
|
| 28 | + new DirectDebitPayment(new BankData()) |
|
| 29 | 29 | ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | public function invalidIntervalProvider(): array { |
| 33 | 33 | return [ |
| 34 | - 'you cant have infinity moneys' => [ 0 ], |
|
| 35 | - 'time travel is also not allowed' => [ -1 ], |
|
| 36 | - 'you cant pay 2.4 times per year' => [ 5 ], |
|
| 37 | - 'you need to pay at least once per year' => [ 13 ], |
|
| 38 | - 'you need to pay at least once per year!' => [ 24 ], |
|
| 34 | + 'you cant have infinity moneys' => [0], |
|
| 35 | + 'time travel is also not allowed' => [ -1], |
|
| 36 | + 'you cant pay 2.4 times per year' => [5], |
|
| 37 | + 'you need to pay at least once per year' => [13], |
|
| 38 | + 'you need to pay at least once per year!' => [24], |
|
| 39 | 39 | ]; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testWhenIntervalIsTwelveMonths_yearlyPaymentIsBasePayment(): void { |
| 43 | - $payment = new Payment( 12, Euro::newFromInt( 42 ), new DirectDebitPayment( new BankData() ) ); |
|
| 44 | - $this->assertEquals( 42, $payment->getYearlyAmount()->getEuroFloat() ); |
|
| 43 | + $payment = new Payment(12, Euro::newFromInt(42), new DirectDebitPayment(new BankData())); |
|
| 44 | + $this->assertEquals(42, $payment->getYearlyAmount()->getEuroFloat()); |
|
| 45 | 45 | } |
| 46 | 46 | |
| 47 | 47 | public function testWhenIntervalIsOneMonth_yearlyPaymentIsTwelveTimesBasePayment(): void { |
| 48 | - $payment = new Payment( 1, Euro::newFromInt( 10 ), new DirectDebitPayment( new BankData() ) ); |
|
| 49 | - $this->assertEquals( 120, $payment->getYearlyAmount()->getEuroFloat() ); |
|
| 48 | + $payment = new Payment(1, Euro::newFromInt(10), new DirectDebitPayment(new BankData())); |
|
| 49 | + $this->assertEquals(120, $payment->getYearlyAmount()->getEuroFloat()); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function testWhenIntervalIsOneQuarter_yearlyPaymentIsFourTimesBasePayment(): void { |
| 53 | - $payment = new Payment( 3, Euro::newFromInt( 50 ), new DirectDebitPayment( new BankData() ) ); |
|
| 54 | - $this->assertEquals( 200, $payment->getYearlyAmount()->getEuroFloat() ); |
|
| 53 | + $payment = new Payment(3, Euro::newFromInt(50), new DirectDebitPayment(new BankData())); |
|
| 54 | + $this->assertEquals(200, $payment->getYearlyAmount()->getEuroFloat()); |
|
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Unit\Domain\Model; |
| 6 | 6 | |
@@ -16,44 +16,44 @@ discard block |
||
| 16 | 16 | class ApplicationTest extends \PHPUnit\Framework\TestCase { |
| 17 | 17 | |
| 18 | 18 | public function testIdIsNullWhenNotAssigned(): void { |
| 19 | - $this->assertNull( ValidMembershipApplication::newDomainEntity()->getId() ); |
|
| 19 | + $this->assertNull(ValidMembershipApplication::newDomainEntity()->getId()); |
|
| 20 | 20 | } |
| 21 | 21 | |
| 22 | 22 | public function testCanAssignIdToNewDonation(): void { |
| 23 | 23 | $donation = ValidMembershipApplication::newDomainEntity(); |
| 24 | 24 | |
| 25 | - $donation->assignId( 42 ); |
|
| 26 | - $this->assertSame( 42, $donation->getId() ); |
|
| 25 | + $donation->assignId(42); |
|
| 26 | + $this->assertSame(42, $donation->getId()); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | public function testCannotAssignIdToDonationWithIdentity(): void { |
| 30 | 30 | $donation = ValidMembershipApplication::newDomainEntity(); |
| 31 | - $donation->assignId( 42 ); |
|
| 31 | + $donation->assignId(42); |
|
| 32 | 32 | |
| 33 | - $this->expectException( RuntimeException::class ); |
|
| 34 | - $donation->assignId( 43 ); |
|
| 33 | + $this->expectException(RuntimeException::class); |
|
| 34 | + $donation->assignId(43); |
|
| 35 | 35 | } |
| 36 | 36 | |
| 37 | 37 | public function testNewApplicationHasExpectedDefaults(): void { |
| 38 | 38 | $application = ValidMembershipApplication::newDomainEntity(); |
| 39 | 39 | |
| 40 | - $this->assertNull( $application->getId() ); |
|
| 41 | - $this->assertFalse( $application->isCancelled() ); |
|
| 42 | - $this->assertFalse( $application->needsModeration() ); |
|
| 40 | + $this->assertNull($application->getId()); |
|
| 41 | + $this->assertFalse($application->isCancelled()); |
|
| 42 | + $this->assertFalse($application->needsModeration()); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | public function testCancellationResultsInCancelledApplication(): void { |
| 46 | 46 | $application = ValidMembershipApplication::newDomainEntity(); |
| 47 | 47 | $application->cancel(); |
| 48 | 48 | |
| 49 | - $this->assertTrue( $application->isCancelled() ); |
|
| 49 | + $this->assertTrue($application->isCancelled()); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | public function testMarkForModerationResultsInApplicationThatNeedsModeration(): void { |
| 53 | 53 | $application = ValidMembershipApplication::newDomainEntity(); |
| 54 | 54 | $application->markForModeration(); |
| 55 | 55 | |
| 56 | - $this->assertTrue( $application->needsModeration() ); |
|
| 56 | + $this->assertTrue($application->needsModeration()); |
|
| 57 | 57 | } |
| 58 | 58 | |
| 59 | 59 | } |
| 60 | 60 | \ No newline at end of file |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -declare( strict_types = 1 ); |
|
| 3 | +declare(strict_types = 1); |
|
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\SubscriptionContext\Tests\Integration\DataAccess; |
| 6 | 6 | |
@@ -33,24 +33,24 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | private function getOrmRepository(): EntityRepository { |
| 36 | - return $this->entityManager->getRepository( Subscription::class ); |
|
| 36 | + return $this->entityManager->getRepository(Subscription::class); |
|
| 37 | 37 | } |
| 38 | 38 | |
| 39 | 39 | public function testGivenASubscription_itIsStored(): void { |
| 40 | 40 | $subscription = new Subscription(); |
| 41 | - $subscription->setEmail( '[email protected]' ); |
|
| 42 | - $subscription->setAddress( new Address() ); |
|
| 43 | - $repository = new DoctrineSubscriptionRepository( $this->entityManager ); |
|
| 44 | - $repository->storeSubscription( $subscription ); |
|
| 41 | + $subscription->setEmail('[email protected]'); |
|
| 42 | + $subscription->setAddress(new Address()); |
|
| 43 | + $repository = new DoctrineSubscriptionRepository($this->entityManager); |
|
| 44 | + $repository->storeSubscription($subscription); |
|
| 45 | 45 | $expected = $this->getOrmRepository()->findAll(); |
| 46 | - $this->assertEquals( [$subscription], $expected ); |
|
| 46 | + $this->assertEquals([$subscription], $expected); |
|
| 47 | 47 | } |
| 48 | 48 | |
| 49 | 49 | public function testGivenARecentSubscription_itIsCounted(): void { |
| 50 | 50 | $firstSubscription = $this->persistFirstSubscription(); |
| 51 | 51 | $this->entityManager->flush(); |
| 52 | - $repository = new DoctrineSubscriptionRepository( $this->entityManager ); |
|
| 53 | - $this->assertSame( 1, $repository->countSimilar( $firstSubscription, new \DateTime( '100 years ago' ) ) ); |
|
| 52 | + $repository = new DoctrineSubscriptionRepository($this->entityManager); |
|
| 53 | + $this->assertSame(1, $repository->countSimilar($firstSubscription, new \DateTime('100 years ago'))); |
|
| 54 | 54 | } |
| 55 | 55 | |
| 56 | 56 | public function testMultipleSubscriptions_onlySimilarAreCounted(): void { |
@@ -59,48 +59,48 @@ discard block |
||
| 59 | 59 | $thirdSubscription = $this->persistThirdSubscription(); |
| 60 | 60 | |
| 61 | 61 | $this->entityManager->flush(); |
| 62 | - $repository = new DoctrineSubscriptionRepository( $this->entityManager ); |
|
| 63 | - $this->assertSame( 1, $repository->countSimilar( $thirdSubscription, new \DateTime( '1 hour ago' ) ) ); |
|
| 64 | - $this->assertSame( 2, $repository->countSimilar( $thirdSubscription, new \DateTime( '100 years ago' ) ) ); |
|
| 62 | + $repository = new DoctrineSubscriptionRepository($this->entityManager); |
|
| 63 | + $this->assertSame(1, $repository->countSimilar($thirdSubscription, new \DateTime('1 hour ago'))); |
|
| 64 | + $this->assertSame(2, $repository->countSimilar($thirdSubscription, new \DateTime('100 years ago'))); |
|
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | public function testDatabaseLayerExceptionsAreConvertedToDomainExceptions(): void { |
| 68 | - $entityManager = $this->getMockBuilder( EntityManager::class ) |
|
| 69 | - ->setMethods( [ 'getRepository', 'getClassMetadata', 'persist', 'flush' ] ) |
|
| 68 | + $entityManager = $this->getMockBuilder(EntityManager::class) |
|
| 69 | + ->setMethods(['getRepository', 'getClassMetadata', 'persist', 'flush']) |
|
| 70 | 70 | ->disableOriginalConstructor() |
| 71 | 71 | ->getMock(); |
| 72 | 72 | |
| 73 | - $entityManager->expects( $this->once() )->method( 'persist' )->willThrowException( new ORMException() ); |
|
| 74 | - $repository = new DoctrineSubscriptionRepository( $entityManager ); |
|
| 73 | + $entityManager->expects($this->once())->method('persist')->willThrowException(new ORMException()); |
|
| 74 | + $repository = new DoctrineSubscriptionRepository($entityManager); |
|
| 75 | 75 | $subscription = new Subscription(); |
| 76 | - $subscription->setEmail( '[email protected]' ); |
|
| 77 | - $subscription->setAddress( new Address() ); |
|
| 76 | + $subscription->setEmail('[email protected]'); |
|
| 77 | + $subscription->setAddress(new Address()); |
|
| 78 | 78 | |
| 79 | - $this->expectException( SubscriptionRepositoryException::class ); |
|
| 80 | - $repository->storeSubscription( $subscription ); |
|
| 79 | + $this->expectException(SubscriptionRepositoryException::class); |
|
| 80 | + $repository->storeSubscription($subscription); |
|
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | private function persistFirstSubscription(): Subscription { |
| 84 | 84 | $subscription = new Subscription(); |
| 85 | - $subscription->setEmail( '[email protected]' ); |
|
| 86 | - $subscription->setCreatedAt( new \DateTime( '10 minutes ago' ) ); |
|
| 87 | - $this->entityManager->persist( $subscription ); |
|
| 85 | + $subscription->setEmail('[email protected]'); |
|
| 86 | + $subscription->setCreatedAt(new \DateTime('10 minutes ago')); |
|
| 87 | + $this->entityManager->persist($subscription); |
|
| 88 | 88 | return $subscription; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | private function persistSecondSubscription(): Subscription { |
| 92 | 92 | $subscription = new Subscription(); |
| 93 | - $subscription->setEmail( '[email protected]' ); |
|
| 94 | - $subscription->setCreatedAt( new \DateTime( '10 days ago' ) ); |
|
| 95 | - $this->entityManager->persist( $subscription ); |
|
| 93 | + $subscription->setEmail('[email protected]'); |
|
| 94 | + $subscription->setCreatedAt(new \DateTime('10 days ago')); |
|
| 95 | + $this->entityManager->persist($subscription); |
|
| 96 | 96 | return $subscription; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | private function persistThirdSubscription(): Subscription { |
| 100 | 100 | $subscription = new Subscription(); |
| 101 | - $subscription->setEmail( '[email protected]' ); |
|
| 102 | - $subscription->setCreatedAt( new \DateTime( '10 minutes ago' ) ); |
|
| 103 | - $this->entityManager->persist( $subscription ); |
|
| 101 | + $subscription->setEmail('[email protected]'); |
|
| 102 | + $subscription->setCreatedAt(new \DateTime('10 minutes ago')); |
|
| 103 | + $this->entityManager->persist($subscription); |
|
| 104 | 104 | return $subscription; |
| 105 | 105 | } |
| 106 | 106 | } |