| Conditions | 5 |
| Paths | 16 |
| Total Lines | 51 |
| Code Lines | 26 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| 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 |
||
| 77 | public function testModifierFailure() |
||
| 78 | { |
||
| 79 | if (!DB::get_conn()->supportsTransactions()) { |
||
| 80 | $this->markTestSkipped( |
||
| 81 | 'The Database doesn\'t support transactions.' |
||
| 82 | ); |
||
| 83 | } |
||
| 84 | |||
| 85 | Config::modify()->set( |
||
| 86 | Order::class, |
||
| 87 | 'modifiers', |
||
| 88 | [ |
||
| 89 | OrderModifierTest_TestModifier::class, |
||
| 90 | FlatTax::class |
||
| 91 | ] |
||
| 92 | ); |
||
| 93 | |||
| 94 | $order = $this->createOrder(); |
||
| 95 | $order->calculate(); |
||
| 96 | $order->write(); |
||
| 97 | |||
| 98 | // 408 from items + 10 from modifier + 25% from tax |
||
| 99 | $this->assertEquals('522.5', $order->Total); |
||
| 100 | |||
| 101 | $amounts = []; |
||
| 102 | foreach ($order->Modifiers()->sort('Sort') as $modifier) { |
||
| 103 | $amounts[] = (string)$modifier->Amount; |
||
| 104 | } |
||
| 105 | |||
| 106 | $this->assertEquals(['10', '104.5'], $amounts); |
||
| 107 | |||
| 108 | OrderModifierTest_TestModifier::$value = 42; |
||
| 109 | |||
| 110 | try { |
||
| 111 | // Calculate will now fail! |
||
| 112 | $order->calculate(); |
||
| 113 | } catch (Exception $e) { |
||
| 114 | } |
||
| 115 | |||
| 116 | // reload order from DB |
||
| 117 | $order = Order::get()->byID($order->ID); |
||
| 118 | |||
| 119 | // Order Total should not have changed |
||
| 120 | $this->assertEquals('522.5', $order->Total); |
||
| 121 | |||
| 122 | $amounts = []; |
||
| 123 | foreach ($order->Modifiers()->sort('Sort') as $modifier) { |
||
| 124 | $amounts[] = (string)$modifier->Amount; |
||
| 125 | } |
||
| 126 | |||
| 127 | $this->assertEquals(['10', '104.5'], $amounts); |
||
| 128 | } |
||
| 143 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths