Index: trunk/extensions/Validator/RELEASE-NOTES |
— | — | @@ -7,11 +7,11 @@ |
8 | 8 | === Validator 0.4.8 === |
9 | 9 | (2011-xx-xx) |
10 | 10 | |
11 | | -* Added unit tests. |
| 11 | +* Added unit tests for the criteria. |
12 | 12 | |
13 | 13 | * Fixed issue with handling floats in CriterionInRange. |
14 | 14 | |
15 | | -* Added support for open limits in CriterionHasLength. |
| 15 | +* Added support for open limits in CriterionHasLength and CriterionItemCount. |
16 | 16 | |
17 | 17 | === Validator 0.4.7 === |
18 | 18 | (2011-05-15) |
Index: trunk/extensions/Validator/test/ValidatorCriteriaTests.php |
— | — | @@ -215,4 +215,31 @@ |
216 | 216 | } |
217 | 217 | } |
218 | 218 | |
| 219 | + /** |
| 220 | + * Tests CriterionNotEmpty. |
| 221 | + */ |
| 222 | + public function testCriterionNotEmpty() { |
| 223 | + $tests = array( |
| 224 | + array( true, 'a' ), |
| 225 | + array( true, ' a ' ), |
| 226 | + array( false, '' ), |
| 227 | + array( false, ' ' ), |
| 228 | + array( false, "\n" ), |
| 229 | + array( false, " \n " ), |
| 230 | + array( true, " \n ." ), |
| 231 | + ); |
| 232 | + |
| 233 | + foreach ( $tests as $test ) { |
| 234 | + $c = new CriterionNotEmpty(); |
| 235 | + $p = new Parameter( 'test' ); |
| 236 | + $p->setUserValue( 'test', $test[1] ); |
| 237 | + |
| 238 | + $this->assertEquals( |
| 239 | + $test[0], |
| 240 | + $c->validate( $p, array() )->isValid(), |
| 241 | + 'Value "'. $test[1]. '" should ' . ( !$test[0] ? '' : 'not ' ) . " be empty." |
| 242 | + ); |
| 243 | + } |
| 244 | + } |
| 245 | + |
219 | 246 | } |