2007-07-09 20:07:38 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
2007-07-09 20:45:29 +00:00
|
|
|
* Short description for file.
|
2007-07-09 20:07:38 +00:00
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
2008-01-01 22:18:17 +00:00
|
|
|
* Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 20:07:38 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2008-01-01 22:18:17 +00:00
|
|
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 20:07:38 +00:00
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5435
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
2007-12-11 03:01:46 +00:00
|
|
|
uses('controller' . DS . 'controller', 'controller' . DS . 'components' . DS .'request_handler');
|
2007-07-09 20:07:38 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.controller.components
|
|
|
|
*/
|
|
|
|
class RequestHandlerComponentTest extends CakeTestCase {
|
|
|
|
|
2007-12-11 03:01:46 +00:00
|
|
|
function setUp() {
|
|
|
|
$this->RequestHandler = new RequestHandlerComponent();
|
|
|
|
$this->Controller = new Controller();
|
|
|
|
}
|
|
|
|
|
|
|
|
function testRenderAs() {
|
2007-12-29 16:35:38 +00:00
|
|
|
$this->assertFalse(in_array('Xml', $this->Controller->helpers));
|
2007-12-11 03:01:46 +00:00
|
|
|
$this->RequestHandler->renderAs($this->Controller, 'xml');
|
2007-12-29 16:35:38 +00:00
|
|
|
$this->assertTrue(in_array('Xml', $this->Controller->helpers));
|
2007-12-11 03:01:46 +00:00
|
|
|
}
|
|
|
|
|
2008-02-14 05:32:46 +00:00
|
|
|
function testRequestTypes() {
|
|
|
|
$this->assertFalse($this->RequestHandler->isFlash());
|
|
|
|
$_SERVER['HTTP_USER_AGENT'] = 'Shockwave Flash';
|
|
|
|
$this->assertTrue($this->RequestHandler->isFlash());
|
|
|
|
unset($_SERVER['HTTP_USER_AGENT']);
|
|
|
|
|
|
|
|
$this->assertFalse($this->RequestHandler->isAjax());
|
|
|
|
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest';
|
|
|
|
$this->assertTrue($this->RequestHandler->isAjax());
|
|
|
|
unset($_SERVER['HTTP_X_REQUESTED_WITH']);
|
|
|
|
}
|
|
|
|
|
2007-12-11 03:01:46 +00:00
|
|
|
function tearDown() {
|
|
|
|
unset($this->RequestHandler);
|
|
|
|
unset($this->Controller);
|
2007-07-09 20:07:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|