| Conditions | 1 |
| Paths | 1 |
| Total Lines | 74 |
| Code Lines | 42 |
| 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 |
||
| 9 | public function testExecute() |
||
| 10 | { |
||
| 11 | /** |
||
| 12 | * Add a new entry (to test for it) |
||
| 13 | */ |
||
| 14 | $this->assertDisplayContains( |
||
| 15 | array( |
||
| 16 | 'command' => 'config:set', |
||
| 17 | 'path' => 'n98_magerun/foo/bar', |
||
| 18 | 'value' => '1234', |
||
| 19 | ), |
||
| 20 | 'n98_magerun/foo/bar => 1234' |
||
| 21 | ); |
||
| 22 | |||
| 23 | $this->assertDisplayContains( |
||
| 24 | array( |
||
| 25 | 'command' => 'config:get', |
||
| 26 | 'path' => 'n98_magerun/foo/bar', |
||
| 27 | ), |
||
| 28 | '| n98_magerun/foo/bar | default | 0 | 1234 |' |
||
| 29 | ); |
||
| 30 | |||
| 31 | $this->assertDisplayContains( |
||
| 32 | array( |
||
| 33 | 'command' => 'config:get', |
||
| 34 | 'path' => 'n98_magerun/foo/bar', |
||
| 35 | '--update-script' => true, |
||
| 36 | ), |
||
| 37 | "\$installer->setConfigData('n98_magerun/foo/bar', '1234');" |
||
| 38 | ); |
||
| 39 | |||
| 40 | $this->assertDisplayContains( |
||
| 41 | array( |
||
| 42 | 'command' => 'config:get', |
||
| 43 | 'path' => 'n98_magerun/foo/bar', |
||
| 44 | '--magerun-script' => true, |
||
| 45 | ), |
||
| 46 | "config:set --scope-id=0 --scope=default -- 'n98_magerun/foo/bar' '1234'" |
||
| 47 | ); |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Dump CSV |
||
| 51 | */ |
||
| 52 | $input = array( |
||
| 53 | 'command' => 'config:get', |
||
| 54 | 'path' => 'n98_magerun/foo/bar', |
||
| 55 | '--format' => 'csv', |
||
| 56 | ); |
||
| 57 | $this->assertDisplayContains($input, 'Path,Scope,Scope-ID,Value'); |
||
| 58 | $this->assertDisplayContains($input, 'n98_magerun/foo/bar,default,0,1234'); |
||
| 59 | |||
| 60 | /** |
||
| 61 | * Dump XML |
||
| 62 | */ |
||
| 63 | $input = array( |
||
| 64 | 'command' => 'config:get', |
||
| 65 | 'path' => 'n98_magerun/foo/bar', |
||
| 66 | '--format' => 'xml', |
||
| 67 | ); |
||
| 68 | $this->assertDisplayContains($input, '<table>'); |
||
| 69 | $this->assertDisplayContains($input, '<Value>1234</Value>'); |
||
| 70 | |||
| 71 | /** |
||
| 72 | * Dump JSON |
||
| 73 | */ |
||
| 74 | $this->assertDisplayRegExp( |
||
| 75 | array( |
||
| 76 | 'command' => 'config:get', |
||
| 77 | 'path' => 'n98_magerun/foo/bar', |
||
| 78 | '--format' => 'json', |
||
| 79 | ), |
||
| 80 | '/"Value":\s*"1234"/' |
||
| 81 | ); |
||
| 82 | } |
||
| 83 | } |
||
| 84 |