@@ 106-116 (lines=11) @@ | ||
103 | } |
|
104 | } |
|
105 | ||
106 | public function testValidateCountryCode() { |
|
107 | $this->assertEquals('US', RestValidatorHelper::validate_country_code(['cc' => 'US'], 'cc')); |
|
108 | $this->assertEquals(null, RestValidatorHelper::validate_country_code([], 'cc', ['required' => false])); |
|
109 | ||
110 | TestHelper::assertException(function() { |
|
111 | RestValidatorHelper::validate_country_code(['cc' => 'FOO'], 'cc'); |
|
112 | }, 'ValidationException'); |
|
113 | TestHelper::assertException(function() { |
|
114 | RestValidatorHelper::validate_country_code([], 'cc'); |
|
115 | }, 'ValidationException'); |
|
116 | } |
|
117 | ||
118 | public function testValidateEmail() { |
|
119 | $this->assertEquals('[email protected]', RestValidatorHelper::validate_email(['mail' => '[email protected]'], 'mail')); |
|
@@ 118-129 (lines=12) @@ | ||
115 | }, 'ValidationException'); |
|
116 | } |
|
117 | ||
118 | public function testValidateEmail() { |
|
119 | $this->assertEquals('[email protected]', RestValidatorHelper::validate_email(['mail' => '[email protected]'], 'mail')); |
|
120 | ||
121 | TestHelper::assertException(function() { |
|
122 | RestValidatorHelper::validate_email(['mail' => 'FOO'], 'mail'); |
|
123 | }, 'ValidationException'); |
|
124 | ||
125 | $this->assertEquals(null, RestValidatorHelper::validate_email([], 'mail', ['required' => false])); |
|
126 | TestHelper::assertException(function() { |
|
127 | RestValidatorHelper::validate_email([], 'mail'); |
|
128 | }, 'ValidationException'); |
|
129 | } |
|
130 | ||
131 | public function testValidateUrl() { |
|
132 | $this->assertEquals('http://test.com', RestValidatorHelper::validate_url(['url' => 'http://test.com'], 'url')); |
|
@@ 131-142 (lines=12) @@ | ||
128 | }, 'ValidationException'); |
|
129 | } |
|
130 | ||
131 | public function testValidateUrl() { |
|
132 | $this->assertEquals('http://test.com', RestValidatorHelper::validate_url(['url' => 'http://test.com'], 'url')); |
|
133 | ||
134 | TestHelper::assertException(function() { |
|
135 | RestValidatorHelper::validate_url(['url' => 'FOO'], 'url'); |
|
136 | }, 'ValidationException'); |
|
137 | ||
138 | $this->assertEquals(null, RestValidatorHelper::validate_url([], 'url', ['required' => false])); |
|
139 | TestHelper::assertException(function() { |
|
140 | RestValidatorHelper::validate_url([], 'url'); |
|
141 | }, 'ValidationException'); |
|
142 | } |
|
143 | ||
144 | ||
145 | public function testValidateString() { |
|
@@ 196-207 (lines=12) @@ | ||
193 | } |
|
194 | ||
195 | ||
196 | public function testValidateDatetime() { |
|
197 | $this->assertEquals('2015-08-07 12:13:14', RestValidatorHelper::validate_datetime(['date' => '2015-08-07 12:13:14'], 'date')); |
|
198 | $this->assertEquals(null, RestValidatorHelper::validate_datetime([], 'date', ['required' => false])); |
|
199 | ||
200 | TestHelper::assertException(function() { |
|
201 | RestValidatorHelper::validate_datetime([], 'date'); |
|
202 | }, 'ValidationException'); |
|
203 | ||
204 | TestHelper::assertException(function() { |
|
205 | RestValidatorHelper::validate_datetime(['date' => 'error'], 'date'); |
|
206 | }, 'ValidationException'); |
|
207 | } |
|
208 | ||
209 | } |
|
210 |