tests/Encoder/EncodeSimpleObjectsTest.php
/**
     * Test encode simple object as resource identity.
     */
Test encode simple object as resource identity.
Test encode simple object as resource identity .
public function testEncodeObjectAsResourceIdentity(): void
    {
        $author  = Author::instance(9, 'Dan', 'Gebhardt')->setIdentifierMeta('id meta');
        $encoder = Encoder::instance(
            [
                Author::class => function ($factory) {
                    $schema = new AuthorSchema($factory);
                    return $schema;
                },
            ]
        )->withUrlPrefix('http://example.com');
        $actual = $encoder->encodeIdentifiers($author);
        $expected = <<<EOL
        {
            "data" : {
                "type" : "people",
                "id"   : "9",
                "meta": "id meta"
            }
        }
EOL;
        self::assertJsonStringEqualsJsonString($expected, $actual);
    }
public function testEncodeObjectAsResourceIdentity ( ) : void { $ author = Author :: instance ( 9 , 'Dan' , 'Gebhardt' ) -> setIdentifierMeta ( 'id meta' ) ; $ encoder = Encoder :: instance ( [ Author :: class => function ( $ factory ) { $ schema = new AuthorSchema ( $ factory ) ; return $ schema ; } , ] ) -> withUrlPrefix ( 'http://example.com' ) ; $ actual = $ encoder -> encodeIdentifiers ( $ author ) ; $ expected = <<< EOL         {             "data" : {                 "type" : "people",                 "id"   : "9",                 "meta": "id meta"             }         } 
EOL ; self :: assertJsonStringEqualsJsonString ( $ expected , $ actual ) ; }
Test encode simple object as resource identity.
Test encode simple object as resource identity .