update 1.0.8.0
Commits for version update
This commit is contained in:
41
vendor/mtdowling/jmespath.php/tests/FnDispatcherTest.php
vendored
Normal file
41
vendor/mtdowling/jmespath.php/tests/FnDispatcherTest.php
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
namespace JmesPath\Tests;
|
||||
|
||||
use JmesPath\FnDispatcher;
|
||||
|
||||
class FnDispatcherTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testConvertsToString()
|
||||
{
|
||||
$fn = new FnDispatcher();
|
||||
$this->assertEquals('foo', $fn('to_string', ['foo']));
|
||||
$this->assertEquals('1', $fn('to_string', [1]));
|
||||
$this->assertEquals('["foo"]', $fn('to_string', [['foo']]));
|
||||
$std = new \stdClass();
|
||||
$std->foo = 'bar';
|
||||
$this->assertEquals('{"foo":"bar"}', $fn('to_string', [$std]));
|
||||
$this->assertEquals('foo', $fn('to_string', [new _TestStringClass()]));
|
||||
$this->assertEquals('"foo"', $fn('to_string', [new _TestJsonStringClass()]));
|
||||
}
|
||||
}
|
||||
|
||||
class _TestStringClass
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return 'foo';
|
||||
}
|
||||
}
|
||||
|
||||
class _TestJsonStringClass implements \JsonSerializable
|
||||
{
|
||||
public function __toString()
|
||||
{
|
||||
return 'no!';
|
||||
}
|
||||
|
||||
public function jsonSerialize()
|
||||
{
|
||||
return 'foo';
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user