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