| Conditions | 1 |
| Paths | 1 |
| Total Lines | 63 |
| Code Lines | 46 |
| 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 |
||
| 31 | public function testPluginRequirements() |
||
| 32 | { |
||
| 33 | PluginTools::refreshLoadedPlugins(); |
||
| 34 | // Add plugin to requirements-list, first time should be true, |
||
| 35 | // second time false because requirement already in list. |
||
| 36 | $this->assertTrue( |
||
| 37 | PluginRequirements::addPluginRequirement( |
||
| 38 | 'Hello Dolly', |
||
| 39 | '0.0.0', |
||
| 40 | '0.0.0', |
||
| 41 | true |
||
| 42 | ), |
||
| 43 | 'Could not add fake requirements' |
||
| 44 | ); |
||
| 45 | $this->assertFalse( |
||
| 46 | PluginRequirements::addPluginRequirement( |
||
| 47 | 'Hello Dolly', |
||
| 48 | '0.0.0', |
||
| 49 | '0.0.0', |
||
| 50 | true |
||
| 51 | ), |
||
| 52 | 'Check for existing requirement failed' |
||
| 53 | ); |
||
| 54 | $this->assertTrue( |
||
| 55 | PluginRequirements::addPluginRequirement( |
||
| 56 | 'WPTools', |
||
| 57 | '0.0.0', |
||
| 58 | '0.0.0', |
||
| 59 | true |
||
| 60 | ), |
||
| 61 | 'Could not add fake requirements' |
||
| 62 | ); |
||
| 63 | // Testing requiredPlugins should be false, since we set fake version-numbers. |
||
| 64 | $this->assertFalse( |
||
| 65 | PluginRequirements::checkRequiredPlugins(), |
||
| 66 | 'Requirement should not be met unless version number of Hello Dolly is 0.0.0' |
||
| 67 | ); |
||
| 68 | $this->assertTrue(PluginRequirements::removePluginRequirement('WPTools')); |
||
| 69 | |||
| 70 | $this->assertTrue(PluginRequirements::removePluginRequirement('Hello Dolly')); |
||
| 71 | $this->assertFalse(PluginRequirements::removePluginRequirement('Hello Dolly')); |
||
| 72 | $this->assertTrue(PluginRequirements::checkRequiredPlugins()); |
||
| 73 | activate_plugin('hello-dolly/hello.php'); |
||
| 74 | PluginTools::refreshLoadedPlugins(); |
||
| 75 | $this->assertTrue( |
||
| 76 | PluginRequirements::addPluginRequirement( |
||
| 77 | 'Hello Dolly', |
||
| 78 | '0.0.0', |
||
| 79 | '999.999.999', |
||
| 80 | false |
||
| 81 | ) |
||
| 82 | ); |
||
| 83 | $this->assertTrue(PluginRequirements::checkRequiredPlugins(), 'Hello Dolly should not be active yet.'); |
||
| 84 | $this->assertTrue(PluginRequirements::removePluginRequirement('Hello Dolly')); |
||
| 85 | $this->assertTrue( |
||
| 86 | PluginRequirements::addPluginRequirement( |
||
| 87 | 'Hello Dolly', |
||
| 88 | '0.0.0', |
||
| 89 | '999.999.999', |
||
| 90 | true |
||
| 91 | ) |
||
| 92 | ); |
||
| 93 | $this->assertFalse(PluginRequirements::checkRequiredPlugins(), 'Hello Dolly should not be active yet.'); |
||
| 94 | } |
||
| 96 |