@@ 43-75 (lines=33) @@ | ||
40 | * |
|
41 | * @return void |
|
42 | */ |
|
43 | public function testEmail() |
|
44 | { |
|
45 | $rule = new RuleEmail; |
|
46 | $xml = simplexml_load_string('<form><field name="email1" /><field name="email2" unique="true" /></form>'); |
|
47 | ||
48 | // Test fail conditions. |
|
49 | ||
50 | $this->assertThat( |
|
51 | $rule->test($xml->field[0], 'bogus'), |
|
52 | $this->isFalse(), |
|
53 | 'Line:' . __LINE__ . ' The rule should fail and return false.' |
|
54 | ); |
|
55 | ||
56 | // Test pass conditions. |
|
57 | ||
58 | $this->assertThat( |
|
59 | $rule->test($xml->field[0], '[email protected]'), |
|
60 | $this->isTrue(), |
|
61 | 'Line:' . __LINE__ . ' The basic rule should pass and return true.' |
|
62 | ); |
|
63 | ||
64 | $this->markTestIncomplete('More tests required'); |
|
65 | ||
66 | /* |
|
67 | TODO: Need to test the "field" attribute which adds to the unique test where clause. |
|
68 | TODO: Database error is prevents the following tests from working properly. |
|
69 | */ |
|
70 | $this->assertThat( |
|
71 | $rule->test($xml->field[1], '[email protected]'), |
|
72 | $this->isTrue(), |
|
73 | 'Line:' . __LINE__ . ' The unique rule should pass and return true.' |
|
74 | ); |
|
75 | } |
|
76 | ||
77 | /** |
|
78 | * Data Provider for email rule test with no multiple attribute and no tld attribute |
@@ 49-77 (lines=29) @@ | ||
46 | * |
|
47 | * @since 1.0 |
|
48 | */ |
|
49 | 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 |