Merge "maintenance: Script to rename titles for Unicode uppercasing changes"
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / ParamValidator / TypeDef / BooleanDefTest.php
1 <?php
2
3 namespace Wikimedia\ParamValidator\TypeDef;
4
5 use Wikimedia\ParamValidator\ValidationException;
6
7 /**
8 * @covers \Wikimedia\ParamValidator\TypeDef\BooleanDef
9 */
10 class BooleanDefTest extends TypeDefTestCase {
11
12 protected static $testClass = BooleanDef::class;
13
14 public function provideValidate() {
15 $ex = new ValidationException( 'test', '', [], 'badbool', [
16 'truevals' => BooleanDef::$TRUEVALS,
17 'falsevals' => array_merge( BooleanDef::$FALSEVALS, [ 'the empty string' ] ),
18 ] );
19
20 foreach ( [
21 [ BooleanDef::$TRUEVALS, true ],
22 [ BooleanDef::$FALSEVALS, false ],
23 [ [ '' ], false ],
24 [ [ '2', 'foobar' ], $ex ],
25 ] as list( $vals, $expect ) ) {
26 foreach ( $vals as $v ) {
27 yield "Value '$v'" => [ $v, $expect ];
28 $v2 = ucfirst( $v );
29 if ( $v2 !== $v ) {
30 yield "Value '$v2'" => [ $v2, $expect ];
31 }
32 $v3 = strtoupper( $v );
33 if ( $v3 !== $v2 ) {
34 yield "Value '$v3'" => [ $v3, $expect ];
35 }
36 }
37 }
38 }
39
40 public function provideStringifyValue() {
41 return [
42 [ true, 'true' ],
43 [ false, 'false' ],
44 ];
45 }
46
47 }