r92204 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r92203‎ | r92204 | r92205 >
Date:21:49, 14 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
@@ -157,4 +157,32 @@
158158 }
159159 }
160160
 161+ /**
 162+ * Tests CriterionUniqueItems.
 163+ */
 164+ public function testCriterionUniqueItems() {
 165+ $tests = array(
 166+ array( true, array( 'foo', 'bar', 'baz' ), false ),
 167+ array( true, array( 'foo', 'bar', 'baz' ), true ),
 168+ array( false, array( 'foo', 'bar', 'baz', 'foo' ), false ),
 169+ array( false, array( 'foo', 'bar', 'baz', 'foo' ), true ),
 170+ array( false, array( 'foo', 'bar', 'baz', 'FOO' ), false ),
 171+ array( true, array( 'foo', 'bar', 'baz', 'FOO' ), true ),
 172+ array( true, array(), false ),
 173+ );
 174+
 175+ foreach ( $tests as $test ) {
 176+ $c = new CriterionUniqueItems( $test[2] );
 177+ $p = new ListParameter( 'test' );
 178+ $p->setUserValue( 'test', '' );
 179+ $p->setValue( $test[1] );
 180+
 181+ $this->assertEquals(
 182+ $test[0],
 183+ $c->validate( $p, array() ),
 184+ 'Value "'. $test[1] . '" should ' . ( $test[0] ? '' : 'not ' ) . " have unique items."
 185+ );
 186+ }
 187+ }
 188+
161189 }