tests/Encoder/EncoderTest.php
/**
     * Test encode unrecognized resource (no registered Schema).
     */
Test encode unrecognized resource (no registered Schema).
Test encode unrecognized resource ( no registered Schema ) .
public function testEncodeUnrecognizedResourceInRelationship(): void
    {
        $author = Author::instance(9, 'Dan', 'Gebhardt');
        $post   = Post::instance(1, 'Title', 'Body', null, [Comment::instance(5, 'First!', $author)]);
        $catch = null;
        try {
            Encoder::instance(
                [
                    Comment::class => CommentSchema::class,
                    Post::class    => PostSchema::class,
                ]
            )->withUrlPrefix('http://example.com')->withIncludedPaths(
                [
                    Post::LINK_COMMENTS,
                ]
            )->encodeData($post);
        } catch (InvalidArgumentException $exception) {
            $catch = $exception;
        }
        self::assertNotNull($catch);
        self::assertStringContainsString(Post::LINK_COMMENTS . '.' . Comment::LINK_AUTHOR, $catch->getMessage());
    }
public function testEncodeUnrecognizedResourceInRelationship ( ) : void { $ author = Author :: instance ( 9 , 'Dan' , 'Gebhardt' ) ; $ post = Post :: instance ( 1 , 'Title' , 'Body' , null , [ Comment :: instance ( 5 , 'First!' , $ author ) ] ) ; $ catch = null ; try { Encoder :: instance ( [ Comment :: class => CommentSchema :: class , Post :: class => PostSchema :: class , ] ) -> withUrlPrefix ( 'http://example.com' ) -> withIncludedPaths ( [ Post :: LINK_COMMENTS , ] ) -> encodeData ( $ post ) ; } catch ( InvalidArgumentException $ exception ) { $ catch = $ exception ; } self :: assertNotNull ( $ catch ) ; self :: assertStringContainsString ( Post :: LINK_COMMENTS . '.' . Comment :: LINK_AUTHOR , $ catch -> getMessage ( ) ) ; }
Test encode unrecognized resource (no registered Schema).
Test encode unrecognized resource ( no registered Schema ) .
/** @var InvalidArgumentException $catch */