Add @covers tags for more tests
[lhc/web/wiklou.git] / tests / phpunit / includes / libs / DeferredStringifierTest.php
1 <?php
2
3 /**
4 * @covers DeferredStringifier
5 */
6 class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
7
8 /**
9 * @dataProvider provideToString
10 */
11 public function testToString( $params, $expected ) {
12 $class = new ReflectionClass( 'DeferredStringifier' );
13 $ds = $class->newInstanceArgs( $params );
14 $this->assertEquals( $expected, (string)$ds );
15 }
16
17 public static function provideToString() {
18 return [
19 // No args
20 [
21 [
22 function () {
23 return 'foo';
24 }
25 ],
26 'foo'
27 ],
28 // Has args
29 [
30 [
31 function ( $i ) {
32 return $i;
33 },
34 'bar'
35 ],
36 'bar'
37 ],
38 ];
39 }
40
41 /**
42 * Verify that the callback is not called if
43 * it is never converted to a string
44 */
45 public function testCallbackNotCalled() {
46 $ds = new DeferredStringifier( function () {
47 throw new Exception( 'This should not be reached!' );
48 } );
49 // No exception was thrown
50 $this->assertTrue( true );
51 }
52 }