Conditions | 2 |
Paths | 1 |
Total Lines | 115 |
Code Lines | 85 |
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 |
||
56 | public function testCanViewAccountPagePastOrdersAndIndividualOrders() |
||
57 | { |
||
58 | $self = $this; |
||
59 | $this->useTestTheme( |
||
60 | dirname(__FILE__), |
||
61 | 'testtheme', |
||
62 | function () use ($self) { |
||
63 | $member = $self->objFromFixture(Member::class, "joebloggs"); |
||
64 | $self->logInAs($member); |
||
65 | $self->controller->init(); //re-init to connect up member |
||
66 | |||
67 | // Open Address Book page |
||
68 | $page = $self->get("account/"); // Past Orders page |
||
69 | $self->assertEquals(AccountPageController::class, $page->getHeader('X-TestPageClass'), "Account page should open"); |
||
70 | |||
71 | $self->assertContains( |
||
72 | "Past Orders", |
||
73 | $page->getBody(), |
||
74 | "Account Page is open" |
||
75 | ); |
||
76 | $self->assertContains( |
||
77 | "Joe Bloggs", |
||
78 | $page->getBody(), |
||
79 | "Joe Bloggs is logged in" |
||
80 | ); |
||
81 | $self->assertContains( |
||
82 | "<td>$408.00</td>", |
||
83 | $page->getBody(), |
||
84 | "Past Order is listed" |
||
85 | ); |
||
86 | |||
87 | // Open unpaid order |
||
88 | $page = $self->get("account/order/10"); |
||
89 | $self->assertEquals( |
||
90 | 200, |
||
91 | $page->getStatusCode(), |
||
92 | "a page should load" |
||
93 | ); |
||
94 | $self->assertContains( |
||
95 | "Please deposit", |
||
96 | $page->getBody(), |
||
97 | "Opening statement is shown" |
||
98 | ); |
||
99 | $self->assertContains( |
||
100 | "XX-3456-7891011-XX", |
||
101 | $page->getBody(), |
||
102 | "Bank Account number is shown" |
||
103 | ); |
||
104 | $self->assertContains( |
||
105 | "Reference:", |
||
106 | $page->getBody(), |
||
107 | "Reference is shown" |
||
108 | ); |
||
109 | $self->assertContains( |
||
110 | "Your name", |
||
111 | $page->getBody(), |
||
112 | "Code is shown" |
||
113 | ); |
||
114 | $self->assertContains( |
||
115 | "$3950.00", |
||
116 | $page->getBody(), |
||
117 | "Total Outstanding is shown" |
||
118 | ); |
||
119 | |||
120 | // Open paid order |
||
121 | $page = $self->get("account/order/11"); |
||
122 | $self->assertEquals( |
||
123 | 200, |
||
124 | $page->getStatusCode(), |
||
125 | "a page should load" |
||
126 | ); |
||
127 | |||
128 | $self->assertNotContains( |
||
129 | "Please deposit", |
||
130 | $page->getBody(), |
||
131 | "Opening statement is not shown" |
||
132 | ); |
||
133 | $self->assertContains( |
||
134 | "$7900.00", |
||
135 | $page->getBody(), |
||
136 | "Total Outstanding is shown" |
||
137 | ); |
||
138 | |||
139 | $self->assertContains( |
||
140 | "Paid", |
||
141 | $page->getBody(), |
||
142 | "'Paid' is displayed in place of Total Outstanding" |
||
143 | ); |
||
144 | |||
145 | // test other order statuses |
||
146 | $order = Order::get()->byId("11"); |
||
147 | $statuses = ["Sent", "Complete", "AdminCancelled", "MemberCancelled"]; |
||
148 | foreach ($statuses as $status) { |
||
149 | $order->Status = $status; |
||
150 | |||
151 | $page = $self->get("account/order/11"); |
||
152 | $self->assertEquals( |
||
153 | 200, |
||
154 | $page->getStatusCode(), |
||
155 | "a page should load" |
||
156 | ); |
||
157 | $self->assertNotContains( |
||
158 | "Please deposit", |
||
159 | $page->getBody(), |
||
160 | "Opening statement is not shown" |
||
161 | ); |
||
162 | $self->assertContains( |
||
163 | "$7900.00", |
||
164 | $page->getBody(), |
||
165 | "Total Outstanding is shown" |
||
166 | ); |
||
167 | $self->assertContains( |
||
168 | "Paid", |
||
169 | $page->getBody(), |
||
170 | "'Paid' is displayed in place of Total Outstanding" |
||
171 | ); |
||
177 |