Fix view tests

This commit is contained in:
Timothy Warren 2016-01-08 11:19:56 -05:00
parent 27ac7e8063
commit f5549934fe
3 changed files with 37 additions and 54 deletions

View File

@ -1,8 +1,8 @@
<?php
include_once __DIR__ . "/../ViewTest.php";
include_once __DIR__ . "HttpViewTest.php";
class HtmlViewTest extends ViewTest {
class HtmlViewTest extends HttpViewTest {
protected $template_path;

View File

@ -1,10 +1,8 @@
<?php
include_once __DIR__ . "/../ViewTest.php";
use Aviat\Ion\Friend;
class HttpViewTest extends ViewTest {
class HttpViewTest extends AnimeClient_TestCase {
public function setUp()
{
@ -19,4 +17,38 @@ class HttpViewTest extends ViewTest {
$this->assertEquals('/foo', $this->friend->response->headers->get('Location'));
$this->assertEquals(303, $this->friend->response->status->getCode());
}
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());
}
}

View File

@ -1,49 +0,0 @@
<?php
use Aura\Web\WebFactory;
use Aviat\Ion\Friend;
class ViewTest extends AnimeClient_TestCase {
public function setUp()
{
parent::setUp();
$this->view = new TestView($this->container);
$this->friend = new Friend($this->view);
}
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());
}
}