| Conditions | 1 |
| Paths | 1 |
| Total Lines | 29 |
| Lines | 29 |
| Ratio | 100 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 49 | View Code Duplication | public function testOptions() |
|
|
|
|||
| 50 | { |
||
| 51 | $rule = new RuleOptions; |
||
| 52 | $xml = simplexml_load_string( |
||
| 53 | '<form><field name="field1"><option value="value1">Value1</option><option value="value2">Value2</option></field></form>' |
||
| 54 | ); |
||
| 55 | |||
| 56 | // Test fail conditions. |
||
| 57 | |||
| 58 | $this->assertThat( |
||
| 59 | $rule->test($xml->field[0], 'bogus'), |
||
| 60 | $this->isFalse(), |
||
| 61 | 'Line:' . __LINE__ . ' The rule should fail and return false.' |
||
| 62 | ); |
||
| 63 | |||
| 64 | // Test pass conditions. |
||
| 65 | |||
| 66 | $this->assertThat( |
||
| 67 | $rule->test($xml->field[0], 'value1'), |
||
| 68 | $this->isTrue(), |
||
| 69 | 'Line:' . __LINE__ . ' value1 should pass and return true.' |
||
| 70 | ); |
||
| 71 | |||
| 72 | $this->assertThat( |
||
| 73 | $rule->test($xml->field[0], 'value2'), |
||
| 74 | $this->isTrue(), |
||
| 75 | 'Line:' . __LINE__ . ' value2 should pass and return true.' |
||
| 76 | ); |
||
| 77 | } |
||
| 78 | } |
||
| 79 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.