HummingBirdAnimeClient/tests/Ion/View/JsonViewTest.php

39 lines
875 B
PHP
Raw Normal View History

2015-10-15 09:25:30 -04:00
<?php
use Aviat\Ion\Friend;
2016-01-08 11:40:24 -05:00
include_once __DIR__ . "/HttpViewTest.php";
2015-10-15 09:25:30 -04:00
2016-01-08 11:40:24 -05:00
class JsonViewTest extends HttpViewTest {
2015-10-15 09:25:30 -04:00
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);
}
}