Per wikitech-l consensus: https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html Notes: * Disabled CallTimePassByReference due to false positives (T127163) Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
50 lines
933 B
PHP
50 lines
933 B
PHP
<?php
|
|
|
|
class DeferredStringifierTest extends PHPUnit_Framework_TestCase {
|
|
|
|
/**
|
|
* @covers DeferredStringifier
|
|
* @dataProvider provideToString
|
|
*/
|
|
public function testToString( $params, $expected ) {
|
|
$class = new ReflectionClass( 'DeferredStringifier' );
|
|
$ds = $class->newInstanceArgs( $params );
|
|
$this->assertEquals( $expected, (string)$ds );
|
|
}
|
|
|
|
public static function provideToString() {
|
|
return [
|
|
// No args
|
|
[
|
|
[
|
|
function() {
|
|
return 'foo';
|
|
}
|
|
],
|
|
'foo'
|
|
],
|
|
// Has args
|
|
[
|
|
[
|
|
function( $i ) {
|
|
return $i;
|
|
},
|
|
'bar'
|
|
],
|
|
'bar'
|
|
],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* Verify that the callback is not called if
|
|
* it is never converted to a string
|
|
*/
|
|
public function testCallbackNotCalled() {
|
|
$ds = new DeferredStringifier( function() {
|
|
throw new Exception( 'This should not be reached!' );
|
|
} );
|
|
// No exception was thrown
|
|
$this->assertTrue( true );
|
|
}
|
|
}
|