-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathJsonTemplateTest.php
More file actions
42 lines (36 loc) · 1.07 KB
/
JsonTemplateTest.php
File metadata and controls
42 lines (36 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php
/**
* Json CakePHP template test case
*
* @copyright Copyright 2014, NetCommons Project
* @author Kohei Teraguchi <kteraguchi@commonsnet.org>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
App::uses('Controller', 'Controller');
App::uses('CakeResponse', 'Network');
/**
* Json CakePHP template test case
*/
class JsonTemplateTest extends CakeTestCase {
/**
* testJson method
*
* @return void
*/
public function testJson() {
// It is better reference Google JSON Style Guide
$response = new CakeResponse();
$controller = new Controller(null, $response);
$controller->viewClass = 'Json';
$name = 'test';
$status = '999';
$results = 'results test';
$controller->set(compact('name', 'status', 'results'));
$response = $controller->render('NetCommons.Elements/json');
$jsonArray = json_decode($response->body(), true);
$this->assertEquals($name, $jsonArray['name']);
$this->assertEquals($status, $jsonArray['code']);
$this->assertEquals($results, $jsonArray['results']);
}
}