Merge "DatabaseMssql: Don't duplicate body of makeList()"
[mediawiki.git] / tests / phpunit / includes / libs / DeferredStringifierTest.php
blob8b7610ae7b76caebd7ddc350009d426086bff83f
1 <?php
3 class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
5 /**
6 * @covers DeferredStringifier
7 * @dataProvider provideToString
8 */
9 public function testToString( $params, $expected ) {
10 $class = new ReflectionClass( 'DeferredStringifier' );
11 $ds = $class->newInstanceArgs( $params );
12 $this->assertEquals( $expected, (string)$ds );
15 public static function provideToString() {
16 return array(
17 // No args
18 array(
19 array(
20 function() {
21 return 'foo';
24 'foo'
26 // Has args
27 array(
28 array(
29 function( $i ) {
30 return $i;
32 'bar'
34 'bar'
39 /**
40 * Verify that the callback is not called if
41 * it is never converted to a string
43 public function testCallbackNotCalled() {
44 $ds = new DeferredStringifier( function() {
45 throw new Exception( 'This should not be reached!' );
46 } );
47 // No exception was thrown
48 $this->assertTrue( true );