| Conditions | 1 |
| Paths | 1 |
| Total Lines | 93 |
| Code Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 4 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 74 | public function testEmailIsSentUponStepCheckoutCompletion(): void |
||
| 75 | { |
||
| 76 | $self = $this; |
||
| 77 | $this->useTestTheme( |
||
| 78 | __DIR__, |
||
| 79 | 'testtheme', |
||
| 80 | function () use ($self): void { |
||
| 81 | $page = $self->get("checkout/"); |
||
| 82 | $self->assertEquals( |
||
| 83 | 200, |
||
| 84 | $page->getStatusCode(), |
||
| 85 | "contact details page should load" |
||
| 86 | ); |
||
| 87 | |||
| 88 | // contact form |
||
| 89 | $page = $self->submitForm( |
||
| 90 | "CheckoutForm_ContactDetailsForm", |
||
| 91 | "action_checkoutSubmit", |
||
| 92 | [ |
||
| 93 | 'CustomerDetailsCheckoutComponent_FirstName' => 'Joe', |
||
| 94 | 'CustomerDetailsCheckoutComponent_Surname' => 'Bloggs', |
||
| 95 | 'CustomerDetailsCheckoutComponent_Email' => '[email protected]' |
||
| 96 | ] |
||
| 97 | ); |
||
| 98 | $self->assertEquals( |
||
| 99 | 200, |
||
| 100 | $page->getStatusCode(), |
||
| 101 | "enter contact details page should load" |
||
| 102 | ); |
||
| 103 | |||
| 104 | // Shipping Address form |
||
| 105 | $page = $self->submitForm( |
||
| 106 | "CheckoutForm_ShippingAddressForm", |
||
| 107 | "action_setshippingaddress", |
||
| 108 | [ |
||
| 109 | 'ShippingAddressCheckoutComponent_Country' => 'AU', |
||
| 110 | 'ShippingAddressCheckoutComponent_Address' => '201-203 BROADWAY AVE', |
||
| 111 | 'ShippingAddressCheckoutComponent_AddressLine2' => 'U 235', |
||
| 112 | 'ShippingAddressCheckoutComponent_City' => 'WEST BEACH', |
||
| 113 | 'ShippingAddressCheckoutComponent_State' => 'South Australia', |
||
| 114 | 'ShippingAddressCheckoutComponent_PostalCode' => '5024', |
||
| 115 | 'ShippingAddressCheckoutComponent_Phone' => '', |
||
| 116 | 'SeperateBilling' => false |
||
| 117 | ] |
||
| 118 | ); |
||
| 119 | $self->assertEquals( |
||
| 120 | 200, |
||
| 121 | $page->getStatusCode(), |
||
| 122 | "payment methods page should load" |
||
| 123 | ); |
||
| 124 | |||
| 125 | $self->assertStringContainsString( |
||
| 126 | "CheckoutForm_PaymentMethodForm_PaymentMethod_Manual", |
||
| 127 | $page->getBody(), |
||
| 128 | "Manual payment method available" |
||
| 129 | ); |
||
| 130 | |||
| 131 | $self->assertStringContainsString( |
||
| 132 | "You will be notified of the bank account details", |
||
| 133 | $page->getBody(), |
||
| 134 | "Bank Account Message presented during the payment method section" |
||
| 135 | ); |
||
| 136 | |||
| 137 | // Payment Method can be manual |
||
| 138 | $page = $self->submitForm( |
||
| 139 | "CheckoutForm_PaymentMethodForm", |
||
| 140 | "action_setpaymentmethod", |
||
| 141 | ['PaymentMethod' => 'Manual'] |
||
| 142 | ); |
||
| 143 | $self->assertEquals( |
||
| 144 | 200, |
||
| 145 | $page->getStatusCode(), |
||
| 146 | "Payment Method set. The summary page should load." |
||
| 147 | ); |
||
| 148 | |||
| 149 | // Summary |
||
| 150 | $page = $self->submitForm( |
||
| 151 | "PaymentForm_ConfirmationForm", |
||
| 152 | "action_checkoutSubmit", |
||
| 153 | ['PaymentForm_ConfirmationForm_Notes' => 'Test'] |
||
| 154 | ); |
||
| 155 | $self->assertEquals( |
||
| 156 | 200, |
||
| 157 | $page->getStatusCode(), |
||
| 158 | "enter summary page should load" |
||
| 159 | ); |
||
| 160 | $self->assertStringContainsString( |
||
| 161 | 'XX-3456-7891011-XX', |
||
| 162 | $page->getBody(), |
||
| 163 | "Account Page contains bank deposit instructions" |
||
| 164 | ); |
||
| 165 | $self->assertEmailSent( |
||
| 166 | '[email protected]' |
||
| 167 | ); |
||
| 172 |