| @@ 94-103 (lines=10) @@ | ||
| 91 | * |
|
| 92 | * @return void |
|
| 93 | */ |
|
| 94 | public function testColorData($color, $expectedResult) |
|
| 95 | { |
|
| 96 | $rule = new RuleColor; |
|
| 97 | $xml = simplexml_load_string('<form><field name="color1" /></form>'); |
|
| 98 | $this->assertThat( |
|
| 99 | $rule->test($xml->field[0], $color), |
|
| 100 | $this->equalTo($expectedResult), |
|
| 101 | $color . ' should have returned ' . ($expectedResult ? 'true' : 'false') . ' but did not' |
|
| 102 | ); |
|
| 103 | } |
|
| 104 | } |
|
| 105 | ||
| @@ 111-120 (lines=10) @@ | ||
| 108 | * |
|
| 109 | * @since 11.1 |
|
| 110 | */ |
|
| 111 | public function testEmailData($emailAddress, $expectedResult) |
|
| 112 | { |
|
| 113 | $rule = new RuleEmail; |
|
| 114 | $xml = simplexml_load_string('<form><field name="email1" /></form>'); |
|
| 115 | $this->assertThat( |
|
| 116 | $rule->test($xml->field[0], $emailAddress), |
|
| 117 | $this->equalTo($expectedResult), |
|
| 118 | $emailAddress . ' should have returned ' . ($expectedResult ? 'true' : 'false') . ' but did not' |
|
| 119 | ); |
|
| 120 | } |
|
| 121 | ||
| 122 | /** |
|
| 123 | * Data Provider for email rule test with multiple attribute and no tld attribute |
|
| @@ 149-158 (lines=10) @@ | ||
| 146 | * |
|
| 147 | * @since 12.3 |
|
| 148 | */ |
|
| 149 | public function testEmailData2($emailAddress, $expectedResult) |
|
| 150 | { |
|
| 151 | $rule = new RuleEmail; |
|
| 152 | $xml = simplexml_load_string('<form><field name="email1" multiple="multiple" /></form>'); |
|
| 153 | $this->assertThat( |
|
| 154 | $rule->test($xml->field[0], $emailAddress), |
|
| 155 | $this->equalTo($expectedResult), |
|
| 156 | $emailAddress . ' should have returned ' . ($expectedResult ? 'true' : 'false') . ' but did not' |
|
| 157 | ); |
|
| 158 | } |
|
| 159 | ||
| 160 | /** |
|
| 161 | * Data Provider for email rule test with tld attribute |
|
| @@ 190-199 (lines=10) @@ | ||
| 187 | * |
|
| 188 | * @since 12.3 |
|
| 189 | */ |
|
| 190 | public function testEmailData3($emailAddress, $expectedResult) |
|
| 191 | { |
|
| 192 | $rule = new RuleEmail; |
|
| 193 | $xml = simplexml_load_string('<form><field name="email1" tld="tld" /></form>'); |
|
| 194 | $this->assertThat( |
|
| 195 | $rule->test($xml->field[0], $emailAddress), |
|
| 196 | $this->equalTo($expectedResult), |
|
| 197 | $emailAddress . ' should have returned ' . ($expectedResult ? 'true' : 'false') . ' but did not' |
|
| 198 | ); |
|
| 199 | } |
|
| 200 | } |
|
| 201 | ||