SHINDIG-943 by Pan Jie - Add support invalidation for CacheApc/CacheFile/CacheMemcach...
[shindig.git] / php / test / social / OutputJsonConverterTest.php
blob428b53a9d7dea9dc080b491f6dcbe1b4067a8c9b
1 <?php
2 /**
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
21 /**
22 * OutputJsonConverter test case.
24 class OutputJsonConverterTest extends PHPUnit_Framework_TestCase {
26 /**
27 * @var OutputJsonConverter
29 private $OutputJsonConverter;
31 /**
32 * Prepares the environment before running a test.
34 protected function setUp() {
35 parent::setUp();
36 $this->OutputJsonConverter = new OutputJsonConverter();
39 /**
40 * Cleans up the environment after running a test.
42 protected function tearDown() {
43 $this->OutputJsonConverter = null;
44 parent::tearDown();
47 /**
48 * Tests OutputJsonConverter->outputResponse()
50 public function testOutputResponse() {
51 $inputConverter = new InputJsonConverter();
52 $outputConverter = new OutputJsonConverter();
53 $servletRequest = array('url' => '/people/1/@self');
54 $requestItem = RestRequestItem::createWithRequest($servletRequest, null, $inputConverter, $outputConverter);
55 $requestItem->applyUrlTemplate("/people/{userId}/{groupId}/{personId}");
56 $response = array(
57 'entry' => array('isOwner' => false, 'isViewer' => false, 'displayName' => '1 1',
58 'id' => '1'));
59 $responseItem = new ResponseItem(null, null, $response);
60 ob_start();
61 $outputConverter->outputResponse($responseItem, $requestItem);
62 $output = ob_get_clean();
63 $expected = '{
64 "entry": {
65 "isOwner": false,
66 "isViewer": false,
67 "displayName": "1 1",
68 "id": "1"
70 }';
71 $this->assertEquals($expected, $output);