r92099 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92098‎ | r92099 | r92100 >
Date:21:07, 13 July 2011
Author:jeroendedauw
Status:deferred
Tags:
Comment:
added test
Modified paths:
  • /trunk/extensions/Validator/test/ValidatorCriteriaTests.php (modified) (history)

Diff [purge]

Index: trunk/extensions/Validator/test/ValidatorCriteriaTests.php
@@ -38,5 +38,30 @@
3939 );
4040 }
4141 }
 42+
 43+ /**
 44+ * Tests CriterionInArray.
 45+ */
 46+ public function testCriterionInArray() {
 47+ $tests = array(
 48+ array( true, 'foo', false, array( 'foo', 'bar', 'baz' ) ),
 49+ array( true, 'FoO', false, array( 'fOo', 'bar', 'baz' ) ),
 50+ array( false, 'FoO', true, array( 'fOo', 'bar', 'baz' ) ),
 51+ array( false, 'foobar', false, array( 'foo', 'bar', 'baz' ) ),
 52+ array( false, '', false, array( 'foo', 'bar', 'baz' ) ),
 53+ array( false, '', false, array( 'foo', 'bar', 'baz', 0 ) ),
 54+ );
 55+
 56+ foreach ( $tests as $test ) {
 57+ $c = new CriterionInArray( $test[3], $test[2] );
 58+ $p = new Parameter( 'test' );
 59+ $p->setUserValue( 'test', $test[1] );
 60+ $this->assertEquals(
 61+ $test[0],
 62+ $c->validate( $p, array() )->isValid(),
 63+ 'Value "'. $test[1] . '" should ' . ( $test[0] ? '' : 'not ' ) . "be in list '" . $GLOBALS['wgLang']->listToText( $test[3] ) . "'."
 64+ );
 65+ }
 66+ }
4267
4368 }