Flugg\Responder\Tests\Unit\SuccessResponseBuilderTest::toArrayMethodShouldTransformData PHP Method

toArrayMethodShouldTransformData() public method

Test that the [toArray] method also transforms the data using the set transformer.
    public function toArrayMethodShouldTransformData()
    {
        // Arrange...
        $responseBuilder = $this->app->make('responder.success');
        $model = $this->makeModel(['foo' => 123]);
        $responseBuilder->transform($model, function ($model) {
            return ['foo' => (string) $model->foo];
        });
        // Act...
        $array = $responseBuilder->toArray();
        // Assert...
        $this->assertContains(['foo' => '123'], $array);
    }
SuccessResponseBuilderTest