public function testCanFilterFields() { $data = (object) ['id' => '123', 'foo' => 'bar', 'baz' => 'qux']; $resource = new Resource($data, new PostSerializer4()); $resource->fields(['posts' => ['baz']]); $this->assertEquals(['type' => 'posts', 'id' => '123', 'attributes' => ['baz' => 'qux']], $resource->toArray()); }