| Conditions | 1 |
| Paths | 1 |
| Total Lines | 100 |
| Code Lines | 70 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| 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 |
||
| 65 | public function testEmailIsSentUponStepCheckoutCompletionByGuest(): void |
||
| 66 | { |
||
| 67 | $self = $this; |
||
| 68 | $this->useTestTheme( |
||
| 69 | __DIR__, |
||
| 70 | 'testtheme', |
||
| 71 | function () use ($self): void { |
||
| 72 | $page = $self->get("checkout/"); |
||
| 73 | $self->assertEquals( |
||
| 74 | 200, |
||
| 75 | $page->getStatusCode(), |
||
| 76 | "page should load" |
||
| 77 | ); |
||
| 78 | |||
| 79 | $page = $self->submitForm("Form_MembershipForm", "action_guestcontinue", []); |
||
| 80 | $self->assertEquals( |
||
| 81 | 200, |
||
| 82 | $page->getStatusCode(), |
||
| 83 | "page should load" |
||
| 84 | ); |
||
| 85 | |||
| 86 | // contact form |
||
| 87 | $page = $self->submitForm( |
||
| 88 | "CheckoutForm_ContactDetailsForm", |
||
| 89 | "action_checkoutSubmit", |
||
| 90 | [ |
||
| 91 | 'SilverShop-Checkout-Component-CustomerDetails_FirstName' => 'James', |
||
| 92 | 'SilverShop-Checkout-Component-CustomerDetails_Surname' => 'Stark', |
||
| 93 | 'SilverShop-Checkout-Component-CustomerDetails_Email' => '[email protected]' |
||
| 94 | ] |
||
| 95 | ); |
||
| 96 | $self->assertEquals( |
||
| 97 | 200, |
||
| 98 | $page->getStatusCode(), |
||
| 99 | "a page should load" |
||
| 100 | ); |
||
| 101 | |||
| 102 | // Shipping Address form |
||
| 103 | $page = $self->submitForm( |
||
| 104 | "CheckoutForm_ShippingAddressForm", |
||
| 105 | "action_setshippingaddress", |
||
| 106 | [ |
||
| 107 | 'SilverShop-Checkout-Component-ShippingAddress_Country' => 'AU', |
||
| 108 | 'SilverShop-Checkout-Component-ShippingAddress_Address' => '201-203 BROADWAY AVE', |
||
| 109 | 'SilverShop-Checkout-Component-ShippingAddress_AddressLine2' => 'U 235', |
||
| 110 | 'SilverShop-Checkout-Component-ShippingAddress_City' => 'WEST BEACH', |
||
| 111 | 'SilverShop-Checkout-Component-ShippingAddress_State' => 'South Australia', |
||
| 112 | 'SilverShop-Checkout-Component-ShippingAddress_PostalCode' => '5024', |
||
| 113 | 'SilverShop-Checkout-Component-ShippingAddress_Phone' => '', |
||
| 114 | 'SeperateBilling' => false |
||
| 115 | ] |
||
| 116 | ); |
||
| 117 | $self->assertEquals( |
||
| 118 | 200, |
||
| 119 | $page->getStatusCode(), |
||
| 120 | "payment methods page should load" |
||
| 121 | ); |
||
| 122 | |||
| 123 | $self->assertStringContainsString( |
||
| 124 | "CheckoutForm_PaymentMethodForm_PaymentMethod_Manual", |
||
| 125 | $page->getBody(), |
||
| 126 | "Manual payment method available" |
||
| 127 | ); |
||
| 128 | |||
| 129 | $self->assertStringContainsString( |
||
| 130 | "You will be notified of the bank account details", |
||
| 131 | $page->getBody(), |
||
| 132 | "Bank Account Message presented during the payment method section" |
||
| 133 | ); |
||
| 134 | |||
| 135 | // Payment Method can be manual |
||
| 136 | $page = $self->submitForm( |
||
| 137 | "CheckoutForm_PaymentMethodForm", |
||
| 138 | "action_setpaymentmethod", |
||
| 139 | ['PaymentMethod' => 'Manual'] |
||
| 140 | ); |
||
| 141 | $self->assertEquals( |
||
| 142 | 200, |
||
| 143 | $page->getStatusCode(), |
||
| 144 | "Payment Method set. The summary page should load." |
||
| 145 | ); |
||
| 146 | |||
| 147 | // Summary |
||
| 148 | $page = $self->submitForm( |
||
| 149 | "PaymentForm_ConfirmationForm", |
||
| 150 | "action_checkoutSubmit", |
||
| 151 | ['PaymentForm_ConfirmationForm_Notes' => 'Test'] |
||
| 152 | ); |
||
| 153 | $self->assertEquals( |
||
| 154 | 200, |
||
| 155 | $page->getStatusCode(), |
||
| 156 | "a page should load" |
||
| 157 | ); |
||
| 158 | $self->assertStringContainsString( |
||
| 159 | 'XX-3456-7891011-XX', |
||
| 160 | $page->getBody(), |
||
| 161 | "Account Page contains bank deposit instructions" |
||
| 162 | ); |
||
| 163 | $self->assertEmailSent( |
||
| 164 | '[email protected]' |
||
| 165 | ); |
||
| 170 |