HummingBirdAnimeClient/tests/Ion/View/HttpViewTest.php

54 lines
1.5 KiB
PHP
Raw Normal View History

2015-10-15 09:25:30 -04:00
<?php
use Aviat\Ion\Friend;
2016-01-08 11:19:56 -05:00
class HttpViewTest extends AnimeClient_TestCase {
2015-10-15 09:25:30 -04:00
public function setUp()
{
parent::setUp();
$this->view = new TestHttpView($this->container);
$this->friend = new Friend($this->view);
}
public function testRedirect()
{
$this->friend->redirect('/foo', 303);
$this->assertEquals('/foo', $this->friend->response->headers->get('Location'));
$this->assertEquals(303, $this->friend->response->status->getCode());
}
2016-01-08 11:19:56 -05:00
public function testGetOutput()
{
$this->friend->output = 'foo';
$this->assertEquals($this->friend->output, $this->friend->getOutput());
$this->assertFalse($this->friend->hasRendered);
$this->assertEquals($this->friend->getOutput(), $this->friend->__toString());
$this->assertTrue($this->friend->hasRendered);
}
public function testSetOutput()
{
$same = $this->view->setOutput('<h1></h1>');
$this->assertEquals($same, $this->view);
$this->assertEquals('<h1></h1>', $this->view->getOutput());
}
public function testAppendOutput()
{
$this->view->setOutput('<h1>');
$this->view->appendOutput('</h1>');
$this->assertEquals('<h1></h1>', $this->view->getOutput());
}
public function testOutput()
{
$this->friend->contentType = 'text/html';
$this->friend->__destruct();
$content =& $this->friend->response->content;
$this->assertEquals($content->getType(), $this->friend->contentType);
$this->assertEquals($content->getCharset(), 'utf-8');
$this->assertEquals($content->get(), $this->friend->getOutput());
}
2015-10-15 09:25:30 -04:00
}