Elgg\Json\EmptyKeyEncodingTest::testRoundTrip PHP Метод

testRoundTrip() публичный Метод

public testRoundTrip ( )
    function testRoundTrip()
    {
        $json = <<<EOL
{
    "": [
    \t{
\t\t\t"autoload": {
\t\t\t\t"psr-0": {
\t\t\t\t\t"": "engine/classes/"
\t\t\t\t}
\t\t\t}
    \t}
    ],
    "foo": true
}
EOL;
        $encoding = new EmptyKeyEncoding();
        $value = $encoding->decode($json);
        $empty_key = $encoding->getEmptyKey();
        $this->assertTrue(is_array($value->{$empty_key}));
        $this->assertFalse(property_exists($value, '_empty_'));
        $this->assertEquals('engine/classes/', $value->{$empty_key}[0]->autoload->{'psr-0'}->{$empty_key});
        $json = $encoding->encode($value, JSON_UNESCAPED_SLASHES);
        $this->assertContains('"":"engine/classes/"', $json);
        $this->assertContains('"":[{"autoload"', $json);
        $this->assertNotContains($empty_key, $json);
    }