/** * Tests that attempts to render a media type with no handler registered produces an * 'unhandled media type' exception, even if the type itself is a registered content type. * * @return void */ public function testUnregisteredContentHandler() { $response = new Response(); $response->type('xml'); $this->expectException("Unhandled media type `xml`."); Media::render($response, array('foo' => 'bar')); $result = $response->body; $this->assertNull($result); }
public function testDefaultTypeInitialization() { $response = new Response(array('request' => new MockRequestType())); $this->assertEqual('foo', $response->type()); }
public function testRenderWithOptionsMerging() { $base = Libraries::get(true, 'resources') . '/tmp'; $this->skipIf(!is_writable($base), "Path `{$base}` is not writable."); $request = new Request(); $request->params['controller'] = 'pages'; $response = new Response(); $response->type('html'); $this->assertException("/Template not found/", function () use($response) { Media::render($response, null, compact('request')); }); $this->_cleanUp(); }
public function testRender() { $response = new Response(); $response->type('json'); $data = array('something'); Media::render($response, $data); $expected = array('Content-type: application/json'); $result = $response->headers(); $this->assertEqual($expected, $result); $expected = json_encode($data); $result = $response->body(); $this->assertEqual($expected, $result); }