HummingBirdAnimeClient/tests/Ion/View/JsonViewTest.php

44 lines
973 B
PHP

<?php
use Aviat\Ion\Friend;
use Aviat\Ion\View\JsonView;
include_once __DIR__ . "/../ViewTest.php";
class TestJsonView extends JsonView {
public function __destruct() {}
}
class JsonViewTest extends ViewTest {
public function setUp()
{
parent::setUp();
$this->view = new TestJsonView($this->container);
$this->friend = new Friend($this->view);
}
public function testSetOutput()
{
// Extend view class to remove destructor which does output
$view = new TestJsonView($this->container);
// Json encode non-string
$content = ['foo' => 'bar'];
$expected = json_encode($content);
$this->view->setOutput($content);
$this->assertEquals($expected, $this->view->getOutput());
// Directly set string
$content = '{}';
$expected = '{}';
$this->view->setOutput($content);
$this->assertEquals($expected, $this->view->getOutput());
}
public function testOutput()
{
$this->assertEquals('application/json', $this->friend->contentType);
}
}