2016-10-09 00:47:15 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test case for the NotFoundJSONResponse class
|
|
|
|
* Date: 8/10/16
|
|
|
|
* Time: 18:34
|
|
|
|
* @copyright Marcos Zuriaga Miguel 2016
|
|
|
|
* @license AGPLv3
|
|
|
|
*/
|
|
|
|
use \OCA\Passman\Utility\NotFoundJSONResponse;
|
|
|
|
use \OCP\AppFramework\Http;
|
|
|
|
class NotFoundJSONResponseTest extends PHPUnit_Framework_TestCase {
|
|
|
|
public function testOnEmptyResponse(){
|
|
|
|
$data = new NotFoundJSONResponse();
|
2016-10-10 08:15:00 +08:00
|
|
|
$this->assertEquals(Http::STATUS_NOT_FOUND, $data->getStatus());
|
2016-10-09 00:47:15 +08:00
|
|
|
$this->assertJsonStringEqualsJsonString('[]', $data->render(), 'Expected empty JSON response');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testOnDataResult(){
|
|
|
|
$data = [
|
|
|
|
'field' => 'value',
|
|
|
|
'boolean' => true,
|
|
|
|
'integer' => 21
|
|
|
|
];
|
|
|
|
$response = new NotFoundJSONResponse($data);
|
2016-10-10 08:15:00 +08:00
|
|
|
$this->assertEquals(Http::STATUS_NOT_FOUND, $response->getStatus());
|
2016-10-09 00:47:15 +08:00
|
|
|
$this->assertJsonStringEqualsJsonString(json_encode($data), $response->render(), 'Rendered data does not match with expected data');
|
|
|
|
}
|
|
|
|
}
|