MediaWiki REL1_33
DeferredStringifierTest.php
Go to the documentation of this file.
1<?php
2
6class DeferredStringifierTest extends PHPUnit\Framework\TestCase {
7
8 use MediaWikiCoversValidator;
9
13 public function testToString( $params, $expected ) {
14 $class = new ReflectionClass( DeferredStringifier::class );
15 $ds = $class->newInstanceArgs( $params );
16 $this->assertEquals( $expected, (string)$ds );
17 }
18
19 public static function provideToString() {
20 return [
21 // No args
22 [
23 [
24 function () {
25 return 'foo';
26 }
27 ],
28 'foo'
29 ],
30 // Has args
31 [
32 [
33 function ( $i ) {
34 return $i;
35 },
36 'bar'
37 ],
38 'bar'
39 ],
40 ];
41 }
42
47 public function testCallbackNotCalled() {
48 $ds = new DeferredStringifier( function () {
49 throw new Exception( 'This should not be reached!' );
50 } );
51 // No exception was thrown
52 $this->assertTrue( true );
53 }
54}
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
testCallbackNotCalled()
Verify that the callback is not called if it is never converted to a string.
testToString( $params, $expected)
provideToString
$params