Conditions | 1 |
Paths | 1 |
Total Lines | 173 |
Code Lines | 129 |
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 |
||
23 | public function testOrderStatusLogItemsWithMember() |
||
24 | { |
||
25 | // start a new order |
||
26 | $order = $this->objFromFixture("Order", "cart1"); |
||
27 | $member = $this->objFromFixture('Member', 'jeremyperemy'); |
||
28 | $order->MemberID = $member->ID; |
||
29 | |||
30 | $no_log_generated_with_order_status_cart = OrderStatusLog::get()->sort('ID')->last(); |
||
31 | $this->assertNull( |
||
|
|||
32 | $no_log_generated_with_order_status_cart, |
||
33 | "no log generated with Status of 'Cart'" |
||
34 | ); |
||
35 | |||
36 | $order->Status = "Unpaid"; |
||
37 | $order->write(); |
||
38 | |||
39 | $no_log_generated_with_order_status_unpaid = OrderStatusLog::get()->sort('ID')->last(); |
||
40 | $this->assertNull( |
||
41 | $no_log_generated_with_order_status_unpaid, |
||
42 | "no log generated with Status of 'Unpaid'" |
||
43 | ); |
||
44 | |||
45 | $processor = OrderProcessor::create($order); |
||
46 | $response = $processor->makePayment("Manual", array()); |
||
47 | $order->Status = "Paid"; |
||
48 | $order->write(); |
||
49 | |||
50 | $log_order_status_paid = OrderStatusLog::get()->sort('ID')->last(); |
||
51 | $this->assertNull( |
||
52 | $log_order_status_paid, |
||
53 | "no log generated with Status of 'Unpaid'" |
||
54 | ); |
||
55 | |||
56 | $order->Status = "Processing"; |
||
57 | $order->write(); |
||
58 | |||
59 | $log_order_status_processing = OrderStatusLog::get()->sort('ID')->last(); |
||
60 | $this->assertEquals(OrderStatusLog::get()->count(), '1', "One items in the OrderStatusLog"); |
||
61 | $this->assertNotNull( |
||
62 | $log_order_status_processing, |
||
63 | "a log when changing to 'Processing' status (and PaymentMethod is 'Manual')" |
||
64 | ); |
||
65 | $this->assertSame( |
||
66 | $log_order_status_processing->Order()->ID, |
||
67 | $order->ID, |
||
68 | "Log conatins an Order" |
||
69 | ); |
||
70 | |||
71 | $this->assertContains( |
||
72 | "Processing", |
||
73 | $log_order_status_processing->Note, |
||
74 | "Processing note is recorded" |
||
75 | ); |
||
76 | $this->assertContains( |
||
77 | 'changed to "Processing"', |
||
78 | $log_order_status_processing->Title, |
||
79 | 'Processing title is recorded' |
||
80 | ); |
||
81 | $this->assertEmailSent( |
||
82 | '[email protected]', |
||
83 | '[email protected]', |
||
84 | _t('ShopEmail.StatusChangeSubject') . $log_order_status_processing->Title |
||
85 | ); |
||
86 | $order->Status = "Sent"; |
||
87 | $order->write(); |
||
88 | |||
89 | $log_order_status_sent = OrderStatusLog::get()->sort('ID')->last(); |
||
90 | $this->assertEquals( |
||
91 | OrderStatusLog::get()->count(), |
||
92 | '2', |
||
93 | "Three items in the OrderStatusLog" |
||
94 | ); |
||
95 | $this->assertNotNull( |
||
96 | $log_order_status_sent, |
||
97 | "an log should be recorded when an order's status is changed to 'Sent' (and PaymentMethod is 'Manual')" |
||
98 | ); |
||
99 | $this->assertSame( |
||
100 | $log_order_status_sent->Order()->ID, |
||
101 | $order->ID, |
||
102 | "Log conatins an Order" |
||
103 | ); |
||
104 | $this->assertContains( |
||
105 | "sent", |
||
106 | $log_order_status_sent->Note, |
||
107 | "Sent note is recorded" |
||
108 | ); |
||
109 | $this->assertContains( |
||
110 | 'changed to "Sent"', |
||
111 | $log_order_status_sent->Title, |
||
112 | "Sent title is recorded" |
||
113 | ); |
||
114 | |||
115 | $this->assertEmailSent( |
||
116 | "[email protected]", |
||
117 | "[email protected]", |
||
118 | _t('ShopEmail.StatusChangeSubject') . $log_order_status_sent->Title |
||
119 | ); |
||
120 | |||
121 | $order->Status = "Complete"; |
||
122 | $order->write(); |
||
123 | $this->assertEquals( |
||
124 | OrderStatusLog::get()->count(), |
||
125 | '2', |
||
126 | "Additional item in the OrderStatusLog has not been created" |
||
127 | ); |
||
128 | |||
129 | $order->Status = "AdminCancelled"; |
||
130 | $order->write(); |
||
131 | |||
132 | $log_order_status_admin_cancelled = OrderStatusLog::get()->sort('ID')->last(); |
||
133 | $this->assertEquals( |
||
134 | OrderStatusLog::get()->count(), |
||
135 | '3', |
||
136 | "Three items in the OrderStatusLog" |
||
137 | ); |
||
138 | $this->assertNotNull( |
||
139 | $log_order_status_admin_cancelled, |
||
140 | "a log should be recorded with change to 'Admin Cancelled' status (and PaymentMethod is 'Manual')" |
||
141 | ); |
||
142 | $this->assertSame( |
||
143 | $log_order_status_admin_cancelled->Order()->ID, |
||
144 | $order->ID, |
||
145 | "Log conatins an Order" |
||
146 | ); |
||
147 | $this->assertContains( |
||
148 | "cancelled", |
||
149 | $log_order_status_admin_cancelled->Note, |
||
150 | "Admin Cancelled note is recorded" |
||
151 | ); |
||
152 | $this->assertContains( |
||
153 | 'changed to "Cancelled by admin"', |
||
154 | $log_order_status_admin_cancelled->Title, |
||
155 | "Admin Cancelled title is recorded" |
||
156 | ); |
||
157 | $this->assertEmailSent( |
||
158 | "[email protected]", |
||
159 | "[email protected]", |
||
160 | _t('ShopEmail.StatusChangeSubject') . $log_order_status_admin_cancelled->Title |
||
161 | ); |
||
162 | |||
163 | $order->Status = "MemberCancelled"; |
||
164 | $order->write(); |
||
165 | $log_order_status_member_cancelled = OrderStatusLog::get()->sort('ID')->last(); |
||
166 | $this->assertEquals( |
||
167 | OrderStatusLog::get()->count(), |
||
168 | '4', |
||
169 | "Four items in the OrderStatusLog" |
||
170 | ); |
||
171 | $this->assertNotNull( |
||
172 | $log_order_status_member_cancelled, |
||
173 | "a log should be recorded for change to 'Member Cancelled' status (and PaymentMethod is 'Manual')" |
||
174 | ); |
||
175 | $this->assertSame( |
||
176 | $log_order_status_member_cancelled->Order()->ID, |
||
177 | $order->ID, |
||
178 | "Log conatins an Order" |
||
179 | ); |
||
180 | $this->assertSame( |
||
181 | "Your cancellation of the order has been noted. Please contact us if you have any questions.", |
||
182 | $log_order_status_member_cancelled->Note, |
||
183 | "Member Cancelled note is recorded" |
||
184 | ); |
||
185 | $this->assertContains( |
||
186 | ' changed to "Cancelled by member"', |
||
187 | $log_order_status_member_cancelled->Title, |
||
188 | "Member Cancelled title is recorded" |
||
189 | ); |
||
190 | $this->assertEmailSent( |
||
191 | '[email protected]', |
||
192 | '[email protected]', |
||
193 | _t('ShopEmail.StatusChangeSubject') . $log_order_status_member_cancelled->Title |
||
194 | ); |
||
195 | } |
||
196 | |||
256 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.