r92209 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92208‎ | r92209 | r92210 >
Date:22:40, 14 July 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added test and updated rel notes
Modified paths:
  • /trunk/extensions/Validator/RELEASE-NOTES (modified) (history)
  • /trunk/extensions/Validator/test/ValidatorCriteriaTests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/RELEASE-NOTES
@@ -7,11 +7,11 @@
88 === Validator 0.4.8 ===
99 (2011-xx-xx)
1010
11 -* Added unit tests.
 11+* Added unit tests for the criteria.
1212
1313 * Fixed issue with handling floats in CriterionInRange.
1414
15 -* Added support for open limits in CriterionHasLength.
 15+* Added support for open limits in CriterionHasLength and CriterionItemCount.
1616
1717 === Validator 0.4.7 ===
1818 (2011-05-15)
Index: trunk/extensions/Validator/test/ValidatorCriteriaTests.php
@@ -215,4 +215,31 @@
216216 }
217217 }
218218
 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+
219246 }