tests/Encoder/EncodeSimpleObjectsTest.php
/**
     * Test encode simple object in pretty format.
     */
Test encode simple object in pretty format.
Test encode simple object in pretty format .
public function testEncodeObjectWithAttributesOnlyPrettyPrinted(): void
    {
        $author  = Author::instance(9, 'Dan', 'Gebhardt');
        $encoder = Encoder::instance(
            [
                Author::class => function ($factory) {
                    $schema = new AuthorSchema($factory);
                    $schema->removeRelationship(Author::LINK_COMMENTS);
                    return $schema;
                },
            ]
        )->withUrlPrefix('http://example.com')->withEncodeOptions(JSON_PRETTY_PRINT);
        $actual = $encoder->encodeData($author);
        $expected = <<<EOL
{
    "data": {
        "type": "people",
        "id": "9",
        "attributes": {
            "first_name": "Dan",
            "last_name": "Gebhardt"
        },
        "links": {
            "self": "http:\/\/example.com\/people\/9"
        }
    }
}
EOL;
        self::assertJsonStringEqualsJsonString($expected, $actual);
    }
public function testEncodeObjectWithAttributesOnlyPrettyPrinted ( ) : void { $ author = Author :: instance ( 9 , 'Dan' , 'Gebhardt' ) ; $ encoder = Encoder :: instance ( [ Author :: class => function ( $ factory ) { $ schema = new AuthorSchema ( $ factory ) ; $ schema -> removeRelationship ( Author :: LINK_COMMENTS ) ; return $ schema ; } , ] ) -> withUrlPrefix ( 'http://example.com' ) -> withEncodeOptions ( JSON_PRETTY_PRINT ) ; $ actual = $ encoder -> encodeData ( $ author ) ; $ expected = <<< EOL {     "data": {         "type": "people",         "id": "9",         "attributes": {             "first_name": "Dan",             "last_name": "Gebhardt"         },         "links": {             "self": "http:\/\/example.com\/people\/9"         }     } } 
EOL ; self :: assertJsonStringEqualsJsonString ( $ expected , $ actual ) ; }
Test encode simple object in pretty format.
Test encode simple object in pretty format .