Gentics Portal.Node PHP API
 All Classes Namespaces Functions Variables Pages
HeadersHelperTest.php
1 <?php
2 /**
3  * Gentics Portal.Node PHP
4  * Author & Copyright (c) by Gentics Software GmbH
5  * sales@gentics.com
6  * http://www.gentics.com
7  * Licenses can be found in the LICENSE.txt file in the root-folder of this installation
8  * You must not use this software without a valid license agreement.
9  *
10  */
11 class HeadersHelperTest extends CTestCase
12 {
13  public function testForFile()
14  {
15  $content = '1234567890';
16  $files = array('file.css','file.jpg');
17  $path = 'file.css';
18  $fullPath = Yii::app()->getModule('contentSource')->sourceSettings['DynamicContentSource']['cacheFolder'] . $path;
19  touch($fullPath);
20 
21  $headers = HeadersHelper::forFile($path, $content);
22  $this->assertTrue(in_array('Content-Type: text/css', $headers));
23  $this->assertTrue(in_array('Content-Length: 10', $headers));
24 
25  $path = 'file.jpg';
26  $fullPath = Yii::app()->getModule('contentSource')->sourceSettings['DynamicContentSource']['cacheFolder'] . $path;
27  touch($fullPath);
28  $headers = HeadersHelper::forFile($path, $content);
29  $this->assertTrue(in_array('Content-Type: image/jpeg', $headers));
30  }
31 
32  public function testExpires()
33  {
34  $seconds = 3600;
35  $headers = HeadersHelper::expires($seconds);
36  $this->assertTrue(in_array('Pragma: public', $headers));
37  $this->assertTrue(in_array("Expires: " . date("r", time() + $seconds), $headers));
38  }
39 
40  public function testCache()
41  {
42  $seconds = 3600;
43  $headers = HeadersHelper::cache($seconds);
44 
45  $this->assertTrue(in_array('Cache-Control: max-age=' . $seconds . ', public', $headers));
46  }
47 }