| Conditions | 1 |
| Paths | 1 |
| Total Lines | 95 |
| Code Lines | 65 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 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 |
||
| 75 | public function testEmailIsSentUponStepCheckoutCompletion() |
||
| 76 | { |
||
| 77 | $self = $this; |
||
| 78 | $this->useTestTheme( |
||
| 79 | dirname(__FILE__), |
||
| 80 | 'testtheme', |
||
| 81 | function () use ($self) { |
||
| 82 | $page = $self->get("checkout/"); |
||
| 83 | $self->assertEquals( |
||
| 84 | 200, |
||
| 85 | $page->getStatusCode(), |
||
| 86 | "contact details page should load" |
||
| 87 | ); |
||
| 88 | |||
| 89 | // contact form |
||
| 90 | $page = $self->submitForm("CheckoutForm_ContactDetailsForm", "action_checkoutSubmit", array( |
||
| 91 | 'CustomerDetailsCheckoutComponent_FirstName' => 'Joe', |
||
| 92 | 'CustomerDetailsCheckoutComponent_Surname' => 'Bloggs', |
||
| 93 | 'CustomerDetailsCheckoutComponent_Email' => '[email protected]' |
||
| 94 | )); |
||
| 95 | $self->assertEquals( |
||
| 96 | 200, |
||
| 97 | $page->getStatusCode(), |
||
| 98 | "enter contact details page should load" |
||
| 99 | ); |
||
| 100 | |||
| 101 | // Shipping Address form |
||
| 102 | $page = $self->submitForm("CheckoutForm_ShippingAddressForm", "action_setshippingaddress", array( |
||
| 103 | 'ShippingAddressCheckoutComponent_Country' => 'AU', |
||
| 104 | 'ShippingAddressCheckoutComponent_Address' => '201-203 BROADWAY AVE', |
||
| 105 | 'ShippingAddressCheckoutComponent_AddressLine2' => 'U 235', |
||
| 106 | 'ShippingAddressCheckoutComponent_City' => 'WEST BEACH', |
||
| 107 | 'ShippingAddressCheckoutComponent_State' => 'South Australia', |
||
| 108 | 'ShippingAddressCheckoutComponent_PostalCode' => '5024', |
||
| 109 | 'ShippingAddressCheckoutComponent_Phone' => '', |
||
| 110 | 'SeperateBilling' => '0' |
||
| 111 | |||
| 112 | )); |
||
| 113 | $self->assertEquals( |
||
| 114 | 200, |
||
| 115 | $page->getStatusCode(), |
||
| 116 | "payment methods page should load" |
||
| 117 | ); |
||
| 118 | |||
| 119 | $self->assertContains( |
||
| 120 | "CheckoutForm_PaymentMethodForm_PaymentMethod_Manual", |
||
| 121 | $page->getBody(), |
||
| 122 | "Manual payment method available" |
||
| 123 | ); |
||
| 124 | |||
| 125 | $self->assertContains( |
||
| 126 | "You will be notified of the bank account details", |
||
| 127 | $page->getBody(), |
||
| 128 | "Bank Account Message presented during the payment method section" |
||
| 129 | ); |
||
| 130 | |||
| 131 | // Payment Method can be manual |
||
| 132 | $page = $self->submitForm("CheckoutForm_PaymentMethodForm", "action_setpaymentmethod", array( |
||
| 133 | 'PaymentMethod' => 'Manual', |
||
| 134 | )); |
||
| 135 | $self->assertEquals( |
||
| 136 | 200, |
||
| 137 | $page->getStatusCode(), |
||
| 138 | "Payment Method set. The summary page should load." |
||
| 139 | ); |
||
| 140 | |||
| 141 | // Summary |
||
| 142 | $page = $self->submitForm("PaymentForm_ConfirmationForm", "action_checkoutSubmit", array( |
||
| 143 | 'PaymentForm_ConfirmationForm_Notes' => 'Test', |
||
| 144 | )); |
||
| 145 | $self->assertEquals( |
||
| 146 | 200, |
||
| 147 | $page->getStatusCode(), |
||
| 148 | "enter summary page should load" |
||
| 149 | ); |
||
| 150 | $self->assertContains( |
||
| 151 | '<h2>My Account</h2>', |
||
| 152 | $page->getBody(), |
||
| 153 | "Account Page should load" |
||
| 154 | ); |
||
| 155 | |||
| 156 | $self->assertContains( |
||
| 157 | 'XX-3456-7891011-XX', |
||
| 158 | $page->getBody(), |
||
| 159 | "Account Page contains bank deposit instructions" |
||
| 160 | ); |
||
| 161 | |||
| 162 | $self->assertContains( |
||
| 163 | 'Hey bo, just pop the dosh in the account', |
||
| 164 | $page->getBody(), |
||
| 165 | "Bank Account Invoice Message delivered" |
||
| 166 | ); |
||
| 167 | |||
| 168 | $self->assertEmailSent( |
||
| 169 | '[email protected]' |
||
| 170 | ); |
||
| 175 |