Added a hit about user id checking to the activity handler
[shindig.git] / php / test / common / HttpServletTest.php
blob8ff9d2c2285bd7bbf609a6660c95bd0a3869dce4
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 * HttpServlet test case.
24 class HttpServletTest extends PHPUnit_Framework_TestCase {
26 /**
27 * @var HttpServlet
29 private $HttpServlet;
31 private $cacheTime = 60;
32 private $contentType1 = "text/html";
33 private $contentType2 = "text/javascript";
34 private $lastModified = 500;
35 private $noCache = false;
36 public $contentType = 'utf-8';
38 /**
39 * Prepares the environment before running a test.
41 protected function setUp() {
42 parent::setUp();
43 $this->HttpServlet = new HttpServlet(/* parameters */);
45 $this->HttpServlet->setLastModified($this->lastModified);
46 $this->HttpServlet->setNoCache($this->noCache);
47 $this->HttpServlet->setContentType($this->contentType);
48 $this->HttpServlet->setCacheTime($this->cacheTime);
51 /**
52 * Cleans up the environment after running a test.
55 protected function tearDown() {
56 $this->HttpServlet = null;
57 parent::tearDown();
60 /**
61 * Tests HttpServlet->getCacheTime()
63 public function testGetCacheTime() {
64 $this->assertEquals($this->cacheTime, $this->HttpServlet->getCacheTime());
67 /**
68 * Tests HttpServlet->getContentType()
70 public function testGetContentType() {
71 $this->assertEquals($this->contentType, $this->HttpServlet->getContentType());
74 /**
75 * Tests HttpServlet->getLastModified()
77 public function testGetLastModified() {
78 $this->assertEquals($this->lastModified, $this->HttpServlet->getLastModified());
81 /**
82 * Tests HttpServlet->getNoCache()
84 public function testGetNoCache() {
85 $this->assertEquals($this->noCache, $this->HttpServlet->getNoCache());
88 /**
89 * Tests HttpServlet->setCacheTime()
91 public function testSetCacheTime() {
92 $this->HttpServlet->setCacheTime($this->cacheTime + 100);
93 $this->assertEquals($this->cacheTime + 100, $this->HttpServlet->getCacheTime());
96 /**
97 * Tests HttpServlet->setContentType()
99 public function testSetContentType() {
100 $this->HttpServlet->setContentType($this->contentType2);
101 $this->assertNotEquals($this->contentType1, $this->HttpServlet->getContentType());
105 * Tests HttpServlet->setLastModified()
107 public function testSetLastModified() {
108 $this->HttpServlet->setLastModified($this->lastModified + 100);
109 $this->assertEquals($this->lastModified + 100, $this->HttpServlet->getLastModified());
113 * Tests HttpServlet->setNoCache()
115 public function testSetNoCache() {
116 $this->HttpServlet->setNoCache(! $this->noCache);
117 $this->assertNotEquals($this->noCache, $this->HttpServlet->getNoCache());