@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | namespace WMDE\Fundraising\Frontend\MembershipContext\Tests\Integration\UseCases\HandleSubscriptionPaymentNotification; |
| 6 | 6 | |
| 7 | -use WMDE\Fundraising\Frontend\DonationContext\Infrastructure\DonationEventLogger; |
|
| 8 | 7 | use WMDE\Fundraising\Frontend\DonationContext\Tests\Data\ValidPayPalNotificationRequest; |
| 9 | 8 | use WMDE\Fundraising\Frontend\Infrastructure\TemplateBasedMailer; |
| 10 | 9 | use WMDE\Fundraising\Frontend\MembershipContext\DataAccess\DoctrineApplicationRepository; |
@@ -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 | |
@@ -28,20 +28,20 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | public function testWhenRepositoryThrowsException_requestIsNotHandled(): void { |
| 30 | 30 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 31 | - new DoctrineApplicationRepository( ThrowingEntityManager::newInstance( $this ) ), |
|
| 31 | + new DoctrineApplicationRepository(ThrowingEntityManager::newInstance($this)), |
|
| 32 | 32 | new SucceedingAuthorizer(), |
| 33 | 33 | $this->getMailer(), |
| 34 | 34 | new NullLogger() |
| 35 | 35 | ); |
| 36 | - $request = ValidPayPalNotificationRequest::newInstantPayment( 1 ); |
|
| 37 | - $response = $useCase->handleNotification( $request ); |
|
| 38 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 39 | - $this->assertTrue( $response->hasErrors() ); |
|
| 36 | + $request = ValidPayPalNotificationRequest::newInstantPayment(1); |
|
| 37 | + $response = $useCase->handleNotification($request); |
|
| 38 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 39 | + $this->assertTrue($response->hasErrors()); |
|
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | public function testWhenApplicationDoesNotExist_requestIsNotHandled(): void { |
| 43 | 43 | $fakeRepository = new FakeApplicationRepository(); |
| 44 | - $fakeRepository->storeApplication( ValidMembershipApplication::newDomainEntityUsingPayPal() ); |
|
| 44 | + $fakeRepository->storeApplication(ValidMembershipApplication::newDomainEntityUsingPayPal()); |
|
| 45 | 45 | |
| 46 | 46 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 47 | 47 | $fakeRepository, |
@@ -50,14 +50,14 @@ discard block |
||
| 50 | 50 | new NullLogger() |
| 51 | 51 | ); |
| 52 | 52 | |
| 53 | - $request = ValidPayPalNotificationRequest::newInstantPayment( 667 ); |
|
| 54 | - $response = $useCase->handleNotification( $request ); |
|
| 55 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 53 | + $request = ValidPayPalNotificationRequest::newInstantPayment(667); |
|
| 54 | + $response = $useCase->handleNotification($request); |
|
| 55 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | public function testWhenAuthorizationFails_requestIsNotHandled(): void { |
| 59 | 59 | $fakeRepository = new FakeApplicationRepository(); |
| 60 | - $fakeRepository->storeApplication( ValidMembershipApplication::newDomainEntityUsingPayPal() ); |
|
| 60 | + $fakeRepository->storeApplication(ValidMembershipApplication::newDomainEntityUsingPayPal()); |
|
| 61 | 61 | |
| 62 | 62 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 63 | 63 | $fakeRepository, |
@@ -66,9 +66,9 @@ discard block |
||
| 66 | 66 | new NullLogger() |
| 67 | 67 | ); |
| 68 | 68 | |
| 69 | - $request = ValidPayPalNotificationRequest::newInstantPayment( 1 ); |
|
| 70 | - $response = $useCase->handleNotification( $request ); |
|
| 71 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 69 | + $request = ValidPayPalNotificationRequest::newInstantPayment(1); |
|
| 70 | + $response = $useCase->handleNotification($request); |
|
| 71 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | public function testWhenTransactionTypeIsForSubscriptionChanges_requestIsNotHandled(): void { |
@@ -80,17 +80,17 @@ discard block |
||
| 80 | 80 | $this->getMailer(), |
| 81 | 81 | new NullLogger() |
| 82 | 82 | ); |
| 83 | - $response = $useCase->handleNotification( $request ); |
|
| 84 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 83 | + $response = $useCase->handleNotification($request); |
|
| 84 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 85 | 85 | } |
| 86 | 86 | |
| 87 | 87 | public function testGivenSubscriptionPaymentRequest_childDataSetIsCreated(): void { |
| 88 | 88 | $application = ValidMembershipApplication::newConfirmedSubscriptionDomainEntity(); |
| 89 | 89 | |
| 90 | 90 | $fakeRepository = new FakeApplicationRepository(); |
| 91 | - $fakeRepository->storeApplication( $application ); |
|
| 91 | + $fakeRepository->storeApplication($application); |
|
| 92 | 92 | |
| 93 | - $request = ValidPayPalNotificationRequest::newRecurringPayment( $application->getId() ); |
|
| 93 | + $request = ValidPayPalNotificationRequest::newRecurringPayment($application->getId()); |
|
| 94 | 94 | |
| 95 | 95 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 96 | 96 | $fakeRepository, |
@@ -99,35 +99,35 @@ discard block |
||
| 99 | 99 | new NullLogger() |
| 100 | 100 | ); |
| 101 | 101 | |
| 102 | - $response = $useCase->handleNotification( $request ); |
|
| 103 | - $this->assertTrue( $response->notificationWasHandled() ); |
|
| 104 | - $this->assertFalse( $response->hasErrors() ); |
|
| 102 | + $response = $useCase->handleNotification($request); |
|
| 103 | + $this->assertTrue($response->notificationWasHandled()); |
|
| 104 | + $this->assertFalse($response->hasErrors()); |
|
| 105 | 105 | |
| 106 | - $application = $fakeRepository->getApplicationById( $application->getId() ); |
|
| 106 | + $application = $fakeRepository->getApplicationById($application->getId()); |
|
| 107 | 107 | /** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $payment */ |
| 108 | 108 | $payment = $application->getPayment()->getPaymentMethod(); |
| 109 | - $childApplication = $fakeRepository->getApplicationById( $payment->getPayPalData()->getChildPaymentEntityId( ValidPayPalNotificationRequest::TRANSACTION_ID ) ); |
|
| 110 | - $this->assertNotNull( $childApplication ); |
|
| 109 | + $childApplication = $fakeRepository->getApplicationById($payment->getPayPalData()->getChildPaymentEntityId(ValidPayPalNotificationRequest::TRANSACTION_ID)); |
|
| 110 | + $this->assertNotNull($childApplication); |
|
| 111 | 111 | /** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $childPayment */ |
| 112 | 112 | $childPayment = $childApplication->getPayment()->getPaymentMethod(); |
| 113 | - $this->assertEquals( ValidPayPalNotificationRequest::TRANSACTION_ID, $childPayment->getPayPalData()->getPaymentId() ); |
|
| 114 | - $this->assertEquals( $application->getPayment()->getAmount(), $childApplication->getPayment()->getAmount() ); |
|
| 115 | - $this->assertEquals( $application->getApplicant(), $childApplication->getApplicant() ); |
|
| 116 | - $this->assertEquals( $application->getPayment()->getIntervalInMonths(), $childApplication->getPayment()->getIntervalInMonths() ); |
|
| 117 | - $this->assertTrue( $childApplication->isConfirmed() ); |
|
| 118 | - $this->assertTrue( $childApplication->getDonationReceipt() ); |
|
| 113 | + $this->assertEquals(ValidPayPalNotificationRequest::TRANSACTION_ID, $childPayment->getPayPalData()->getPaymentId()); |
|
| 114 | + $this->assertEquals($application->getPayment()->getAmount(), $childApplication->getPayment()->getAmount()); |
|
| 115 | + $this->assertEquals($application->getApplicant(), $childApplication->getApplicant()); |
|
| 116 | + $this->assertEquals($application->getPayment()->getIntervalInMonths(), $childApplication->getPayment()->getIntervalInMonths()); |
|
| 117 | + $this->assertTrue($childApplication->isConfirmed()); |
|
| 118 | + $this->assertTrue($childApplication->getDonationReceipt()); |
|
| 119 | 119 | } |
| 120 | 120 | |
| 121 | 121 | public function testGivenExistingTransactionId_requestIsNotHandled(): void { |
| 122 | 122 | $application = ValidMembershipApplication::newConfirmedSubscriptionDomainEntity(); |
| 123 | 123 | /** @var PayPalPayment $payment */ |
| 124 | 124 | $payment = $application->getPayment()->getPaymentMethod(); |
| 125 | - $payment->getPayPalData()->addChildPayment( ValidPayPalNotificationRequest::TRANSACTION_ID, 1 ); |
|
| 125 | + $payment->getPayPalData()->addChildPayment(ValidPayPalNotificationRequest::TRANSACTION_ID, 1); |
|
| 126 | 126 | |
| 127 | 127 | $fakeRepository = new FakeApplicationRepository(); |
| 128 | - $fakeRepository->storeApplication( $application ); |
|
| 128 | + $fakeRepository->storeApplication($application); |
|
| 129 | 129 | |
| 130 | - $request = ValidPayPalNotificationRequest::newRecurringPayment( 1 ); |
|
| 130 | + $request = ValidPayPalNotificationRequest::newRecurringPayment(1); |
|
| 131 | 131 | |
| 132 | 132 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 133 | 133 | $fakeRepository, |
@@ -136,24 +136,24 @@ discard block |
||
| 136 | 136 | new NullLogger() |
| 137 | 137 | ); |
| 138 | 138 | |
| 139 | - $response = $useCase->handleNotification( $request ); |
|
| 140 | - $this->assertFalse( $response->notificationWasHandled() ); |
|
| 139 | + $response = $useCase->handleNotification($request); |
|
| 140 | + $this->assertFalse($response->notificationWasHandled()); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | /** |
| 144 | 144 | * @return TemplateBasedMailer|\PHPUnit_Framework_MockObject_MockObject |
| 145 | 145 | */ |
| 146 | 146 | private function getMailer(): TemplateBasedMailer { |
| 147 | - return $this->getMockBuilder( TemplateBasedMailer::class )->disableOriginalConstructor()->getMock(); |
|
| 147 | + return $this->getMockBuilder(TemplateBasedMailer::class)->disableOriginalConstructor()->getMock(); |
|
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | public function testGivenSubscriptionPaymentRequest_parentDataSetReferencesChildPaymentId(): void { |
| 151 | 151 | $application = ValidMembershipApplication::newConfirmedSubscriptionDomainEntity(); |
| 152 | 152 | |
| 153 | 153 | $fakeRepository = new FakeApplicationRepository(); |
| 154 | - $fakeRepository->storeApplication( $application ); |
|
| 154 | + $fakeRepository->storeApplication($application); |
|
| 155 | 155 | |
| 156 | - $request = ValidPayPalNotificationRequest::newRecurringPayment( $application->getId() ); |
|
| 156 | + $request = ValidPayPalNotificationRequest::newRecurringPayment($application->getId()); |
|
| 157 | 157 | |
| 158 | 158 | $useCase = new HandleSubscriptionPaymentNotificationUseCase( |
| 159 | 159 | $fakeRepository, |
@@ -161,22 +161,22 @@ discard block |
||
| 161 | 161 | $this->getMailer(), |
| 162 | 162 | new NullLogger() |
| 163 | 163 | ); |
| 164 | - $useCase->handleNotification( $request ); |
|
| 164 | + $useCase->handleNotification($request); |
|
| 165 | 165 | |
| 166 | 166 | /** @var PayPalPayment $payment */ |
| 167 | 167 | $payment = $application->getPayment()->getPaymentMethod(); |
| 168 | 168 | |
| 169 | - $storedApplication = $fakeRepository->getApplicationById( $application->getId() ); |
|
| 169 | + $storedApplication = $fakeRepository->getApplicationById($application->getId()); |
|
| 170 | 170 | /** @var PayPalPayment $storedpayment */ |
| 171 | 171 | $storedpayment = $storedApplication->getPayment()->getPaymentMethod(); |
| 172 | 172 | |
| 173 | 173 | $this->assertSame( |
| 174 | 174 | 2, |
| 175 | - $storedpayment->getPayPalData()->getChildPaymentEntityId( ValidPayPalNotificationRequest::TRANSACTION_ID ) |
|
| 175 | + $storedpayment->getPayPalData()->getChildPaymentEntityId(ValidPayPalNotificationRequest::TRANSACTION_ID) |
|
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | 178 | $this->assertEquals( |
| 179 | - $payment->getPayPalData()->addChildPayment( ValidPayPalNotificationRequest::TRANSACTION_ID, 2 ), |
|
| 179 | + $payment->getPayPalData()->addChildPayment(ValidPayPalNotificationRequest::TRANSACTION_ID, 2), |
|
| 180 | 180 | $storedpayment->getPayPalData() |
| 181 | 181 | ); |
| 182 | 182 | } |
@@ -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\ApplyForMembership; |
| 6 | 6 | |
@@ -78,29 +78,29 @@ discard block |
||
| 78 | 78 | |
| 79 | 79 | public function setUp(): void { |
| 80 | 80 | $this->repository = new InMemoryApplicationRepository(); |
| 81 | - $this->mailer = new TemplateBasedMailerSpy( $this ); |
|
| 82 | - $this->tokenGenerator = new FixedTokenGenerator( self::ACCESS_TOKEN ); |
|
| 81 | + $this->mailer = new TemplateBasedMailerSpy($this); |
|
| 82 | + $this->tokenGenerator = new FixedTokenGenerator(self::ACCESS_TOKEN); |
|
| 83 | 83 | $this->validator = $this->newSucceedingValidator(); |
| 84 | 84 | $this->policyValidator = $this->newSucceedingPolicyValidator(); |
| 85 | - $this->tracker = $this->createMock( ApplicationTracker::class ); |
|
| 86 | - $this->piwikTracker = $this->createMock( ApplicationPiwikTracker::class ); |
|
| 85 | + $this->tracker = $this->createMock(ApplicationTracker::class); |
|
| 86 | + $this->piwikTracker = $this->createMock(ApplicationPiwikTracker::class); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | private function newSucceedingValidator(): MembershipApplicationValidator { |
| 90 | - $validator = $this->getMockBuilder( MembershipApplicationValidator::class ) |
|
| 90 | + $validator = $this->getMockBuilder(MembershipApplicationValidator::class) |
|
| 91 | 91 | ->disableOriginalConstructor()->getMock(); |
| 92 | 92 | |
| 93 | - $validator->expects( $this->any() ) |
|
| 94 | - ->method( 'validate' ) |
|
| 95 | - ->willReturn( new ApplicationValidationResult() ); |
|
| 93 | + $validator->expects($this->any()) |
|
| 94 | + ->method('validate') |
|
| 95 | + ->willReturn(new ApplicationValidationResult()); |
|
| 96 | 96 | |
| 97 | 97 | return $validator; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | public function testGivenValidRequest_applicationSucceeds(): void { |
| 101 | - $response = $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 101 | + $response = $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 102 | 102 | |
| 103 | - $this->assertTrue( $response->isSuccessful() ); |
|
| 103 | + $this->assertTrue($response->isSuccessful()); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | private function newUseCase(): ApplyForMembershipUseCase { |
@@ -117,45 +117,45 @@ discard block |
||
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | private function newTokenFetcher(): ApplicationTokenFetcher { |
| 120 | - return new FixedApplicationTokenFetcher( new MembershipApplicationTokens( |
|
| 120 | + return new FixedApplicationTokenFetcher(new MembershipApplicationTokens( |
|
| 121 | 121 | self::ACCESS_TOKEN, |
| 122 | 122 | self::UPDATE_TOKEN |
| 123 | - ) ); |
|
| 123 | + )); |
|
| 124 | 124 | } |
| 125 | 125 | |
| 126 | 126 | private function newFixedPaymentDelayCalculator(): PaymentDelayCalculator { |
| 127 | 127 | return new FixedPaymentDelayCalculator( |
| 128 | - new \DateTime( self::FIRST_PAYMENT_DATE ) |
|
| 128 | + new \DateTime(self::FIRST_PAYMENT_DATE) |
|
| 129 | 129 | ); |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | 132 | private function newValidRequest(): ApplyForMembershipRequest { |
| 133 | 133 | $request = new ApplyForMembershipRequest(); |
| 134 | 134 | |
| 135 | - $request->setMembershipType( ValidMembershipApplication::MEMBERSHIP_TYPE ); |
|
| 136 | - $request->setApplicantCompanyName( '' ); |
|
| 137 | - $request->setMembershipType( ValidMembershipApplication::MEMBERSHIP_TYPE ); |
|
| 138 | - $request->setApplicantSalutation( ValidMembershipApplication::APPLICANT_SALUTATION ); |
|
| 139 | - $request->setApplicantTitle( ValidMembershipApplication::APPLICANT_TITLE ); |
|
| 140 | - $request->setApplicantFirstName( ValidMembershipApplication::APPLICANT_FIRST_NAME ); |
|
| 141 | - $request->setApplicantLastName( ValidMembershipApplication::APPLICANT_LAST_NAME ); |
|
| 142 | - $request->setApplicantStreetAddress( ValidMembershipApplication::APPLICANT_STREET_ADDRESS ); |
|
| 143 | - $request->setApplicantPostalCode( ValidMembershipApplication::APPLICANT_POSTAL_CODE ); |
|
| 144 | - $request->setApplicantCity( ValidMembershipApplication::APPLICANT_CITY ); |
|
| 145 | - $request->setApplicantCountryCode( ValidMembershipApplication::APPLICANT_COUNTRY_CODE ); |
|
| 146 | - $request->setApplicantEmailAddress( ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS ); |
|
| 147 | - $request->setApplicantPhoneNumber( ValidMembershipApplication::APPLICANT_PHONE_NUMBER ); |
|
| 148 | - $request->setApplicantDateOfBirth( ValidMembershipApplication::APPLICANT_DATE_OF_BIRTH ); |
|
| 149 | - $request->setPaymentType( ValidMembershipApplication::PAYMENT_TYPE_DIRECT_DEBIT ); |
|
| 150 | - $request->setPaymentIntervalInMonths( ValidMembershipApplication::PAYMENT_PERIOD_IN_MONTHS ); |
|
| 151 | - $request->setPaymentAmountInEuros( (string)ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO ); |
|
| 152 | - |
|
| 153 | - $request->setBankData( $this->newValidBankData() ); |
|
| 154 | - |
|
| 155 | - $request->setTrackingInfo( $this->newTrackingInfo() ); |
|
| 156 | - $request->setPiwikTrackingString( 'foo/bar' ); |
|
| 157 | - |
|
| 158 | - $request->setOptsIntoDonationReceipt( true ); |
|
| 135 | + $request->setMembershipType(ValidMembershipApplication::MEMBERSHIP_TYPE); |
|
| 136 | + $request->setApplicantCompanyName(''); |
|
| 137 | + $request->setMembershipType(ValidMembershipApplication::MEMBERSHIP_TYPE); |
|
| 138 | + $request->setApplicantSalutation(ValidMembershipApplication::APPLICANT_SALUTATION); |
|
| 139 | + $request->setApplicantTitle(ValidMembershipApplication::APPLICANT_TITLE); |
|
| 140 | + $request->setApplicantFirstName(ValidMembershipApplication::APPLICANT_FIRST_NAME); |
|
| 141 | + $request->setApplicantLastName(ValidMembershipApplication::APPLICANT_LAST_NAME); |
|
| 142 | + $request->setApplicantStreetAddress(ValidMembershipApplication::APPLICANT_STREET_ADDRESS); |
|
| 143 | + $request->setApplicantPostalCode(ValidMembershipApplication::APPLICANT_POSTAL_CODE); |
|
| 144 | + $request->setApplicantCity(ValidMembershipApplication::APPLICANT_CITY); |
|
| 145 | + $request->setApplicantCountryCode(ValidMembershipApplication::APPLICANT_COUNTRY_CODE); |
|
| 146 | + $request->setApplicantEmailAddress(ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS); |
|
| 147 | + $request->setApplicantPhoneNumber(ValidMembershipApplication::APPLICANT_PHONE_NUMBER); |
|
| 148 | + $request->setApplicantDateOfBirth(ValidMembershipApplication::APPLICANT_DATE_OF_BIRTH); |
|
| 149 | + $request->setPaymentType(ValidMembershipApplication::PAYMENT_TYPE_DIRECT_DEBIT); |
|
| 150 | + $request->setPaymentIntervalInMonths(ValidMembershipApplication::PAYMENT_PERIOD_IN_MONTHS); |
|
| 151 | + $request->setPaymentAmountInEuros((string)ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO); |
|
| 152 | + |
|
| 153 | + $request->setBankData($this->newValidBankData()); |
|
| 154 | + |
|
| 155 | + $request->setTrackingInfo($this->newTrackingInfo()); |
|
| 156 | + $request->setPiwikTrackingString('foo/bar'); |
|
| 157 | + |
|
| 158 | + $request->setOptsIntoDonationReceipt(true); |
|
| 159 | 159 | |
| 160 | 160 | return $request->assertNoNullFields(); |
| 161 | 161 | } |
@@ -163,11 +163,11 @@ discard block |
||
| 163 | 163 | private function newValidBankData(): BankData { |
| 164 | 164 | $bankData = new BankData(); |
| 165 | 165 | |
| 166 | - $bankData->setIban( new Iban( ValidMembershipApplication::PAYMENT_IBAN ) ); |
|
| 167 | - $bankData->setBic( ValidMembershipApplication::PAYMENT_BIC ); |
|
| 168 | - $bankData->setAccount( ValidMembershipApplication::PAYMENT_BANK_ACCOUNT ); |
|
| 169 | - $bankData->setBankCode( ValidMembershipApplication::PAYMENT_BANK_CODE ); |
|
| 170 | - $bankData->setBankName( ValidMembershipApplication::PAYMENT_BANK_NAME ); |
|
| 166 | + $bankData->setIban(new Iban(ValidMembershipApplication::PAYMENT_IBAN)); |
|
| 167 | + $bankData->setBic(ValidMembershipApplication::PAYMENT_BIC); |
|
| 168 | + $bankData->setAccount(ValidMembershipApplication::PAYMENT_BANK_ACCOUNT); |
|
| 169 | + $bankData->setBankCode(ValidMembershipApplication::PAYMENT_BANK_CODE); |
|
| 170 | + $bankData->setBankName(ValidMembershipApplication::PAYMENT_BANK_NAME); |
|
| 171 | 171 | |
| 172 | 172 | return $bankData->assertNoNullFields()->freeze(); |
| 173 | 173 | } |
@@ -180,22 +180,22 @@ discard block |
||
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | public function testGivenValidRequest_applicationGetsPersisted(): void { |
| 183 | - $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 183 | + $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 184 | 184 | |
| 185 | 185 | $expectedApplication = ValidMembershipApplication::newDomainEntity(); |
| 186 | - $expectedApplication->assignId( self::FIRST_APPLICATION_ID ); |
|
| 186 | + $expectedApplication->assignId(self::FIRST_APPLICATION_ID); |
|
| 187 | 187 | |
| 188 | - $application = $this->repository->getApplicationById( $expectedApplication->getId() ); |
|
| 189 | - $this->assertNotNull( $application ); |
|
| 188 | + $application = $this->repository->getApplicationById($expectedApplication->getId()); |
|
| 189 | + $this->assertNotNull($application); |
|
| 190 | 190 | |
| 191 | - $this->assertEquals( $expectedApplication, $application ); |
|
| 191 | + $this->assertEquals($expectedApplication, $application); |
|
| 192 | 192 | } |
| 193 | 193 | |
| 194 | 194 | public function testGivenValidRequest_confirmationEmailIsSend(): void { |
| 195 | - $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 195 | + $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 196 | 196 | |
| 197 | 197 | $this->mailer->assertCalledOnceWith( |
| 198 | - new EmailAddress( ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS ), |
|
| 198 | + new EmailAddress(ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS), |
|
| 199 | 199 | [ |
| 200 | 200 | 'membershipType' => 'sustaining', |
| 201 | 201 | 'membershipFee' => '10.00', |
@@ -209,131 +209,131 @@ discard block |
||
| 209 | 209 | } |
| 210 | 210 | |
| 211 | 211 | public function testGivenValidRequest_tokenIsGeneratedAndReturned(): void { |
| 212 | - $response = $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 212 | + $response = $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 213 | 213 | |
| 214 | - $this->assertSame( self::ACCESS_TOKEN, $response->getAccessToken() ); |
|
| 215 | - $this->assertSame( self::UPDATE_TOKEN, $response->getUpdateToken() ); |
|
| 214 | + $this->assertSame(self::ACCESS_TOKEN, $response->getAccessToken()); |
|
| 215 | + $this->assertSame(self::UPDATE_TOKEN, $response->getUpdateToken()); |
|
| 216 | 216 | } |
| 217 | 217 | |
| 218 | 218 | public function testWhenValidationFails_failureResultIsReturned(): void { |
| 219 | 219 | $this->validator = $this->newFailingValidator(); |
| 220 | 220 | |
| 221 | - $response = $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 221 | + $response = $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 222 | 222 | |
| 223 | - $this->assertFalse( $response->isSuccessful() ); |
|
| 223 | + $this->assertFalse($response->isSuccessful()); |
|
| 224 | 224 | } |
| 225 | 225 | |
| 226 | 226 | private function newFailingValidator(): MembershipApplicationValidator { |
| 227 | - $validator = $this->getMockBuilder( MembershipApplicationValidator::class ) |
|
| 227 | + $validator = $this->getMockBuilder(MembershipApplicationValidator::class) |
|
| 228 | 228 | ->disableOriginalConstructor()->getMock(); |
| 229 | 229 | |
| 230 | - $validator->expects( $this->any() ) |
|
| 231 | - ->method( 'validate' ) |
|
| 232 | - ->willReturn( $this->newInvalidValidationResult() ); |
|
| 230 | + $validator->expects($this->any()) |
|
| 231 | + ->method('validate') |
|
| 232 | + ->willReturn($this->newInvalidValidationResult()); |
|
| 233 | 233 | |
| 234 | 234 | return $validator; |
| 235 | 235 | } |
| 236 | 236 | |
| 237 | 237 | private function newInvalidValidationResult(): ApplicationValidationResult { |
| 238 | - $invalidResult = $this->createMock( ApplicationValidationResult::class ); |
|
| 238 | + $invalidResult = $this->createMock(ApplicationValidationResult::class); |
|
| 239 | 239 | |
| 240 | - $invalidResult->expects( $this->any() ) |
|
| 241 | - ->method( 'isSuccessful' ) |
|
| 242 | - ->willReturn( false ); |
|
| 240 | + $invalidResult->expects($this->any()) |
|
| 241 | + ->method('isSuccessful') |
|
| 242 | + ->willReturn(false); |
|
| 243 | 243 | |
| 244 | 244 | return $invalidResult; |
| 245 | 245 | } |
| 246 | 246 | |
| 247 | 247 | public function testGivenValidRequest_moderationIsNotNeeded(): void { |
| 248 | - $response = $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 248 | + $response = $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 249 | 249 | |
| 250 | - $this->assertFalse( $response->getMembershipApplication()->needsModeration() ); |
|
| 250 | + $this->assertFalse($response->getMembershipApplication()->needsModeration()); |
|
| 251 | 251 | } |
| 252 | 252 | |
| 253 | 253 | public function testGivenFailingPolicyValidator_moderationIsNeeded(): void { |
| 254 | 254 | $this->policyValidator = $this->newFailingPolicyValidator(); |
| 255 | 255 | |
| 256 | - $response = $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 257 | - $this->assertTrue( $response->getMembershipApplication()->needsModeration() ); |
|
| 256 | + $response = $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 257 | + $this->assertTrue($response->getMembershipApplication()->needsModeration()); |
|
| 258 | 258 | } |
| 259 | 259 | |
| 260 | 260 | private function newSucceedingPolicyValidator(): ApplyForMembershipPolicyValidator { |
| 261 | - $policyValidator = $this->getMockBuilder( ApplyForMembershipPolicyValidator::class ) |
|
| 261 | + $policyValidator = $this->getMockBuilder(ApplyForMembershipPolicyValidator::class) |
|
| 262 | 262 | ->disableOriginalConstructor()->getMock(); |
| 263 | - $policyValidator->method( 'needsModeration' )->willReturn( false ); |
|
| 263 | + $policyValidator->method('needsModeration')->willReturn(false); |
|
| 264 | 264 | return $policyValidator; |
| 265 | 265 | } |
| 266 | 266 | |
| 267 | 267 | private function newFailingPolicyValidator(): ApplyForMembershipPolicyValidator { |
| 268 | - $policyValidator = $this->getMockBuilder( ApplyForMembershipPolicyValidator::class ) |
|
| 268 | + $policyValidator = $this->getMockBuilder(ApplyForMembershipPolicyValidator::class) |
|
| 269 | 269 | ->disableOriginalConstructor()->getMock(); |
| 270 | - $policyValidator->method( 'needsModeration' )->willReturn( true ); |
|
| 270 | + $policyValidator->method('needsModeration')->willReturn(true); |
|
| 271 | 271 | return $policyValidator; |
| 272 | 272 | } |
| 273 | 273 | |
| 274 | 274 | public function testWhenApplicationIsUnconfirmed_confirmationEmailIsNotSent(): void { |
| 275 | - $this->newUseCase()->applyForMembership( $this->newValidRequestForUnconfirmedApplication() ); |
|
| 275 | + $this->newUseCase()->applyForMembership($this->newValidRequestForUnconfirmedApplication()); |
|
| 276 | 276 | |
| 277 | - $this->assertSame( 0, count( $this->mailer->getSendMailCalls() ) ); |
|
| 277 | + $this->assertSame(0, count($this->mailer->getSendMailCalls())); |
|
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | private function newValidRequestForUnconfirmedApplication(): ApplyForMembershipRequest { |
| 281 | 281 | $request = new ApplyForMembershipRequest(); |
| 282 | 282 | |
| 283 | - $request->setMembershipType( ValidMembershipApplication::MEMBERSHIP_TYPE ); |
|
| 284 | - $request->setApplicantCompanyName( '' ); |
|
| 285 | - $request->setMembershipType( ValidMembershipApplication::MEMBERSHIP_TYPE ); |
|
| 286 | - $request->setApplicantSalutation( ValidMembershipApplication::APPLICANT_SALUTATION ); |
|
| 287 | - $request->setApplicantTitle( ValidMembershipApplication::APPLICANT_TITLE ); |
|
| 288 | - $request->setApplicantFirstName( ValidMembershipApplication::APPLICANT_FIRST_NAME ); |
|
| 289 | - $request->setApplicantLastName( ValidMembershipApplication::APPLICANT_LAST_NAME ); |
|
| 290 | - $request->setApplicantStreetAddress( ValidMembershipApplication::APPLICANT_STREET_ADDRESS ); |
|
| 291 | - $request->setApplicantPostalCode( ValidMembershipApplication::APPLICANT_POSTAL_CODE ); |
|
| 292 | - $request->setApplicantCity( ValidMembershipApplication::APPLICANT_CITY ); |
|
| 293 | - $request->setApplicantCountryCode( ValidMembershipApplication::APPLICANT_COUNTRY_CODE ); |
|
| 294 | - $request->setApplicantEmailAddress( ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS ); |
|
| 295 | - $request->setApplicantPhoneNumber( ValidMembershipApplication::APPLICANT_PHONE_NUMBER ); |
|
| 296 | - $request->setApplicantDateOfBirth( ValidMembershipApplication::APPLICANT_DATE_OF_BIRTH ); |
|
| 297 | - $request->setPaymentType( ValidMembershipApplication::PAYMENT_TYPE_PAYPAL ); |
|
| 298 | - $request->setPaymentIntervalInMonths( ValidMembershipApplication::PAYMENT_PERIOD_IN_MONTHS ); |
|
| 299 | - $request->setPaymentAmountInEuros( (string)ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO ); |
|
| 300 | - $request->setBankData( new BankData() ); |
|
| 301 | - |
|
| 302 | - $request->setTrackingInfo( $this->newTrackingInfo() ); |
|
| 303 | - $request->setPiwikTrackingString( 'foo/bar' ); |
|
| 283 | + $request->setMembershipType(ValidMembershipApplication::MEMBERSHIP_TYPE); |
|
| 284 | + $request->setApplicantCompanyName(''); |
|
| 285 | + $request->setMembershipType(ValidMembershipApplication::MEMBERSHIP_TYPE); |
|
| 286 | + $request->setApplicantSalutation(ValidMembershipApplication::APPLICANT_SALUTATION); |
|
| 287 | + $request->setApplicantTitle(ValidMembershipApplication::APPLICANT_TITLE); |
|
| 288 | + $request->setApplicantFirstName(ValidMembershipApplication::APPLICANT_FIRST_NAME); |
|
| 289 | + $request->setApplicantLastName(ValidMembershipApplication::APPLICANT_LAST_NAME); |
|
| 290 | + $request->setApplicantStreetAddress(ValidMembershipApplication::APPLICANT_STREET_ADDRESS); |
|
| 291 | + $request->setApplicantPostalCode(ValidMembershipApplication::APPLICANT_POSTAL_CODE); |
|
| 292 | + $request->setApplicantCity(ValidMembershipApplication::APPLICANT_CITY); |
|
| 293 | + $request->setApplicantCountryCode(ValidMembershipApplication::APPLICANT_COUNTRY_CODE); |
|
| 294 | + $request->setApplicantEmailAddress(ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS); |
|
| 295 | + $request->setApplicantPhoneNumber(ValidMembershipApplication::APPLICANT_PHONE_NUMBER); |
|
| 296 | + $request->setApplicantDateOfBirth(ValidMembershipApplication::APPLICANT_DATE_OF_BIRTH); |
|
| 297 | + $request->setPaymentType(ValidMembershipApplication::PAYMENT_TYPE_PAYPAL); |
|
| 298 | + $request->setPaymentIntervalInMonths(ValidMembershipApplication::PAYMENT_PERIOD_IN_MONTHS); |
|
| 299 | + $request->setPaymentAmountInEuros((string)ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO); |
|
| 300 | + $request->setBankData(new BankData()); |
|
| 301 | + |
|
| 302 | + $request->setTrackingInfo($this->newTrackingInfo()); |
|
| 303 | + $request->setPiwikTrackingString('foo/bar'); |
|
| 304 | 304 | |
| 305 | 305 | return $request->assertNoNullFields(); |
| 306 | 306 | } |
| 307 | 307 | |
| 308 | 308 | private function newAutoDeletingPolicyValidator(): ApplyForMembershipPolicyValidator { |
| 309 | - $policyValidator = $this->getMockBuilder( ApplyForMembershipPolicyValidator::class ) |
|
| 309 | + $policyValidator = $this->getMockBuilder(ApplyForMembershipPolicyValidator::class) |
|
| 310 | 310 | ->disableOriginalConstructor()->getMock(); |
| 311 | - $policyValidator->method( 'isAutoDeleted' )->willReturn( true ); |
|
| 311 | + $policyValidator->method('isAutoDeleted')->willReturn(true); |
|
| 312 | 312 | return $policyValidator; |
| 313 | 313 | } |
| 314 | 314 | |
| 315 | 315 | public function testWhenUsingBlacklistedEmailAddress_moderationIsAutomaticallyDeleted(): void { |
| 316 | 316 | $this->policyValidator = $this->newAutoDeletingPolicyValidator(); |
| 317 | - $this->newUseCase()->applyForMembership( $this->newValidRequest() ); |
|
| 318 | - $this->assertTrue( $this->repository->getApplicationById( 1 )->isDeleted() ); |
|
| 317 | + $this->newUseCase()->applyForMembership($this->newValidRequest()); |
|
| 318 | + $this->assertTrue($this->repository->getApplicationById(1)->isDeleted()); |
|
| 319 | 319 | } |
| 320 | 320 | |
| 321 | 321 | public function testWhenUsingPayPalPayment_delayInDaysIsPersisted(): void { |
| 322 | 322 | $request = $this->newValidRequest(); |
| 323 | - $request->setPaymentType( 'PPL' ); |
|
| 324 | - $this->newUseCase()->applyForMembership( $request ); |
|
| 323 | + $request->setPaymentType('PPL'); |
|
| 324 | + $this->newUseCase()->applyForMembership($request); |
|
| 325 | 325 | /** @var PayPalPayment $payPalPayment */ |
| 326 | - $payPalPayment = $this->repository->getApplicationById( 1 )->getPayment()->getPaymentMethod(); |
|
| 327 | - $this->assertSame( self::FIRST_PAYMENT_DATE, $payPalPayment->getPayPalData()->getFirstPaymentDate() ); |
|
| 326 | + $payPalPayment = $this->repository->getApplicationById(1)->getPayment()->getPaymentMethod(); |
|
| 327 | + $this->assertSame(self::FIRST_PAYMENT_DATE, $payPalPayment->getPayPalData()->getFirstPaymentDate()); |
|
| 328 | 328 | } |
| 329 | 329 | |
| 330 | 330 | public function testGivenDonationReceiptOptOutRequest_applicationHoldsThisValue(): void { |
| 331 | 331 | $request = $this->newValidRequest(); |
| 332 | - $request->setOptsIntoDonationReceipt( false ); |
|
| 333 | - $this->newUseCase()->applyForMembership( $request ); |
|
| 332 | + $request->setOptsIntoDonationReceipt(false); |
|
| 333 | + $this->newUseCase()->applyForMembership($request); |
|
| 334 | 334 | |
| 335 | - $application = $this->repository->getApplicationById( self::FIRST_APPLICATION_ID ); |
|
| 336 | - $this->assertFalse( $application->getDonationReceipt() ); |
|
| 335 | + $application = $this->repository->getApplicationById(self::FIRST_APPLICATION_ID); |
|
| 336 | + $this->assertFalse($application->getDonationReceipt()); |
|
| 337 | 337 | } |
| 338 | 338 | |
| 339 | 339 | } |
@@ -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,49 +16,49 @@ 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 | public function testDonationReceiptIsSetFromConstructor(): void { |
| 60 | 60 | $application = ValidMembershipApplication::newDomainEntity(); |
| 61 | - $this->assertTrue( $application->getDonationReceipt() ); |
|
| 61 | + $this->assertTrue($application->getDonationReceipt()); |
|
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | } |
| 65 | 65 | \ 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\MembershipContext\Tests\Unit\UseCases\ApplyForMembership; |
| 6 | 6 | |
@@ -29,48 +29,48 @@ discard block |
||
| 29 | 29 | public function testCompanyMembershipRequestGetsBuildCorrectly(): void { |
| 30 | 30 | $request = $this->newCompanyMembershipRequest(); |
| 31 | 31 | |
| 32 | - $application = ( new MembershipApplicationBuilder() )->newApplicationFromRequest( $request ); |
|
| 32 | + $application = (new MembershipApplicationBuilder())->newApplicationFromRequest($request); |
|
| 33 | 33 | |
| 34 | - $this->assertIsExpectedCompanyPersonName( $application->getApplicant()->getName() ); |
|
| 35 | - $this->assertIsExpectedAddress( $application->getApplicant()->getPhysicalAddress() ); |
|
| 34 | + $this->assertIsExpectedCompanyPersonName($application->getApplicant()->getName()); |
|
| 35 | + $this->assertIsExpectedAddress($application->getApplicant()->getPhysicalAddress()); |
|
| 36 | 36 | |
| 37 | 37 | $this->assertEquals( |
| 38 | - Euro::newFromInt( ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO ), |
|
| 38 | + Euro::newFromInt(ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO), |
|
| 39 | 39 | $application->getPayment()->getAmount() |
| 40 | 40 | ); |
| 41 | 41 | |
| 42 | - $this->assertTrue( $application->getDonationReceipt() ); |
|
| 42 | + $this->assertTrue($application->getDonationReceipt()); |
|
| 43 | 43 | } |
| 44 | 44 | |
| 45 | - private function newCompanyMembershipRequest( bool $omitOptionalFields = false ): ApplyForMembershipRequest { |
|
| 45 | + private function newCompanyMembershipRequest(bool $omitOptionalFields = false): ApplyForMembershipRequest { |
|
| 46 | 46 | $request = new ApplyForMembershipRequest(); |
| 47 | 47 | |
| 48 | - $request->setMembershipType( ValidMembershipApplication::MEMBERSHIP_TYPE ); |
|
| 48 | + $request->setMembershipType(ValidMembershipApplication::MEMBERSHIP_TYPE); |
|
| 49 | 49 | $request->markApplicantAsCompany(); |
| 50 | - $request->setApplicantCompanyName( self::COMPANY_NAME ); |
|
| 51 | - $request->setMembershipType( ValidMembershipApplication::MEMBERSHIP_TYPE ); |
|
| 52 | - $request->setApplicantSalutation( '' ); |
|
| 53 | - $request->setApplicantTitle( '' ); |
|
| 54 | - $request->setApplicantFirstName( '' ); |
|
| 55 | - $request->setApplicantLastName( '' ); |
|
| 56 | - $request->setApplicantStreetAddress( ValidMembershipApplication::APPLICANT_STREET_ADDRESS ); |
|
| 57 | - $request->setApplicantPostalCode( ValidMembershipApplication::APPLICANT_POSTAL_CODE ); |
|
| 58 | - $request->setApplicantCity( ValidMembershipApplication::APPLICANT_CITY ); |
|
| 59 | - $request->setApplicantCountryCode( ValidMembershipApplication::APPLICANT_COUNTRY_CODE ); |
|
| 60 | - $request->setApplicantEmailAddress( ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS ); |
|
| 61 | - $request->setPaymentType( ValidMembershipApplication::PAYMENT_TYPE_DIRECT_DEBIT ); |
|
| 62 | - $request->setPaymentIntervalInMonths( ValidMembershipApplication::PAYMENT_PERIOD_IN_MONTHS ); |
|
| 63 | - $request->setPaymentAmountInEuros( (string)ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO ); |
|
| 64 | - $request->setBankData( $this->newValidBankData() ); |
|
| 50 | + $request->setApplicantCompanyName(self::COMPANY_NAME); |
|
| 51 | + $request->setMembershipType(ValidMembershipApplication::MEMBERSHIP_TYPE); |
|
| 52 | + $request->setApplicantSalutation(''); |
|
| 53 | + $request->setApplicantTitle(''); |
|
| 54 | + $request->setApplicantFirstName(''); |
|
| 55 | + $request->setApplicantLastName(''); |
|
| 56 | + $request->setApplicantStreetAddress(ValidMembershipApplication::APPLICANT_STREET_ADDRESS); |
|
| 57 | + $request->setApplicantPostalCode(ValidMembershipApplication::APPLICANT_POSTAL_CODE); |
|
| 58 | + $request->setApplicantCity(ValidMembershipApplication::APPLICANT_CITY); |
|
| 59 | + $request->setApplicantCountryCode(ValidMembershipApplication::APPLICANT_COUNTRY_CODE); |
|
| 60 | + $request->setApplicantEmailAddress(ValidMembershipApplication::APPLICANT_EMAIL_ADDRESS); |
|
| 61 | + $request->setPaymentType(ValidMembershipApplication::PAYMENT_TYPE_DIRECT_DEBIT); |
|
| 62 | + $request->setPaymentIntervalInMonths(ValidMembershipApplication::PAYMENT_PERIOD_IN_MONTHS); |
|
| 63 | + $request->setPaymentAmountInEuros((string)ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO); |
|
| 64 | + $request->setBankData($this->newValidBankData()); |
|
| 65 | 65 | $request->setApplicantPhoneNumber( |
| 66 | 66 | $omitOptionalFields ? '' : ValidMembershipApplication::APPLICANT_PHONE_NUMBER |
| 67 | 67 | ); |
| 68 | 68 | $request->setApplicantDateOfBirth( |
| 69 | 69 | $omitOptionalFields ? '' : ValidMembershipApplication::APPLICANT_DATE_OF_BIRTH |
| 70 | 70 | ); |
| 71 | - $request->setTrackingInfo( $this->newTrackingInfo() ); |
|
| 72 | - $request->setPiwikTrackingString( 'foo/bar' ); |
|
| 73 | - $request->setOptsIntoDonationReceipt( true ); |
|
| 71 | + $request->setTrackingInfo($this->newTrackingInfo()); |
|
| 72 | + $request->setPiwikTrackingString('foo/bar'); |
|
| 73 | + $request->setOptsIntoDonationReceipt(true); |
|
| 74 | 74 | |
| 75 | 75 | return $request->assertNoNullFields()->freeze(); |
| 76 | 76 | } |
@@ -78,11 +78,11 @@ discard block |
||
| 78 | 78 | private function newValidBankData(): BankData { |
| 79 | 79 | $bankData = new BankData(); |
| 80 | 80 | |
| 81 | - $bankData->setIban( new Iban( ValidMembershipApplication::PAYMENT_IBAN ) ); |
|
| 82 | - $bankData->setBic( ValidMembershipApplication::PAYMENT_BIC ); |
|
| 83 | - $bankData->setAccount( ValidMembershipApplication::PAYMENT_BANK_ACCOUNT ); |
|
| 84 | - $bankData->setBankCode( ValidMembershipApplication::PAYMENT_BANK_CODE ); |
|
| 85 | - $bankData->setBankName( ValidMembershipApplication::PAYMENT_BANK_NAME ); |
|
| 81 | + $bankData->setIban(new Iban(ValidMembershipApplication::PAYMENT_IBAN)); |
|
| 82 | + $bankData->setBic(ValidMembershipApplication::PAYMENT_BIC); |
|
| 83 | + $bankData->setAccount(ValidMembershipApplication::PAYMENT_BANK_ACCOUNT); |
|
| 84 | + $bankData->setBankCode(ValidMembershipApplication::PAYMENT_BANK_CODE); |
|
| 85 | + $bankData->setBankName(ValidMembershipApplication::PAYMENT_BANK_NAME); |
|
| 86 | 86 | |
| 87 | 87 | return $bankData->assertNoNullFields()->freeze(); |
| 88 | 88 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | ); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - private function assertIsExpectedCompanyPersonName( ApplicantName $name ): void { |
|
| 97 | + private function assertIsExpectedCompanyPersonName(ApplicantName $name): void { |
|
| 98 | 98 | $this->assertEquals( |
| 99 | 99 | $this->getCompanyPersonName(), |
| 100 | 100 | $name |
@@ -104,16 +104,16 @@ discard block |
||
| 104 | 104 | private function getCompanyPersonName(): ApplicantName { |
| 105 | 105 | $name = ApplicantName::newCompanyName(); |
| 106 | 106 | |
| 107 | - $name->setCompanyName( self::COMPANY_NAME ); |
|
| 108 | - $name->setSalutation( ApplicantName::COMPANY_SALUTATION ); |
|
| 109 | - $name->setTitle( '' ); |
|
| 110 | - $name->setFirstName( '' ); |
|
| 111 | - $name->setLastName( '' ); |
|
| 107 | + $name->setCompanyName(self::COMPANY_NAME); |
|
| 108 | + $name->setSalutation(ApplicantName::COMPANY_SALUTATION); |
|
| 109 | + $name->setTitle(''); |
|
| 110 | + $name->setFirstName(''); |
|
| 111 | + $name->setLastName(''); |
|
| 112 | 112 | |
| 113 | 113 | return $name->assertNoNullFields()->freeze(); |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - private function assertIsExpectedAddress( ApplicantAddress $address ): void { |
|
| 116 | + private function assertIsExpectedAddress(ApplicantAddress $address): void { |
|
| 117 | 117 | $this->assertEquals( |
| 118 | 118 | $this->getPhysicalAddress(), |
| 119 | 119 | $address |
@@ -123,34 +123,34 @@ discard block |
||
| 123 | 123 | private function getPhysicalAddress(): ApplicantAddress { |
| 124 | 124 | $address = new ApplicantAddress(); |
| 125 | 125 | |
| 126 | - $address->setStreetAddress( ValidMembershipApplication::APPLICANT_STREET_ADDRESS ); |
|
| 127 | - $address->setPostalCode( ValidMembershipApplication::APPLICANT_POSTAL_CODE ); |
|
| 128 | - $address->setCity( ValidMembershipApplication::APPLICANT_CITY ); |
|
| 129 | - $address->setCountryCode( ValidMembershipApplication::APPLICANT_COUNTRY_CODE ); |
|
| 126 | + $address->setStreetAddress(ValidMembershipApplication::APPLICANT_STREET_ADDRESS); |
|
| 127 | + $address->setPostalCode(ValidMembershipApplication::APPLICANT_POSTAL_CODE); |
|
| 128 | + $address->setCity(ValidMembershipApplication::APPLICANT_CITY); |
|
| 129 | + $address->setCountryCode(ValidMembershipApplication::APPLICANT_COUNTRY_CODE); |
|
| 130 | 130 | |
| 131 | 131 | return $address->assertNoNullFields()->freeze(); |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | public function testWhenNoBirthDateAndPhoneNumberIsGiven_membershipApplicationIsStillBuiltCorrectly(): void { |
| 135 | - $request = $this->newCompanyMembershipRequest( self::OMIT_OPTIONAL_FIELDS ); |
|
| 135 | + $request = $this->newCompanyMembershipRequest(self::OMIT_OPTIONAL_FIELDS); |
|
| 136 | 136 | |
| 137 | - $application = ( new MembershipApplicationBuilder() )->newApplicationFromRequest( $request ); |
|
| 137 | + $application = (new MembershipApplicationBuilder())->newApplicationFromRequest($request); |
|
| 138 | 138 | |
| 139 | - $this->assertIsExpectedCompanyPersonName( $application->getApplicant()->getName() ); |
|
| 140 | - $this->assertIsExpectedAddress( $application->getApplicant()->getPhysicalAddress() ); |
|
| 139 | + $this->assertIsExpectedCompanyPersonName($application->getApplicant()->getName()); |
|
| 140 | + $this->assertIsExpectedAddress($application->getApplicant()->getPhysicalAddress()); |
|
| 141 | 141 | |
| 142 | 142 | $this->assertEquals( |
| 143 | - Euro::newFromInt( ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO ), |
|
| 143 | + Euro::newFromInt(ValidMembershipApplication::PAYMENT_AMOUNT_IN_EURO), |
|
| 144 | 144 | $application->getPayment()->getAmount() |
| 145 | 145 | ); |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | public function testWhenBuildingCompanyApplication_salutationFieldIsSet(): void { |
| 149 | - $request = $this->newCompanyMembershipRequest( self::OMIT_OPTIONAL_FIELDS ); |
|
| 149 | + $request = $this->newCompanyMembershipRequest(self::OMIT_OPTIONAL_FIELDS); |
|
| 150 | 150 | |
| 151 | - $application = ( new MembershipApplicationBuilder() )->newApplicationFromRequest( $request ); |
|
| 151 | + $application = (new MembershipApplicationBuilder())->newApplicationFromRequest($request); |
|
| 152 | 152 | |
| 153 | - $this->assertSame( ApplicantName::COMPANY_SALUTATION, $application->getApplicant()->getName()->getSalutation() ); |
|
| 153 | + $this->assertSame(ApplicantName::COMPANY_SALUTATION, $application->getApplicant()->getName()->getSalutation()); |
|
| 154 | 154 | } |
| 155 | 155 | |
| 156 | 156 | } |
@@ -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\Domain\Model; |
| 6 | 6 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | private $isDeleted; |
| 44 | 44 | private $donationReceipt; |
| 45 | 45 | |
| 46 | - public static function newApplication( string $type, Applicant $applicant, Payment $payment, ?bool $donationReceipt ): self { |
|
| 46 | + public static function newApplication(string $type, Applicant $applicant, Payment $payment, ?bool $donationReceipt) : self { |
|
| 47 | 47 | return new self( |
| 48 | 48 | null, |
| 49 | 49 | $type, |
@@ -57,8 +57,8 @@ discard block |
||
| 57 | 57 | ); |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - public function __construct( ?int $id, string $type, Applicant $applicant, Payment $payment, |
|
| 61 | - bool $needsModeration, bool $isCancelled, bool $isConfirmed, bool $isDeleted, ?bool $donationReceipt ) { |
|
| 60 | + public function __construct(?int $id, string $type, Applicant $applicant, Payment $payment, |
|
| 61 | + bool $needsModeration, bool $isCancelled, bool $isConfirmed, bool $isDeleted, ?bool $donationReceipt) { |
|
| 62 | 62 | $this->id = $id; |
| 63 | 63 | $this->type = $type; |
| 64 | 64 | $this->applicant = $applicant; |
@@ -98,9 +98,9 @@ discard block |
||
| 98 | 98 | * @param int $id |
| 99 | 99 | * @throws \RuntimeException |
| 100 | 100 | */ |
| 101 | - public function assignId( int $id ): void { |
|
| 102 | - if ( $this->id !== null && $this->id !== $id ) { |
|
| 103 | - throw new \RuntimeException( 'Id cannot be changed after initial assignment' ); |
|
| 101 | + public function assignId(int $id): void { |
|
| 102 | + if ($this->id !== null && $this->id !== $id) { |
|
| 103 | + throw new \RuntimeException('Id cannot be changed after initial assignment'); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $this->id = $id; |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | |
| 133 | 133 | public function confirmSubscriptionCreated(): void { |
| 134 | - if ( !$this->hasExternalPayment() ) { |
|
| 135 | - throw new RuntimeException( 'Only external payments can be confirmed as booked' ); |
|
| 134 | + if (!$this->hasExternalPayment()) { |
|
| 135 | + throw new RuntimeException('Only external payments can be confirmed as booked'); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - if ( !$this->statusAllowsForBooking() ) { |
|
| 139 | - throw new RuntimeException( 'Only unconfirmed membership applications can be confirmed as booked' ); |
|
| 138 | + if (!$this->statusAllowsForBooking()) { |
|
| 139 | + throw new RuntimeException('Only unconfirmed membership applications can be confirmed as booked'); |
|
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | $this->confirm(); |
@@ -158,11 +158,11 @@ discard block |
||
| 158 | 158 | return $this->isDeleted; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function notifyOfFirstPaymentDate( string $firstPaymentDate ): void { |
|
| 161 | + public function notifyOfFirstPaymentDate(string $firstPaymentDate): void { |
|
| 162 | 162 | $paymentMethod = $this->getPayment()->getPaymentMethod(); |
| 163 | 163 | |
| 164 | - if ( $paymentMethod instanceof PayPalPayment ) { |
|
| 165 | - $paymentMethod->getPayPalData()->setFirstPaymentDate( $firstPaymentDate ); |
|
| 164 | + if ($paymentMethod instanceof PayPalPayment) { |
|
| 165 | + $paymentMethod->getPayPalData()->setFirstPaymentDate($firstPaymentDate); |
|
| 166 | 166 | } |
| 167 | 167 | } |
| 168 | 168 | |
@@ -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\UseCases\ApplyForMembership; |
| 6 | 6 | |
@@ -26,77 +26,77 @@ discard block |
||
| 26 | 26 | |
| 27 | 27 | const COMPANY_APPLICANT_TYPE = 'firma'; |
| 28 | 28 | |
| 29 | - public function newApplicationFromRequest( ApplyForMembershipRequest $request ): Application { |
|
| 29 | + public function newApplicationFromRequest(ApplyForMembershipRequest $request): Application { |
|
| 30 | 30 | return Application::newApplication( |
| 31 | 31 | $request->getMembershipType(), |
| 32 | - $this->newApplicant( $request ), |
|
| 33 | - $this->newPayment( $request ), |
|
| 32 | + $this->newApplicant($request), |
|
| 33 | + $this->newPayment($request), |
|
| 34 | 34 | $request->getOptsIntoDonationReceipt() |
| 35 | 35 | ); |
| 36 | 36 | } |
| 37 | 37 | |
| 38 | - private function newApplicant( ApplyForMembershipRequest $request ): Applicant { |
|
| 38 | + private function newApplicant(ApplyForMembershipRequest $request): Applicant { |
|
| 39 | 39 | return new Applicant( |
| 40 | - $this->newPersonName( $request ), |
|
| 41 | - $this->newAddress( $request ), |
|
| 42 | - new EmailAddress( $request->getApplicantEmailAddress() ), |
|
| 43 | - new PhoneNumber( $request->getApplicantPhoneNumber() ), |
|
| 44 | - ( $request->getApplicantDateOfBirth() === '' ) ? null : new \DateTime( $request->getApplicantDateOfBirth() ) |
|
| 40 | + $this->newPersonName($request), |
|
| 41 | + $this->newAddress($request), |
|
| 42 | + new EmailAddress($request->getApplicantEmailAddress()), |
|
| 43 | + new PhoneNumber($request->getApplicantPhoneNumber()), |
|
| 44 | + ($request->getApplicantDateOfBirth() === '') ? null : new \DateTime($request->getApplicantDateOfBirth()) |
|
| 45 | 45 | ); |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - private function newPersonName( ApplyForMembershipRequest $request ): ApplicantName { |
|
| 49 | - if ( $request->isCompanyApplication() ) { |
|
| 50 | - return $this->newCompanyPersonName( $request ); |
|
| 48 | + private function newPersonName(ApplyForMembershipRequest $request): ApplicantName { |
|
| 49 | + if ($request->isCompanyApplication()) { |
|
| 50 | + return $this->newCompanyPersonName($request); |
|
| 51 | 51 | } else { |
| 52 | - return $this->newPrivatePersonName( $request ); |
|
| 52 | + return $this->newPrivatePersonName($request); |
|
| 53 | 53 | } |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - private function newPrivatePersonName( ApplyForMembershipRequest $request ): ApplicantName { |
|
| 56 | + private function newPrivatePersonName(ApplyForMembershipRequest $request): ApplicantName { |
|
| 57 | 57 | $personName = ApplicantName::newPrivatePersonName(); |
| 58 | - $personName->setFirstName( $request->getApplicantFirstName() ); |
|
| 59 | - $personName->setLastName( $request->getApplicantLastName() ); |
|
| 60 | - $personName->setSalutation( $request->getApplicantSalutation() ); |
|
| 61 | - $personName->setTitle( $request->getApplicantTitle() ); |
|
| 58 | + $personName->setFirstName($request->getApplicantFirstName()); |
|
| 59 | + $personName->setLastName($request->getApplicantLastName()); |
|
| 60 | + $personName->setSalutation($request->getApplicantSalutation()); |
|
| 61 | + $personName->setTitle($request->getApplicantTitle()); |
|
| 62 | 62 | return $personName->freeze()->assertNoNullFields(); |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - private function newCompanyPersonName( ApplyForMembershipRequest $request ): ApplicantName { |
|
| 65 | + private function newCompanyPersonName(ApplyForMembershipRequest $request): ApplicantName { |
|
| 66 | 66 | $personName = ApplicantName::newCompanyName(); |
| 67 | - $personName->setCompanyName( $request->getApplicantCompanyName() ); |
|
| 67 | + $personName->setCompanyName($request->getApplicantCompanyName()); |
|
| 68 | 68 | return $personName->freeze()->assertNoNullFields(); |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - private function newAddress( ApplyForMembershipRequest $request ): ApplicantAddress { |
|
| 71 | + private function newAddress(ApplyForMembershipRequest $request): ApplicantAddress { |
|
| 72 | 72 | $address = new ApplicantAddress(); |
| 73 | 73 | |
| 74 | - $address->setCity( $request->getApplicantCity() ); |
|
| 75 | - $address->setCountryCode( $request->getApplicantCountryCode() ); |
|
| 76 | - $address->setPostalCode( $request->getApplicantPostalCode() ); |
|
| 77 | - $address->setStreetAddress( $request->getApplicantStreetAddress() ); |
|
| 74 | + $address->setCity($request->getApplicantCity()); |
|
| 75 | + $address->setCountryCode($request->getApplicantCountryCode()); |
|
| 76 | + $address->setPostalCode($request->getApplicantPostalCode()); |
|
| 77 | + $address->setStreetAddress($request->getApplicantStreetAddress()); |
|
| 78 | 78 | |
| 79 | 79 | return $address->freeze()->assertNoNullFields(); |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - private function newPayment( ApplyForMembershipRequest $request ): Payment { |
|
| 82 | + private function newPayment(ApplyForMembershipRequest $request): Payment { |
|
| 83 | 83 | return new Payment( |
| 84 | 84 | $request->getPaymentIntervalInMonths(), |
| 85 | - Euro::newFromString( $request->getPaymentAmountInEuros() ), |
|
| 86 | - $this->newPaymentMethod( $request ) |
|
| 85 | + Euro::newFromString($request->getPaymentAmountInEuros()), |
|
| 86 | + $this->newPaymentMethod($request) |
|
| 87 | 87 | ); |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - private function newPaymentMethod( ApplyForMembershipRequest $request ): PaymentMethod { |
|
| 91 | - if ( $request->getPaymentType() === PaymentType::DIRECT_DEBIT ) { |
|
| 92 | - return new DirectDebitPayment( $request->getBankData() ); |
|
| 90 | + private function newPaymentMethod(ApplyForMembershipRequest $request): PaymentMethod { |
|
| 91 | + if ($request->getPaymentType() === PaymentType::DIRECT_DEBIT) { |
|
| 92 | + return new DirectDebitPayment($request->getBankData()); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - if ( $request->getPaymentType() === PaymentType::PAYPAL ) { |
|
| 96 | - return new PayPalPayment( new PayPalData() ); |
|
| 95 | + if ($request->getPaymentType() === PaymentType::PAYPAL) { |
|
| 96 | + return new PayPalPayment(new PayPalData()); |
|
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - throw new \RuntimeException( 'Unsupported payment type' ); |
|
| 99 | + throw new \RuntimeException('Unsupported payment type'); |
|
| 100 | 100 | } |
| 101 | 101 | |
| 102 | 102 | } |
@@ -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\UseCases\ApplyForMembership; |
| 6 | 6 | |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | return $this->membershipType; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | - public function setMembershipType( string $membershipType ): void { |
|
| 50 | + public function setMembershipType(string $membershipType): void { |
|
| 51 | 51 | $this->assertIsWritable(); |
| 52 | 52 | $this->membershipType = $membershipType; |
| 53 | 53 | } |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | return $this->applicantCompanyName; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - public function setApplicantCompanyName( string $applicantCompanyName ): void { |
|
| 71 | + public function setApplicantCompanyName(string $applicantCompanyName): void { |
|
| 72 | 72 | $this->applicantCompanyName = $applicantCompanyName; |
| 73 | 73 | } |
| 74 | 74 | |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | return $this->applicantSalutation; |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - public function setApplicantSalutation( string $applicantSalutation ): void { |
|
| 79 | + public function setApplicantSalutation(string $applicantSalutation): void { |
|
| 80 | 80 | $this->assertIsWritable(); |
| 81 | 81 | $this->applicantSalutation = $applicantSalutation; |
| 82 | 82 | } |
@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | return $this->applicantTitle; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | - public function setApplicantTitle( string $applicantTitle ): void { |
|
| 88 | + public function setApplicantTitle(string $applicantTitle): void { |
|
| 89 | 89 | $this->assertIsWritable(); |
| 90 | 90 | $this->applicantTitle = $applicantTitle; |
| 91 | 91 | } |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | return $this->applicantFirstName; |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - public function setApplicantFirstName( string $applicantFirstName ): void { |
|
| 97 | + public function setApplicantFirstName(string $applicantFirstName): void { |
|
| 98 | 98 | $this->assertIsWritable(); |
| 99 | 99 | $this->applicantFirstName = $applicantFirstName; |
| 100 | 100 | } |
@@ -103,7 +103,7 @@ discard block |
||
| 103 | 103 | return $this->applicantLastName; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | - public function setApplicantLastName( string $applicantLastName ): void { |
|
| 106 | + public function setApplicantLastName(string $applicantLastName): void { |
|
| 107 | 107 | $this->assertIsWritable(); |
| 108 | 108 | $this->applicantLastName = $applicantLastName; |
| 109 | 109 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | return $this->applicantStreetAddress; |
| 113 | 113 | } |
| 114 | 114 | |
| 115 | - public function setApplicantStreetAddress( string $applicantStreetAddress ): void { |
|
| 115 | + public function setApplicantStreetAddress(string $applicantStreetAddress): void { |
|
| 116 | 116 | $this->assertIsWritable(); |
| 117 | 117 | $this->applicantStreetAddress = $applicantStreetAddress; |
| 118 | 118 | } |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $this->applicantPostalCode; |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - public function setApplicantPostalCode( string $applicantPostalCode ): void { |
|
| 124 | + public function setApplicantPostalCode(string $applicantPostalCode): void { |
|
| 125 | 125 | $this->assertIsWritable(); |
| 126 | 126 | $this->applicantPostalCode = $applicantPostalCode; |
| 127 | 127 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | return $this->applicantCity; |
| 131 | 131 | } |
| 132 | 132 | |
| 133 | - public function setApplicantCity( string $applicantCity ): void { |
|
| 133 | + public function setApplicantCity(string $applicantCity): void { |
|
| 134 | 134 | $this->assertIsWritable(); |
| 135 | 135 | $this->applicantCity = $applicantCity; |
| 136 | 136 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | return $this->applicantCountryCode; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public function setApplicantCountryCode( string $applicantCountryCode ): void { |
|
| 142 | + public function setApplicantCountryCode(string $applicantCountryCode): void { |
|
| 143 | 143 | $this->assertIsWritable(); |
| 144 | 144 | $this->applicantCountryCode = $applicantCountryCode; |
| 145 | 145 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | return $this->applicantEmailAddress; |
| 149 | 149 | } |
| 150 | 150 | |
| 151 | - public function setApplicantEmailAddress( string $applicantEmailAddress ): void { |
|
| 151 | + public function setApplicantEmailAddress(string $applicantEmailAddress): void { |
|
| 152 | 152 | $this->assertIsWritable(); |
| 153 | 153 | $this->applicantEmailAddress = $applicantEmailAddress; |
| 154 | 154 | } |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | return $this->applicantPhoneNumber; |
| 158 | 158 | } |
| 159 | 159 | |
| 160 | - public function setApplicantPhoneNumber( string $applicantPhoneNumber ): void { |
|
| 160 | + public function setApplicantPhoneNumber(string $applicantPhoneNumber): void { |
|
| 161 | 161 | $this->assertIsWritable(); |
| 162 | 162 | $this->applicantPhoneNumber = $applicantPhoneNumber; |
| 163 | 163 | } |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | return $this->applicantDateOfBirth; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function setApplicantDateOfBirth( string $applicantDateOfBirth ): void { |
|
| 169 | + public function setApplicantDateOfBirth(string $applicantDateOfBirth): void { |
|
| 170 | 170 | $this->assertIsWritable(); |
| 171 | 171 | $this->applicantDateOfBirth = $applicantDateOfBirth; |
| 172 | 172 | } |
@@ -175,7 +175,7 @@ discard block |
||
| 175 | 175 | return $this->paymentIntervalInMonths; |
| 176 | 176 | } |
| 177 | 177 | |
| 178 | - public function setPaymentIntervalInMonths( int $paymentIntervalInMonths ): void { |
|
| 178 | + public function setPaymentIntervalInMonths(int $paymentIntervalInMonths): void { |
|
| 179 | 179 | $this->assertIsWritable(); |
| 180 | 180 | $this->paymentIntervalInMonths = $paymentIntervalInMonths; |
| 181 | 181 | } |
@@ -184,7 +184,7 @@ discard block |
||
| 184 | 184 | return $this->paymentAmount; |
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - public function setPaymentAmountInEuros( string $paymentAmount ): void { |
|
| 187 | + public function setPaymentAmountInEuros(string $paymentAmount): void { |
|
| 188 | 188 | $this->assertIsWritable(); |
| 189 | 189 | $this->paymentAmount = $paymentAmount; |
| 190 | 190 | } |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | return $this->bankData; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - public function setBankData( BankData $bankData ): void { |
|
| 196 | + public function setBankData(BankData $bankData): void { |
|
| 197 | 197 | $this->assertIsWritable(); |
| 198 | 198 | $this->bankData = $bankData; |
| 199 | 199 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | return $this->trackingInfo; |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | - public function setTrackingInfo( MembershipApplicationTrackingInfo $trackingInfo ): void { |
|
| 205 | + public function setTrackingInfo(MembershipApplicationTrackingInfo $trackingInfo): void { |
|
| 206 | 206 | $this->assertIsWritable(); |
| 207 | 207 | $this->trackingInfo = $trackingInfo; |
| 208 | 208 | } |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | return $this->piwikTrackingString; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public function setPiwikTrackingString( string $piwikTrackingString ): void { |
|
| 214 | + public function setPiwikTrackingString(string $piwikTrackingString): void { |
|
| 215 | 215 | $this->assertIsWritable(); |
| 216 | 216 | $this->piwikTrackingString = $piwikTrackingString; |
| 217 | 217 | } |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | return $this->paymentType; |
| 221 | 221 | } |
| 222 | 222 | |
| 223 | - public function setPaymentType( string $paymentType ): void { |
|
| 223 | + public function setPaymentType(string $paymentType): void { |
|
| 224 | 224 | $this->assertIsWritable(); |
| 225 | 225 | $this->paymentType = $paymentType; |
| 226 | 226 | } |
@@ -229,7 +229,7 @@ discard block |
||
| 229 | 229 | return $this->optsIntoDonationReceipt; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - public function setOptsIntoDonationReceipt( bool $optIn ): void { |
|
| 232 | + public function setOptsIntoDonationReceipt(bool $optIn): void { |
|
| 233 | 233 | $this->assertIsWritable(); |
| 234 | 234 | $this->optsIntoDonationReceipt = $optIn; |
| 235 | 235 | } |
@@ -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\UseCases\HandleSubscriptionPaymentNotification; |
| 6 | 6 | |
@@ -29,8 +29,8 @@ discard block |
||
| 29 | 29 | private $mailer; |
| 30 | 30 | private $logger; |
| 31 | 31 | |
| 32 | - public function __construct( ApplicationRepository $repository, ApplicationAuthorizer $authorizationService, |
|
| 33 | - TemplateMailerInterface $mailer, LoggerInterface $logger ) { |
|
| 32 | + public function __construct(ApplicationRepository $repository, ApplicationAuthorizer $authorizationService, |
|
| 33 | + TemplateMailerInterface $mailer, LoggerInterface $logger) { |
|
| 34 | 34 | |
| 35 | 35 | $this->repository = $repository; |
| 36 | 36 | $this->authorizationService = $authorizationService; |
@@ -38,108 +38,108 @@ discard block |
||
| 38 | 38 | $this->logger = $logger; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function handleNotification( PayPalPaymentNotificationRequest $request ): PaypalNotificationResponse { |
|
| 41 | + public function handleNotification(PayPalPaymentNotificationRequest $request): PaypalNotificationResponse { |
|
| 42 | 42 | try { |
| 43 | - $membershipApplication = $this->repository->getApplicationById( $request->getInternalId() ); |
|
| 44 | - } catch ( GetMembershipApplicationException $ex ) { |
|
| 45 | - return $this->createErrorResponse( $ex ); |
|
| 43 | + $membershipApplication = $this->repository->getApplicationById($request->getInternalId()); |
|
| 44 | + } catch (GetMembershipApplicationException $ex) { |
|
| 45 | + return $this->createErrorResponse($ex); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - if ( $membershipApplication === null ) { |
|
| 49 | - return $this->createUnhandledResponse( 'specified data set could not be found' ); |
|
| 48 | + if ($membershipApplication === null) { |
|
| 49 | + return $this->createUnhandledResponse('specified data set could not be found'); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | - return $this->handleRequestForPayment( $request, $membershipApplication ); |
|
| 52 | + return $this->handleRequestForPayment($request, $membershipApplication); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - private function handleRequestForPayment( PayPalPaymentNotificationRequest $request, |
|
| 56 | - Application $application ): PaypalNotificationResponse { |
|
| 57 | - if ( !( $application->getPayment()->getPaymentMethod() instanceof PayPalPayment ) ) { |
|
| 58 | - return $this->createUnhandledResponse( 'Trying to handle IPN for non-PayPal membership application' ); |
|
| 55 | + private function handleRequestForPayment(PayPalPaymentNotificationRequest $request, |
|
| 56 | + Application $application): PaypalNotificationResponse { |
|
| 57 | + if (!($application->getPayment()->getPaymentMethod() instanceof PayPalPayment)) { |
|
| 58 | + return $this->createUnhandledResponse('Trying to handle IPN for non-PayPal membership application'); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if ( !$this->authorizationService->canModifyApplication( $request->getInternalId() ) ) { |
|
| 62 | - return $this->createUnhandledResponse( 'Wrong access code for membership application' ); |
|
| 61 | + if (!$this->authorizationService->canModifyApplication($request->getInternalId())) { |
|
| 62 | + return $this->createUnhandledResponse('Wrong access code for membership application'); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - if ( $this->transactionAlreadyProcessed( $application, $request ) ) { |
|
| 66 | - return $this->createUnhandledResponse( 'Trying to handle IPN for already processed transaction' ); |
|
| 65 | + if ($this->transactionAlreadyProcessed($application, $request)) { |
|
| 66 | + return $this->createUnhandledResponse('Trying to handle IPN for already processed transaction'); |
|
| 67 | 67 | } |
| 68 | 68 | |
| 69 | - $childApplication = $this->createChildApplication( $application, $request ); |
|
| 69 | + $childApplication = $this->createChildApplication($application, $request); |
|
| 70 | 70 | |
| 71 | 71 | /** @var \WMDE\Fundraising\Frontend\PaymentContext\Domain\Model\PayPalPayment $payment */ |
| 72 | 72 | $payment = $application->getPayment()->getPaymentMethod(); |
| 73 | - $payment->getPayPalData()->addChildPayment( $request->getTransactionId(), $childApplication->getId() ); |
|
| 73 | + $payment->getPayPalData()->addChildPayment($request->getTransactionId(), $childApplication->getId()); |
|
| 74 | 74 | |
| 75 | 75 | try { |
| 76 | - $this->repository->storeApplication( $application ); |
|
| 76 | + $this->repository->storeApplication($application); |
|
| 77 | 77 | } |
| 78 | - catch ( StoreMembershipApplicationException $ex ) { |
|
| 79 | - $this->createErrorResponse( $ex ); |
|
| 78 | + catch (StoreMembershipApplicationException $ex) { |
|
| 79 | + $this->createErrorResponse($ex); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | 82 | return PaypalNotificationResponse::newSuccessResponse(); |
| 83 | 83 | } |
| 84 | 84 | |
| 85 | - private function createUnhandledResponse( string $reason ): PaypalNotificationResponse { |
|
| 86 | - return PaypalNotificationResponse::newUnhandledResponse( [ |
|
| 85 | + private function createUnhandledResponse(string $reason): PaypalNotificationResponse { |
|
| 86 | + return PaypalNotificationResponse::newUnhandledResponse([ |
|
| 87 | 87 | 'message' => $reason |
| 88 | - ] ); |
|
| 88 | + ]); |
|
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - private function createErrorResponse( \Exception $ex ): PaypalNotificationResponse { |
|
| 92 | - return PaypalNotificationResponse::newFailureResponse( [ |
|
| 91 | + private function createErrorResponse(\Exception $ex): PaypalNotificationResponse { |
|
| 92 | + return PaypalNotificationResponse::newFailureResponse([ |
|
| 93 | 93 | 'message' => $ex->getMessage(), |
| 94 | 94 | 'stackTrace' => $ex->getTraceAsString() |
| 95 | - ] ); |
|
| 95 | + ]); |
|
| 96 | 96 | } |
| 97 | - private function newPayPalDataFromRequest( PayPalPaymentNotificationRequest $request ): PayPalData { |
|
| 98 | - return ( new PayPalData() ) |
|
| 99 | - ->setPayerId( $request->getPayerId() ) |
|
| 100 | - ->setSubscriberId( $request->getSubscriptionId() ) |
|
| 101 | - ->setPayerStatus( $request->getPayerStatus() ) |
|
| 102 | - ->setAddressStatus( $request->getPayerAddressStatus() ) |
|
| 103 | - ->setAmount( $request->getAmountGross() ) |
|
| 104 | - ->setCurrencyCode( $request->getCurrencyCode() ) |
|
| 105 | - ->setFee( Euro::newFromString( $request->getTransactionFee() ) ) |
|
| 106 | - ->setSettleAmount( $request->getSettleAmount() ) |
|
| 107 | - ->setFirstName( $request->getPayerFirstName() ) |
|
| 108 | - ->setLastName( $request->getPayerLastName() ) |
|
| 109 | - ->setAddressName( $request->getPayerAddressName() ) |
|
| 110 | - ->setPaymentId( $request->getTransactionId() ) |
|
| 111 | - ->setPaymentType( $request->getPaymentType() ) |
|
| 112 | - ->setPaymentStatus( implode( '/', [ $request->getPaymentStatus(), $request->getTransactionType() ] ) ) |
|
| 113 | - ->setPaymentTimestamp( $request->getPaymentTimestamp() ); |
|
| 97 | + private function newPayPalDataFromRequest(PayPalPaymentNotificationRequest $request): PayPalData { |
|
| 98 | + return (new PayPalData()) |
|
| 99 | + ->setPayerId($request->getPayerId()) |
|
| 100 | + ->setSubscriberId($request->getSubscriptionId()) |
|
| 101 | + ->setPayerStatus($request->getPayerStatus()) |
|
| 102 | + ->setAddressStatus($request->getPayerAddressStatus()) |
|
| 103 | + ->setAmount($request->getAmountGross()) |
|
| 104 | + ->setCurrencyCode($request->getCurrencyCode()) |
|
| 105 | + ->setFee(Euro::newFromString($request->getTransactionFee())) |
|
| 106 | + ->setSettleAmount($request->getSettleAmount()) |
|
| 107 | + ->setFirstName($request->getPayerFirstName()) |
|
| 108 | + ->setLastName($request->getPayerLastName()) |
|
| 109 | + ->setAddressName($request->getPayerAddressName()) |
|
| 110 | + ->setPaymentId($request->getTransactionId()) |
|
| 111 | + ->setPaymentType($request->getPaymentType()) |
|
| 112 | + ->setPaymentStatus(implode('/', [$request->getPaymentStatus(), $request->getTransactionType()])) |
|
| 113 | + ->setPaymentTimestamp($request->getPaymentTimestamp()); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - private function createChildApplication( Application $application, PayPalPaymentNotificationRequest $request ): ?Application { |
|
| 116 | + private function createChildApplication(Application $application, PayPalPaymentNotificationRequest $request): ?Application { |
|
| 117 | 117 | $childApplication = Application::newApplication( |
| 118 | 118 | $application->getType(), |
| 119 | 119 | $application->getApplicant(), |
| 120 | 120 | new Payment( |
| 121 | 121 | $application->getPayment()->getIntervalInMonths(), |
| 122 | 122 | $application->getPayment()->getAmount(), |
| 123 | - new PayPalPayment( $this->newPayPalDataFromRequest( $request ) ) |
|
| 123 | + new PayPalPayment($this->newPayPalDataFromRequest($request)) |
|
| 124 | 124 | ), |
| 125 | 125 | $application->getDonationReceipt() |
| 126 | 126 | ); |
| 127 | 127 | $childApplication->confirm(); |
| 128 | 128 | |
| 129 | 129 | try { |
| 130 | - $this->repository->storeApplication( $childApplication ); |
|
| 130 | + $this->repository->storeApplication($childApplication); |
|
| 131 | 131 | } |
| 132 | - catch ( StoreMembershipApplicationException $ex ) { |
|
| 132 | + catch (StoreMembershipApplicationException $ex) { |
|
| 133 | 133 | return null; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | return $childApplication; |
| 137 | 137 | } |
| 138 | 138 | |
| 139 | - private function transactionAlreadyProcessed( Application $application, PayPalPaymentNotificationRequest $request ): bool { |
|
| 139 | + private function transactionAlreadyProcessed(Application $application, PayPalPaymentNotificationRequest $request): bool { |
|
| 140 | 140 | /** @var PayPalPayment $payment */ |
| 141 | 141 | $payment = $application->getPayment()->getPaymentMethod(); |
| 142 | - return $payment->getPayPalData()->hasChildPayment( $request->getTransactionId() ); |
|
| 142 | + return $payment->getPayPalData()->hasChildPayment($request->getTransactionId()); |
|
| 143 | 143 | } |
| 144 | 144 | |
| 145 | 145 | } |
@@ -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\DataAccess; |
| 6 | 6 | |
@@ -35,108 +35,108 @@ discard block |
||
| 35 | 35 | |
| 36 | 36 | private $entityManager; |
| 37 | 37 | |
| 38 | - public function __construct( EntityManager $entityManager ) { |
|
| 38 | + public function __construct(EntityManager $entityManager) { |
|
| 39 | 39 | $this->entityManager = $entityManager; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function storeApplication( Application $application ): void { |
|
| 43 | - if ( $application->hasId() ) { |
|
| 44 | - $this->updateApplication( $application ); |
|
| 42 | + public function storeApplication(Application $application): void { |
|
| 43 | + if ($application->hasId()) { |
|
| 44 | + $this->updateApplication($application); |
|
| 45 | 45 | } |
| 46 | 46 | else { |
| 47 | - $this->insertApplication( $application ); |
|
| 47 | + $this->insertApplication($application); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - private function insertApplication( Application $application ): void { |
|
| 51 | + private function insertApplication(Application $application): void { |
|
| 52 | 52 | $doctrineApplication = new DoctrineApplication(); |
| 53 | - $this->updateDoctrineApplication( $doctrineApplication, $application ); |
|
| 53 | + $this->updateDoctrineApplication($doctrineApplication, $application); |
|
| 54 | 54 | |
| 55 | 55 | try { |
| 56 | - $this->entityManager->persist( $doctrineApplication ); |
|
| 56 | + $this->entityManager->persist($doctrineApplication); |
|
| 57 | 57 | $this->entityManager->flush(); |
| 58 | 58 | } |
| 59 | - catch ( ORMException $ex ) { |
|
| 60 | - throw new StoreMembershipApplicationException( $ex ); |
|
| 59 | + catch (ORMException $ex) { |
|
| 60 | + throw new StoreMembershipApplicationException($ex); |
|
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - $application->assignId( $doctrineApplication->getId() ); |
|
| 63 | + $application->assignId($doctrineApplication->getId()); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - private function updateApplication( Application $application ): void { |
|
| 67 | - $doctrineApplication = $this->getDoctrineApplicationById( $application->getId() ); |
|
| 66 | + private function updateApplication(Application $application): void { |
|
| 67 | + $doctrineApplication = $this->getDoctrineApplicationById($application->getId()); |
|
| 68 | 68 | |
| 69 | - if ( $doctrineApplication === null ) { |
|
| 69 | + if ($doctrineApplication === null) { |
|
| 70 | 70 | throw new StoreMembershipApplicationException(); |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - $this->updateDoctrineApplication( $doctrineApplication, $application ); |
|
| 73 | + $this->updateDoctrineApplication($doctrineApplication, $application); |
|
| 74 | 74 | |
| 75 | 75 | try { |
| 76 | - $this->entityManager->persist( $doctrineApplication ); |
|
| 76 | + $this->entityManager->persist($doctrineApplication); |
|
| 77 | 77 | $this->entityManager->flush(); |
| 78 | 78 | } |
| 79 | - catch ( ORMException $ex ) { |
|
| 80 | - throw new StoreMembershipApplicationException( $ex ); |
|
| 79 | + catch (ORMException $ex) { |
|
| 80 | + throw new StoreMembershipApplicationException($ex); |
|
| 81 | 81 | } |
| 82 | 82 | } |
| 83 | 83 | |
| 84 | - private function updateDoctrineApplication( DoctrineApplication $doctrineApplication, Application $application ): void { |
|
| 85 | - $doctrineApplication->setId( $application->getId() ); |
|
| 86 | - $doctrineApplication->setMembershipType( $application->getType() ); |
|
| 84 | + private function updateDoctrineApplication(DoctrineApplication $doctrineApplication, Application $application): void { |
|
| 85 | + $doctrineApplication->setId($application->getId()); |
|
| 86 | + $doctrineApplication->setMembershipType($application->getType()); |
|
| 87 | 87 | |
| 88 | - $this->setApplicantFields( $doctrineApplication, $application->getApplicant() ); |
|
| 89 | - $this->setPaymentFields( $doctrineApplication, $application->getPayment() ); |
|
| 90 | - $doctrineApplication->setDonationReceipt( $application->getDonationReceipt() ); |
|
| 88 | + $this->setApplicantFields($doctrineApplication, $application->getApplicant()); |
|
| 89 | + $this->setPaymentFields($doctrineApplication, $application->getPayment()); |
|
| 90 | + $doctrineApplication->setDonationReceipt($application->getDonationReceipt()); |
|
| 91 | 91 | |
| 92 | - $doctrineStatus = $this->getDoctrineStatus( $application ); |
|
| 93 | - $this->preserveDoctrineStatus( $doctrineApplication, $doctrineStatus ); |
|
| 94 | - $doctrineApplication->setStatus( $doctrineStatus ); |
|
| 92 | + $doctrineStatus = $this->getDoctrineStatus($application); |
|
| 93 | + $this->preserveDoctrineStatus($doctrineApplication, $doctrineStatus); |
|
| 94 | + $doctrineApplication->setStatus($doctrineStatus); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | - private function setApplicantFields( DoctrineApplication $application, Applicant $applicant ): void { |
|
| 98 | - $application->setApplicantFirstName( $applicant->getName()->getFirstName() ); |
|
| 99 | - $application->setApplicantLastName( $applicant->getName()->getLastName() ); |
|
| 100 | - $application->setApplicantSalutation( $applicant->getName()->getSalutation() ); |
|
| 101 | - $application->setApplicantTitle( $applicant->getName()->getTitle() ); |
|
| 102 | - $application->setCompany( $applicant->getName()->getCompanyName() ); |
|
| 97 | + private function setApplicantFields(DoctrineApplication $application, Applicant $applicant): void { |
|
| 98 | + $application->setApplicantFirstName($applicant->getName()->getFirstName()); |
|
| 99 | + $application->setApplicantLastName($applicant->getName()->getLastName()); |
|
| 100 | + $application->setApplicantSalutation($applicant->getName()->getSalutation()); |
|
| 101 | + $application->setApplicantTitle($applicant->getName()->getTitle()); |
|
| 102 | + $application->setCompany($applicant->getName()->getCompanyName()); |
|
| 103 | 103 | |
| 104 | - $application->setApplicantDateOfBirth( $applicant->getDateOfBirth() ); |
|
| 104 | + $application->setApplicantDateOfBirth($applicant->getDateOfBirth()); |
|
| 105 | 105 | |
| 106 | - $application->setApplicantEmailAddress( $applicant->getEmailAddress()->getFullAddress() ); |
|
| 107 | - $application->setApplicantPhoneNumber( $applicant->getPhoneNumber()->__toString() ); |
|
| 106 | + $application->setApplicantEmailAddress($applicant->getEmailAddress()->getFullAddress()); |
|
| 107 | + $application->setApplicantPhoneNumber($applicant->getPhoneNumber()->__toString()); |
|
| 108 | 108 | |
| 109 | 109 | $address = $applicant->getPhysicalAddress(); |
| 110 | 110 | |
| 111 | - $application->setCity( $address->getCity() ); |
|
| 112 | - $application->setCountry( $address->getCountryCode() ); |
|
| 113 | - $application->setPostcode( $address->getPostalCode() ); |
|
| 114 | - $application->setAddress( $address->getStreetAddress() ); |
|
| 111 | + $application->setCity($address->getCity()); |
|
| 112 | + $application->setCountry($address->getCountryCode()); |
|
| 113 | + $application->setPostcode($address->getPostalCode()); |
|
| 114 | + $application->setAddress($address->getStreetAddress()); |
|
| 115 | 115 | } |
| 116 | 116 | |
| 117 | - private function setPaymentFields( DoctrineApplication $application, Payment $payment ): void { |
|
| 118 | - $application->setPaymentIntervalInMonths( $payment->getIntervalInMonths() ); |
|
| 119 | - $application->setPaymentAmount( (int)$payment->getAmount()->getEuroFloat() ); |
|
| 117 | + private function setPaymentFields(DoctrineApplication $application, Payment $payment): void { |
|
| 118 | + $application->setPaymentIntervalInMonths($payment->getIntervalInMonths()); |
|
| 119 | + $application->setPaymentAmount((int)$payment->getAmount()->getEuroFloat()); |
|
| 120 | 120 | $paymentMethod = $payment->getPaymentMethod(); |
| 121 | 121 | |
| 122 | - $application->setPaymentType( $paymentMethod->getType() ); |
|
| 123 | - if ( $paymentMethod instanceof DirectDebitPayment ) { |
|
| 124 | - $this->setBankDataFields( $application, $paymentMethod->getBankData() ); |
|
| 125 | - } elseif ( $paymentMethod instanceof PayPalPayment && $paymentMethod->getPayPalData() != new PayPalData() ) { |
|
| 126 | - $this->setPayPalDataFields( $application, $paymentMethod->getPayPalData() ); |
|
| 122 | + $application->setPaymentType($paymentMethod->getType()); |
|
| 123 | + if ($paymentMethod instanceof DirectDebitPayment) { |
|
| 124 | + $this->setBankDataFields($application, $paymentMethod->getBankData()); |
|
| 125 | + } elseif ($paymentMethod instanceof PayPalPayment && $paymentMethod->getPayPalData() != new PayPalData()) { |
|
| 126 | + $this->setPayPalDataFields($application, $paymentMethod->getPayPalData()); |
|
| 127 | 127 | } |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - private function setBankDataFields( DoctrineApplication $application, BankData $bankData ): void { |
|
| 131 | - $application->setPaymentBankAccount( $bankData->getAccount() ); |
|
| 132 | - $application->setPaymentBankCode( $bankData->getBankCode() ); |
|
| 133 | - $application->setPaymentBankName( $bankData->getBankName() ); |
|
| 134 | - $application->setPaymentBic( $bankData->getBic() ); |
|
| 135 | - $application->setPaymentIban( $bankData->getIban()->toString() ); |
|
| 130 | + private function setBankDataFields(DoctrineApplication $application, BankData $bankData): void { |
|
| 131 | + $application->setPaymentBankAccount($bankData->getAccount()); |
|
| 132 | + $application->setPaymentBankCode($bankData->getBankCode()); |
|
| 133 | + $application->setPaymentBankName($bankData->getBankName()); |
|
| 134 | + $application->setPaymentBic($bankData->getBic()); |
|
| 135 | + $application->setPaymentIban($bankData->getIban()->toString()); |
|
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - private function setPayPalDataFields( DoctrineApplication $application, PayPalData $payPalData ): void { |
|
| 139 | - $application->encodeAndSetData( array_merge( |
|
| 138 | + private function setPayPalDataFields(DoctrineApplication $application, PayPalData $payPalData): void { |
|
| 139 | + $application->encodeAndSetData(array_merge( |
|
| 140 | 140 | $application->getDecodedData(), |
| 141 | 141 | [ |
| 142 | 142 | 'paypal_payer_id' => $payPalData->getPayerId(), |
@@ -158,43 +158,43 @@ discard block |
||
| 158 | 158 | 'ext_payment_timestamp' => $payPalData->getPaymentTimestamp(), |
| 159 | 159 | 'first_payment_date' => $payPalData->getFirstPaymentDate() |
| 160 | 160 | ] |
| 161 | - ) ); |
|
| 161 | + )); |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | - private function getDoctrineStatus( Application $application ): int { |
|
| 164 | + private function getDoctrineStatus(Application $application): int { |
|
| 165 | 165 | $status = DoctrineApplication::STATUS_NEUTRAL; |
| 166 | 166 | |
| 167 | - if ( $application->needsModeration() ) { |
|
| 167 | + if ($application->needsModeration()) { |
|
| 168 | 168 | $status += DoctrineApplication::STATUS_MODERATION; |
| 169 | 169 | } |
| 170 | 170 | |
| 171 | - if ( $application->isCancelled() ) { |
|
| 171 | + if ($application->isCancelled()) { |
|
| 172 | 172 | $status += DoctrineApplication::STATUS_CANCELED; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if ( $application->isDeleted() ) { |
|
| 175 | + if ($application->isDeleted()) { |
|
| 176 | 176 | $status += DoctrineApplication::STATUS_DELETED; |
| 177 | 177 | } |
| 178 | 178 | |
| 179 | - if ( $application->isConfirmed() || $this->isAutoConfirmed( $status, $application ) ) { |
|
| 179 | + if ($application->isConfirmed() || $this->isAutoConfirmed($status, $application)) { |
|
| 180 | 180 | $status += DoctrineApplication::STATUS_CONFIRMED; |
| 181 | 181 | } |
| 182 | 182 | |
| 183 | 183 | return $status; |
| 184 | 184 | } |
| 185 | 185 | |
| 186 | - private function isAutoConfirmed( int $status, Application $application ): bool { |
|
| 187 | - return $status === DoctrineApplication::STATUS_NEUTRAL && $this->isDirectDebitPayment( $application ); |
|
| 186 | + private function isAutoConfirmed(int $status, Application $application): bool { |
|
| 187 | + return $status === DoctrineApplication::STATUS_NEUTRAL && $this->isDirectDebitPayment($application); |
|
| 188 | 188 | } |
| 189 | 189 | |
| 190 | - private function isDirectDebitPayment( Application $application ): bool { |
|
| 190 | + private function isDirectDebitPayment(Application $application): bool { |
|
| 191 | 191 | return $application->getPayment()->getPaymentMethod()->getType() === PaymentType::DIRECT_DEBIT; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - private function preserveDoctrineStatus( DoctrineApplication $doctrineApplication, int $doctrineStatus ): void { |
|
| 195 | - if ( $doctrineStatus < DoctrineApplication::STATUS_CONFIRMED ) { |
|
| 196 | - $doctrineApplication->modifyDataObject( function ( MembershipApplicationData $data ): void { |
|
| 197 | - $data->setPreservedStatus( DoctrineApplication::STATUS_CONFIRMED ); |
|
| 194 | + private function preserveDoctrineStatus(DoctrineApplication $doctrineApplication, int $doctrineStatus): void { |
|
| 195 | + if ($doctrineStatus < DoctrineApplication::STATUS_CONFIRMED) { |
|
| 196 | + $doctrineApplication->modifyDataObject(function(MembershipApplicationData $data): void { |
|
| 197 | + $data->setPreservedStatus(DoctrineApplication::STATUS_CONFIRMED); |
|
| 198 | 198 | } ); |
| 199 | 199 | } |
| 200 | 200 | } |
@@ -205,19 +205,19 @@ discard block |
||
| 205 | 205 | * @return Application|null |
| 206 | 206 | * @throws GetMembershipApplicationException |
| 207 | 207 | */ |
| 208 | - public function getApplicationById( int $id ): ?Application { |
|
| 208 | + public function getApplicationById(int $id): ?Application { |
|
| 209 | 209 | try { |
| 210 | - $application = $this->getDoctrineApplicationById( $id ); |
|
| 210 | + $application = $this->getDoctrineApplicationById($id); |
|
| 211 | 211 | } |
| 212 | - catch ( ORMException $ex ) { |
|
| 213 | - throw new GetMembershipApplicationException( $ex ); |
|
| 212 | + catch (ORMException $ex) { |
|
| 213 | + throw new GetMembershipApplicationException($ex); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | - if ( $application === null ) { |
|
| 216 | + if ($application === null) { |
|
| 217 | 217 | return null; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | - return $this->newApplicationDomainEntity( $application ); |
|
| 220 | + return $this->newApplicationDomainEntity($application); |
|
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | /** |
@@ -225,25 +225,25 @@ discard block |
||
| 225 | 225 | * @return DoctrineApplication|null |
| 226 | 226 | * @throws ORMException |
| 227 | 227 | */ |
| 228 | - public function getDoctrineApplicationById( int $id ): ?DoctrineApplication { |
|
| 229 | - return $this->entityManager->find( DoctrineApplication::class, $id ); |
|
| 228 | + public function getDoctrineApplicationById(int $id): ?DoctrineApplication { |
|
| 229 | + return $this->entityManager->find(DoctrineApplication::class, $id); |
|
| 230 | 230 | } |
| 231 | 231 | |
| 232 | - private function newApplicationDomainEntity( DoctrineApplication $application ): Application { |
|
| 232 | + private function newApplicationDomainEntity(DoctrineApplication $application): Application { |
|
| 233 | 233 | return new Application( |
| 234 | 234 | $application->getId(), |
| 235 | 235 | $application->getMembershipType(), |
| 236 | 236 | new Applicant( |
| 237 | - $this->newPersonName( $application ), |
|
| 238 | - $this->newAddress( $application ), |
|
| 239 | - new EmailAddress( $application->getApplicantEmailAddress() ), |
|
| 240 | - new PhoneNumber( $application->getApplicantPhoneNumber() ), |
|
| 237 | + $this->newPersonName($application), |
|
| 238 | + $this->newAddress($application), |
|
| 239 | + new EmailAddress($application->getApplicantEmailAddress()), |
|
| 240 | + new PhoneNumber($application->getApplicantPhoneNumber()), |
|
| 241 | 241 | $application->getApplicantDateOfBirth() |
| 242 | 242 | ), |
| 243 | 243 | new Payment( |
| 244 | 244 | $application->getPaymentIntervalInMonths(), |
| 245 | - Euro::newFromFloat( $application->getPaymentAmount() ), |
|
| 246 | - $this->newPaymentMethod( $application ) |
|
| 245 | + Euro::newFromFloat($application->getPaymentAmount()), |
|
| 246 | + $this->newPaymentMethod($application) |
|
| 247 | 247 | ), |
| 248 | 248 | $application->needsModeration(), |
| 249 | 249 | $application->isCancelled(), |
@@ -253,77 +253,77 @@ discard block |
||
| 253 | 253 | ); |
| 254 | 254 | } |
| 255 | 255 | |
| 256 | - private function newPersonName( DoctrineApplication $application ): ApplicantName { |
|
| 257 | - if ( empty( $application->getCompany() ) ) { |
|
| 256 | + private function newPersonName(DoctrineApplication $application): ApplicantName { |
|
| 257 | + if (empty($application->getCompany())) { |
|
| 258 | 258 | $personName = ApplicantName::newPrivatePersonName(); |
| 259 | - $personName->setFirstName( $application->getApplicantFirstName() ); |
|
| 260 | - $personName->setLastName( $application->getApplicantLastName() ); |
|
| 261 | - $personName->setSalutation( $application->getApplicantSalutation() ); |
|
| 262 | - $personName->setTitle( $application->getApplicantTitle() ); |
|
| 259 | + $personName->setFirstName($application->getApplicantFirstName()); |
|
| 260 | + $personName->setLastName($application->getApplicantLastName()); |
|
| 261 | + $personName->setSalutation($application->getApplicantSalutation()); |
|
| 262 | + $personName->setTitle($application->getApplicantTitle()); |
|
| 263 | 263 | } else { |
| 264 | 264 | $personName = ApplicantName::newCompanyName(); |
| 265 | - $personName->setCompanyName( $application->getCompany() ); |
|
| 266 | - $personName->setSalutation( $application->getApplicantSalutation() ); |
|
| 265 | + $personName->setCompanyName($application->getCompany()); |
|
| 266 | + $personName->setSalutation($application->getApplicantSalutation()); |
|
| 267 | 267 | } |
| 268 | 268 | |
| 269 | 269 | return $personName->freeze()->assertNoNullFields(); |
| 270 | 270 | } |
| 271 | 271 | |
| 272 | - private function newAddress( DoctrineApplication $application ): ApplicantAddress { |
|
| 272 | + private function newAddress(DoctrineApplication $application): ApplicantAddress { |
|
| 273 | 273 | $address = new ApplicantAddress(); |
| 274 | 274 | |
| 275 | - $address->setCity( $application->getCity() ); |
|
| 276 | - $address->setCountryCode( $application->getCountry() ); |
|
| 277 | - $address->setPostalCode( $application->getPostcode() ); |
|
| 278 | - $address->setStreetAddress( $application->getAddress() ); |
|
| 275 | + $address->setCity($application->getCity()); |
|
| 276 | + $address->setCountryCode($application->getCountry()); |
|
| 277 | + $address->setPostalCode($application->getPostcode()); |
|
| 278 | + $address->setStreetAddress($application->getAddress()); |
|
| 279 | 279 | |
| 280 | 280 | return $address->freeze()->assertNoNullFields(); |
| 281 | 281 | } |
| 282 | 282 | |
| 283 | - private function newPaymentMethod( DoctrineApplication $application ): PaymentMethod { |
|
| 284 | - if ( $application->getPaymentType() === PaymentType::DIRECT_DEBIT ) { |
|
| 285 | - return new DirectDebitPayment( $this->newBankData( $application ) ); |
|
| 283 | + private function newPaymentMethod(DoctrineApplication $application): PaymentMethod { |
|
| 284 | + if ($application->getPaymentType() === PaymentType::DIRECT_DEBIT) { |
|
| 285 | + return new DirectDebitPayment($this->newBankData($application)); |
|
| 286 | 286 | } |
| 287 | 287 | |
| 288 | - if ( $application->getPaymentType() === PaymentType::PAYPAL ) { |
|
| 289 | - return new PayPalPayment( $this->newPayPalData( $application ) ); |
|
| 288 | + if ($application->getPaymentType() === PaymentType::PAYPAL) { |
|
| 289 | + return new PayPalPayment($this->newPayPalData($application)); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | - throw new \RuntimeException( 'Unsupported payment type' ); |
|
| 292 | + throw new \RuntimeException('Unsupported payment type'); |
|
| 293 | 293 | } |
| 294 | 294 | |
| 295 | - private function newBankData( DoctrineApplication $application ): BankData { |
|
| 295 | + private function newBankData(DoctrineApplication $application): BankData { |
|
| 296 | 296 | $bankData = new BankData(); |
| 297 | 297 | |
| 298 | - $bankData->setAccount( $application->getPaymentBankAccount() ); |
|
| 299 | - $bankData->setBankCode( $application->getPaymentBankCode() ); |
|
| 300 | - $bankData->setBankName( $application->getPaymentBankName() ); |
|
| 301 | - $bankData->setBic( $application->getPaymentBic() ); |
|
| 302 | - $bankData->setIban( new Iban( $application->getPaymentIban() ) ); |
|
| 298 | + $bankData->setAccount($application->getPaymentBankAccount()); |
|
| 299 | + $bankData->setBankCode($application->getPaymentBankCode()); |
|
| 300 | + $bankData->setBankName($application->getPaymentBankName()); |
|
| 301 | + $bankData->setBic($application->getPaymentBic()); |
|
| 302 | + $bankData->setIban(new Iban($application->getPaymentIban())); |
|
| 303 | 303 | |
| 304 | 304 | return $bankData->freeze()->assertNoNullFields(); |
| 305 | 305 | } |
| 306 | 306 | |
| 307 | - private function newPayPalData( DoctrineApplication $application ): ?PayPalData { |
|
| 307 | + private function newPayPalData(DoctrineApplication $application): ?PayPalData { |
|
| 308 | 308 | $data = $application->getDecodedData(); |
| 309 | 309 | |
| 310 | - return ( new PayPalData() ) |
|
| 311 | - ->setPayerId( $data['paypal_payer_id'] ?? '' ) |
|
| 312 | - ->setSubscriberId( $data['paypal_subscr_id'] ?? '' ) |
|
| 313 | - ->setPayerStatus( $data['paypal_payer_status'] ?? '' ) |
|
| 314 | - ->setAddressStatus( $data['paypal_address_status'] ?? '' ) |
|
| 315 | - ->setAmount( Euro::newFromString( $data['paypal_mc_gross'] ?? '0' ) ) |
|
| 316 | - ->setCurrencyCode( $data['paypal_mc_currency'] ?? '' ) |
|
| 317 | - ->setFee( Euro::newFromString( $data['paypal_mc_fee'] ?? '0' ) ) |
|
| 318 | - ->setSettleAmount( Euro::newFromString( $data['paypal_settle_amount'] ?? '0' ) ) |
|
| 319 | - ->setFirstName( $data['paypal_first_name'] ?? '' ) |
|
| 320 | - ->setLastName( $data['paypal_last_name'] ?? '' ) |
|
| 321 | - ->setAddressName( $data['paypal_address_name'] ?? '' ) |
|
| 322 | - ->setPaymentId( $data['ext_payment_id'] ?? '' ) |
|
| 323 | - ->setPaymentType( $data['ext_payment_type'] ?? '' ) |
|
| 324 | - ->setPaymentStatus( $data['ext_payment_status'] ?? '' ) |
|
| 325 | - ->setPaymentTimestamp( $data['ext_payment_timestamp'] ?? '' ) |
|
| 326 | - ->setFirstPaymentDate( $data['first_payment_date'] ?? '' ) |
|
| 310 | + return (new PayPalData()) |
|
| 311 | + ->setPayerId($data['paypal_payer_id'] ?? '') |
|
| 312 | + ->setSubscriberId($data['paypal_subscr_id'] ?? '') |
|
| 313 | + ->setPayerStatus($data['paypal_payer_status'] ?? '') |
|
| 314 | + ->setAddressStatus($data['paypal_address_status'] ?? '') |
|
| 315 | + ->setAmount(Euro::newFromString($data['paypal_mc_gross'] ?? '0')) |
|
| 316 | + ->setCurrencyCode($data['paypal_mc_currency'] ?? '') |
|
| 317 | + ->setFee(Euro::newFromString($data['paypal_mc_fee'] ?? '0')) |
|
| 318 | + ->setSettleAmount(Euro::newFromString($data['paypal_settle_amount'] ?? '0')) |
|
| 319 | + ->setFirstName($data['paypal_first_name'] ?? '') |
|
| 320 | + ->setLastName($data['paypal_last_name'] ?? '') |
|
| 321 | + ->setAddressName($data['paypal_address_name'] ?? '') |
|
| 322 | + ->setPaymentId($data['ext_payment_id'] ?? '') |
|
| 323 | + ->setPaymentType($data['ext_payment_type'] ?? '') |
|
| 324 | + ->setPaymentStatus($data['ext_payment_status'] ?? '') |
|
| 325 | + ->setPaymentTimestamp($data['ext_payment_timestamp'] ?? '') |
|
| 326 | + ->setFirstPaymentDate($data['first_payment_date'] ?? '') |
|
| 327 | 327 | ->freeze()->assertNoNullFields(); |
| 328 | 328 | } |
| 329 | 329 | |