| Conditions | 1 |
| Paths | 1 |
| Total Lines | 131 |
| Code Lines | 83 |
| 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 |
||
| 107 | { |
||
| 108 | $expect = array( |
||
| 109 | 'SILVERSTRIPE\TEST\CLASSA' => array('silverstripe\test\ClassB', 'silverstripe\test\ClassH'), |
||
| 110 | 'silverstripe\test\classa' => array('silverstripe\test\ClassB', 'silverstripe\test\ClassH'), |
||
| 111 | ); |
||
| 112 | |||
| 113 | foreach ($expect as $class => $desc) { |
||
| 114 | $this->assertEquals($desc, $this->manifest->getDescendantsOf($class)); |
||
| 115 | } |
||
| 116 | } |
||
| 117 | |||
| 118 | public function testGetInterfaces() |
||
| 119 | { |
||
| 120 | $expect = array( |
||
| 121 | 'silverstripe\test\interfacea' => "{$this->base}/module/interfaces/InterfaceA.php", |
||
| 122 | ); |
||
| 123 | $this->assertEquals($expect, $this->manifest->getInterfaces()); |
||
| 124 | } |
||
| 125 | |||
| 126 | public function testGetImplementors() |
||
| 127 | { |
||
| 128 | $expect = array( |
||
| 129 | 'silverstripe\test\interfacea' => array('silverstripe\test\ClassE'), |
||
| 130 | 'interfacea' => array('silverstripe\test\ClassF'), |
||
| 131 | 'silverstripe\test\subtest\interfacea' => array('silverstripe\test\ClassG'), |
||
| 132 | 'silverstripe\security\permissionprovider' => array('SilverStripe\Framework\Tests\ClassI'), |
||
| 133 | ); |
||
| 134 | $this->assertEquals($expect, $this->manifest->getImplementors()); |
||
| 135 | } |
||
| 136 | |||
| 137 | public function testGetImplementorsOf() |
||
| 138 | { |
||
| 139 | $expect = array( |
||
| 140 | 'SILVERSTRIPE\TEST\INTERFACEA' => array('silverstripe\test\ClassE'), |
||
| 141 | 'silverstripe\test\interfacea' => array('silverstripe\test\ClassE'), |
||
| 142 | 'INTERFACEA' => array('silverstripe\test\ClassF'), |
||
| 143 | 'interfacea' => array('silverstripe\test\ClassF'), |
||
| 144 | 'SILVERSTRIPE\TEST\SUBTEST\INTERFACEA' => array('silverstripe\test\ClassG'), |
||
| 145 | 'silverstripe\test\subtest\interfacea' => array('silverstripe\test\ClassG'), |
||
| 146 | ); |
||
| 147 | |||
| 148 | foreach ($expect as $interface => $impl) { |
||
| 149 | $this->assertEquals($impl, $this->manifest->getImplementorsOf($interface)); |
||
| 150 | } |
||
| 151 | } |
||
| 152 | |||
| 153 | public function testGetConfigs() |
||
| 154 | { |
||
| 155 | $expect = array("{$this->base}/module/_config.php"); |
||
| 156 | $this->assertEquals($expect, $this->manifest->getConfigs()); |
||
| 157 | } |
||
| 158 | |||
| 159 | public function testGetModules() |
||
| 160 | { |
||
| 161 | $expect = array( |
||
| 162 | "module" => "{$this->base}/module", |
||
| 163 | "moduleb" => "{$this->base}/moduleb" |
||
| 164 | ); |
||
| 165 | $this->assertEquals($expect, $this->manifest->getModules()); |
||
| 166 | } |
||
| 167 | } |
||
| 168 |