lithium\tests\cases\net\http\MediaTest::testManualContentHandling PHP Метод

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

Tests handling content type manually using parameters to Media::render(), for content types that are registered but have no default handler.
    public function testManualContentHandling()
    {
        Media::type('custom', 'text/x-custom');
        $response = new Response();
        $response->type('custom');
        Media::render($response, 'Hello, world!', array('layout' => false, 'template' => false, 'encode' => function ($data) {
            return "Message: {$data}";
        }));
        $result = $response->body;
        $expected = array("Message: Hello, world!");
        $this->assertEqual($expected, $result);
        $this->assertException("/Template not found/", function () use($response) {
            Media::render($response, 'Hello, world!');
        });
    }