Elgg\Http\ResponseFactoryTest::testCanSendAjaxResponseFromApiResponse PHP Метод

testCanSendAjaxResponseFromApiResponse() публичный Метод

    public function testCanSendAjaxResponseFromApiResponse()
    {
        $service = $this->createService();
        ob_start();
        $data = ['foo' => 'bar'];
        $wrapped_content = json_encode(['value' => $data]);
        $api_response = new \Elgg\Ajax\Response();
        $api_response->setData((object) ['value' => $data]);
        $response = $service->send($this->ajax->respondFromApiResponse($api_response));
        $this->assertInstanceOf(JsonResponse::class, $response);
        $this->assertEquals($wrapped_content, $response->getContent());
        $output = ob_get_clean();
        $this->assertEquals($wrapped_content, $output);
    }