You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
898 B
PHP

<?php
namespace BSR\Webservice\Formatter;
use PHPUnit\Framework\TestCase;
class JsonTest extends TestCase
{
protected $accept = array(
'application/json',
'application/x-json',
);
public function testRenderEncodesDataIntoJsonFormat()
{
$format = new Json();
$someArray = array(
'asdf' => array(1, 'a', 'b', array()),
'1' => array(3 => 'c'),
0 => 'hello',
);
ob_start();
$format->render($someArray);
$jsonRepresentation = ob_get_clean();
$this->assertSame(json_decode($jsonRepresentation, true), $someArray);
}
public function testRegistersItsFormatAcceptHeader()
{
Formatter::getFormatter();
$formats = Formatter::getRegisterdFormats();
$this->assertSame(array_intersect($this->accept, array_keys($formats)), $this->accept);
}
}