wiki.techinc.nl/tests/phpunit/includes/libs/DeferredStringifierTest.php
Umherirrender be42e09aa8 build: Prepare for mediawiki/mediawiki-codesniffer to 0.9.0
The used phpcs has a bug, so the version 0.9.0 could not be enforced at the moment.
Will be fixed in next version, see T167168

Changed:
- Remove duplicate newline at end of file
- Add space between function and ( for closures
- and -> &&, or -> ||

Change-Id: I4172fb08861729bccd55aecbd07e029e2638d311
2017-06-26 17:14:31 +00:00

50 lines
936 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 );
}
}