diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-05-01 15:30:02 -0400 |
commit | 1de335ad3f395ca6861085393ba366a9e3fb4a0d (patch) | |
tree | f1fdd326034e05177596851be6a7127615d81498 /tests/phpunit/includes/libs/DeferredStringifierTest.php | |
parent | 9c75fa8ff6d4d38ef552c00fef5969fb154765e8 (diff) | |
parent | f6d65e533c62f6deb21342d4901ece24497b433e (diff) |
Merge commit 'f6d65'
# Conflicts:
# skins/ArchLinux/ArchLinux.php
Diffstat (limited to 'tests/phpunit/includes/libs/DeferredStringifierTest.php')
-rw-r--r-- | tests/phpunit/includes/libs/DeferredStringifierTest.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/phpunit/includes/libs/DeferredStringifierTest.php b/tests/phpunit/includes/libs/DeferredStringifierTest.php new file mode 100644 index 00000000..8b7610ae --- /dev/null +++ b/tests/phpunit/includes/libs/DeferredStringifierTest.php @@ -0,0 +1,50 @@ +<?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 array( + // No args + array( + array( + function() { + return 'foo'; + } + ), + 'foo' + ), + // Has args + array( + array( + 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 ); + } +} |