2008-05-30 11:40:08 +00:00
< ? php
/* SVN FILE: $Id$ */
/**
2009-03-19 21:10:13 +00:00
* RequestHandlerComponentTest file
2008-05-30 11:40:08 +00:00
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP ( tm ) Tests < https :// trac . cakephp . org / wiki / Developement / TestSuite >
2008-10-30 17:30:26 +00:00
* Copyright 2005 - 2008 , Cake Software Foundation , Inc . ( http :// www . cakefoundation . org )
2008-05-30 11:40:08 +00:00
*
* Licensed under The Open Group Test Suite License
* Redistributions of files must retain the above copyright notice .
*
* @ filesource
2008-10-30 17:30:26 +00:00
* @ copyright Copyright 2005 - 2008 , Cake Software Foundation , Inc . ( http :// www . cakefoundation . org )
* @ link https :// trac . cakephp . org / wiki / Developement / TestSuite CakePHP ( tm ) Tests
2009-03-19 21:10:13 +00:00
* @ package cake
2008-10-30 17:30:26 +00:00
* @ 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
2008-05-30 11:40:08 +00:00
*/
App :: import ( 'Core' , array ( 'Controller' ));
App :: import ( 'Component' , array ( 'RequestHandler' ));
2009-03-01 06:11:03 +00:00
Mock :: generatePartial ( 'RequestHandlerComponent' , 'NoStopRequestHandler' , array ( '_stop' ));
2008-06-02 19:22:55 +00:00
/**
* RequestHandlerTestController class
2008-06-10 22:38:05 +00:00
*
2008-10-30 17:30:26 +00:00
* @ package cake
* @ subpackage cake . tests . cases . libs . controller . components
2008-06-02 19:22:55 +00:00
*/
2008-05-30 11:40:08 +00:00
class RequestHandlerTestController extends Controller {
2008-06-02 19:22:55 +00:00
/**
* uses property
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ var mixed null
* @ access public
*/
2008-05-30 11:40:08 +00:00
var $uses = null ;
2008-06-02 19:22:55 +00:00
/**
* construct method
2008-06-10 22:38:05 +00:00
*
* @ param array $params
2008-06-02 19:22:55 +00:00
* @ access private
* @ return void
*/
2008-05-30 11:40:08 +00:00
function __construct ( $params = array ()) {
foreach ( $params as $key => $val ) {
$this -> { $key } = $val ;
}
parent :: __construct ();
}
2009-03-01 06:11:03 +00:00
/**
* test method for ajax redirection
*
* @ return void
**/
function destination () {
$this -> viewPath = 'posts' ;
$this -> render ( 'index' );
}
2008-05-30 11:40:08 +00:00
}
2008-06-10 22:38:05 +00:00
/**
* RequestHandlerTestDisabledController class
*
2008-10-30 17:30:26 +00:00
* @ package cake
* @ subpackage cake . tests . cases . libs . controller . components
2008-06-10 22:38:05 +00:00
*/
class RequestHandlerTestDisabledController extends Controller {
/**
* uses property
*
* @ var mixed null
* @ access public
*/
var $uses = null ;
/**
* construct method
*
* @ param array $params
* @ access private
* @ return void
*/
function __construct ( $params = array ()) {
foreach ( $params as $key => $val ) {
$this -> { $key } = $val ;
}
parent :: __construct ();
}
2009-03-19 21:10:13 +00:00
/**
* beforeFilter method
*
* @ return void
* @ access public
*/
2008-06-10 22:38:05 +00:00
function beforeFilter () {
$this -> RequestHandler -> enabled = false ;
}
}
2008-05-30 11:40:08 +00:00
/**
2009-03-19 21:10:13 +00:00
* RequestHandlerComponentTest class
2008-05-30 11:40:08 +00:00
*
2009-03-19 21:10:13 +00:00
* @ package cake
2008-10-30 17:30:26 +00:00
* @ subpackage cake . tests . cases . libs . controller . components
2008-05-30 11:40:08 +00:00
*/
class RequestHandlerComponentTest extends CakeTestCase {
2009-03-19 21:10:13 +00:00
/**
* Controller property
*
* @ var RequestHandlerTestController
* @ access public
*/
var $Controller ;
/**
* RequestHandler property
*
* @ var RequestHandlerComponent
* @ access public
*/
var $RequestHandler ;
2008-06-02 19:22:55 +00:00
/**
* setUp method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function setUp () {
$this -> _init ();
}
2008-06-02 19:22:55 +00:00
/**
2009-03-19 21:10:13 +00:00
* tearDown method
2008-06-10 22:38:05 +00:00
*
2009-03-19 21:10:13 +00:00
* @ access public
2008-06-02 19:22:55 +00:00
* @ return void
*/
2009-03-19 21:10:13 +00:00
function tearDown () {
unset ( $this -> RequestHandler );
unset ( $this -> Controller );
if ( ! headers_sent ()) {
header ( 'Content-type: text/html' ); //reset content type.
}
2008-05-30 11:40:08 +00:00
}
2008-06-02 19:22:55 +00:00
/**
* testInitializeCallback method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testInitializeCallback () {
$this -> assertNull ( $this -> RequestHandler -> ext );
$this -> _init ();
$this -> Controller -> params [ 'url' ][ 'ext' ] = 'rss' ;
$this -> RequestHandler -> initialize ( $this -> Controller );
$this -> assertEqual ( $this -> RequestHandler -> ext , 'rss' );
}
2008-06-02 19:22:55 +00:00
/**
* testDisabling method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testDisabling () {
$_SERVER [ 'HTTP_X_REQUESTED_WITH' ] = 'XMLHttpRequest' ;
2008-06-10 22:38:05 +00:00
$this -> _init ();
2008-06-12 18:36:08 +00:00
$this -> Controller -> Component -> initialize ( $this -> Controller );
$this -> Controller -> beforeFilter ();
$this -> Controller -> Component -> startup ( $this -> Controller );
2008-05-30 11:40:08 +00:00
$this -> assertEqual ( $this -> Controller -> params , array ( 'isAjax' => true ));
2008-06-10 22:38:05 +00:00
$this -> Controller = new RequestHandlerTestDisabledController ( array ( 'components' => array ( 'RequestHandler' )));
2008-06-12 18:36:08 +00:00
$this -> Controller -> constructClasses ();
$this -> Controller -> Component -> initialize ( $this -> Controller );
$this -> Controller -> beforeFilter ();
$this -> Controller -> Component -> startup ( $this -> Controller );
2008-05-30 11:40:08 +00:00
$this -> assertEqual ( $this -> Controller -> params , array ());
unset ( $_SERVER [ 'HTTP_X_REQUESTED_WITH' ]);
}
2008-06-02 19:22:55 +00:00
/**
* testAutoResponseType method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testAutoResponseType () {
$this -> Controller -> ext = '.thtml' ;
$this -> Controller -> params [ 'url' ][ 'ext' ] = 'rss' ;
$this -> RequestHandler -> initialize ( $this -> Controller );
$this -> RequestHandler -> startup ( $this -> Controller );
$this -> assertEqual ( $this -> Controller -> ext , '.ctp' );
}
2008-06-02 19:22:55 +00:00
/**
* testStartupCallback method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testStartupCallback () {
$_SERVER [ 'REQUEST_METHOD' ] = 'PUT' ;
$_SERVER [ 'CONTENT_TYPE' ] = 'application/xml' ;
$this -> RequestHandler -> startup ( $this -> Controller );
$this -> assertTrue ( is_object ( $this -> Controller -> data ));
$this -> assertEqual ( strtolower ( get_class ( $this -> Controller -> data )), 'xml' );
}
2008-08-09 18:32:59 +00:00
/**
* testStartupCallback with charset .
*
* @ return void
**/
function testStartupCallbackCharset () {
$_SERVER [ 'REQUEST_METHOD' ] = 'PUT' ;
$_SERVER [ 'CONTENT_TYPE' ] = 'application/xml; charset=UTF-8' ;
$this -> RequestHandler -> startup ( $this -> Controller );
$this -> assertTrue ( is_object ( $this -> Controller -> data ));
2009-03-19 21:10:13 +00:00
$this -> assertEqual ( strtolower ( get_class ( $this -> Controller -> data )), 'xml' );
2008-08-09 18:32:59 +00:00
}
2008-06-02 19:22:55 +00:00
/**
* testNonAjaxRedirect method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testNonAjaxRedirect () {
$this -> RequestHandler -> initialize ( $this -> Controller );
$this -> RequestHandler -> startup ( $this -> Controller );
$this -> assertNull ( $this -> RequestHandler -> beforeRedirect ( $this -> Controller , '/' ));
}
2008-06-02 19:22:55 +00:00
/**
* testRenderAs method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testRenderAs () {
$this -> assertFalse ( in_array ( 'Xml' , $this -> Controller -> helpers ));
$this -> RequestHandler -> renderAs ( $this -> Controller , 'xml' );
$this -> assertTrue ( in_array ( 'Xml' , $this -> Controller -> helpers ));
}
2008-06-02 19:22:55 +00:00
/**
* testRequestClientTypes method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testRequestClientTypes () {
$this -> assertFalse ( $this -> RequestHandler -> isFlash ());
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Shockwave Flash' ;
$this -> assertTrue ( $this -> RequestHandler -> isFlash ());
unset ( $_SERVER [ 'HTTP_USER_AGENT' ], $_SERVER [ 'HTTP_X_REQUESTED_WITH' ]);
$this -> assertFalse ( $this -> RequestHandler -> isAjax ());
$_SERVER [ 'HTTP_X_REQUESTED_WITH' ] = 'XMLHttpRequest' ;
$_SERVER [ 'HTTP_X_PROTOTYPE_VERSION' ] = '1.5' ;
$this -> assertTrue ( $this -> RequestHandler -> isAjax ());
$this -> assertEqual ( $this -> RequestHandler -> getAjaxVersion (), '1.5' );
unset ( $_SERVER [ 'HTTP_X_REQUESTED_WITH' ], $_SERVER [ 'HTTP_X_PROTOTYPE_VERSION' ]);
$this -> assertFalse ( $this -> RequestHandler -> isAjax ());
$this -> assertFalse ( $this -> RequestHandler -> getAjaxVersion ());
}
2008-12-10 13:55:58 +00:00
/**
* Tests the detection of various Flash versions
*
* @ access public
* @ return void
*/
function testFlashDetection () {
$_agent = env ( 'HTTP_USER_AGENT' );
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Shockwave Flash' ;
$this -> assertTrue ( $this -> RequestHandler -> isFlash ());
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Adobe Flash' ;
$this -> assertTrue ( $this -> RequestHandler -> isFlash ());
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Adobe Flash Player 9' ;
$this -> assertTrue ( $this -> RequestHandler -> isFlash ());
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Adobe Flash Player 10' ;
$this -> assertTrue ( $this -> RequestHandler -> isFlash ());
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Shock Flash' ;
$this -> assertFalse ( $this -> RequestHandler -> isFlash ());
$_SERVER [ 'HTTP_USER_AGENT' ] = $_agent ;
}
2008-06-02 19:22:55 +00:00
/**
* testRequestContentTypes method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testRequestContentTypes () {
$_SERVER [ 'REQUEST_METHOD' ] = 'GET' ;
$this -> assertNull ( $this -> RequestHandler -> requestedWith ());
$_SERVER [ 'REQUEST_METHOD' ] = 'POST' ;
$_SERVER [ 'CONTENT_TYPE' ] = 'application/json' ;
$this -> assertEqual ( $this -> RequestHandler -> requestedWith (), 'json' );
$result = $this -> RequestHandler -> requestedWith ( array ( 'json' , 'xml' ));
$this -> assertEqual ( $result , 'json' );
$result = $this -> RequestHandler -> requestedWith ( array ( 'rss' , 'atom' ));
$this -> assertFalse ( $result );
$_SERVER [ 'HTTP_ACCEPT' ] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*' ;
$this -> _init ();
$this -> assertTrue ( $this -> RequestHandler -> isXml ());
$this -> assertFalse ( $this -> RequestHandler -> isAtom ());
$this -> assertFalse ( $this -> RequestHandler -> isRSS ());
$_SERVER [ 'HTTP_ACCEPT' ] = 'application/atom+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*' ;
$this -> _init ();
$this -> assertTrue ( $this -> RequestHandler -> isAtom ());
$this -> assertFalse ( $this -> RequestHandler -> isRSS ());
$_SERVER [ 'HTTP_ACCEPT' ] = 'application/rss+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*' ;
$this -> _init ();
$this -> assertFalse ( $this -> RequestHandler -> isAtom ());
$this -> assertTrue ( $this -> RequestHandler -> isRSS ());
$this -> assertFalse ( $this -> RequestHandler -> isWap ());
$_SERVER [ 'HTTP_ACCEPT' ] = 'text/vnd.wap.wml,text/html,text/plain,image/png,*/*' ;
$this -> _init ();
$this -> assertTrue ( $this -> RequestHandler -> isWap ());
$_SERVER [ 'HTTP_ACCEPT' ] = 'application/rss+xml,text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*' ;
}
2008-06-02 19:22:55 +00:00
/**
* testResponseContentType method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testResponseContentType () {
$this -> assertNull ( $this -> RequestHandler -> responseType ());
$this -> assertTrue ( $this -> RequestHandler -> respondAs ( 'atom' ));
$this -> assertEqual ( $this -> RequestHandler -> responseType (), 'atom' );
}
2008-06-02 19:22:55 +00:00
/**
* testMobileDeviceDetection method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testMobileDeviceDetection () {
$this -> assertFalse ( $this -> RequestHandler -> isMobile ());
$_SERVER [ 'HTTP_USER_AGENT' ] = 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3' ;
$this -> assertTrue ( $this -> RequestHandler -> isMobile ());
}
2008-06-02 19:22:55 +00:00
/**
* testRequestProperties method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testRequestProperties () {
$_SERVER [ 'HTTPS' ] = 'on' ;
$this -> assertTrue ( $this -> RequestHandler -> isSSL ());
unset ( $_SERVER [ 'HTTPS' ]);
$this -> assertFalse ( $this -> RequestHandler -> isSSL ());
$_ENV [ 'SCRIPT_URI' ] = 'https://localhost/' ;
$s = $_SERVER ;
$_SERVER = array ();
$this -> assertTrue ( $this -> RequestHandler -> isSSL ());
$_SERVER = $s ;
}
2008-06-02 19:22:55 +00:00
/**
* testRequestMethod method
2008-06-10 22:38:05 +00:00
*
2008-06-02 19:22:55 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testRequestMethod () {
$_SERVER [ 'REQUEST_METHOD' ] = 'GET' ;
$this -> assertTrue ( $this -> RequestHandler -> isGet ());
$this -> assertFalse ( $this -> RequestHandler -> isPost ());
$this -> assertFalse ( $this -> RequestHandler -> isPut ());
$this -> assertFalse ( $this -> RequestHandler -> isDelete ());
$_SERVER [ 'REQUEST_METHOD' ] = 'POST' ;
$this -> assertFalse ( $this -> RequestHandler -> isGet ());
$this -> assertTrue ( $this -> RequestHandler -> isPost ());
$this -> assertFalse ( $this -> RequestHandler -> isPut ());
$this -> assertFalse ( $this -> RequestHandler -> isDelete ());
$_SERVER [ 'REQUEST_METHOD' ] = 'PUT' ;
$this -> assertFalse ( $this -> RequestHandler -> isGet ());
$this -> assertFalse ( $this -> RequestHandler -> isPost ());
$this -> assertTrue ( $this -> RequestHandler -> isPut ());
$this -> assertFalse ( $this -> RequestHandler -> isDelete ());
$_SERVER [ 'REQUEST_METHOD' ] = 'DELETE' ;
$this -> assertFalse ( $this -> RequestHandler -> isGet ());
$this -> assertFalse ( $this -> RequestHandler -> isPost ());
$this -> assertFalse ( $this -> RequestHandler -> isPut ());
$this -> assertTrue ( $this -> RequestHandler -> isDelete ());
}
2008-06-05 15:20:45 +00:00
/**
* testClientContentPreference method
2008-06-10 22:38:05 +00:00
*
2008-06-05 15:20:45 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testClientContentPreference () {
$_SERVER [ 'HTTP_ACCEPT' ] = 'text/xml,application/xml,application/xhtml+xml,text/html,text/plain,image/png,*/*' ;
$this -> _init ();
$this -> assertNotEqual ( $this -> RequestHandler -> prefers (), 'rss' );
$this -> RequestHandler -> ext = 'rss' ;
$this -> assertEqual ( $this -> RequestHandler -> prefers (), 'rss' );
2008-09-19 19:48:22 +00:00
$this -> assertFalse ( $this -> RequestHandler -> prefers ( 'xml' ));
$this -> assertTrue ( $this -> RequestHandler -> accepts ( 'xml' ));
2008-05-30 11:40:08 +00:00
$_SERVER [ 'HTTP_ACCEPT' ] = 'text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5' ;
$this -> _init ();
$this -> assertEqual ( $this -> RequestHandler -> prefers (), 'xml' );
$this -> assertEqual ( $this -> RequestHandler -> accepts ( array ( 'js' , 'xml' , 'html' )), 'xml' );
$this -> assertFalse ( $this -> RequestHandler -> accepts ( array ( 'gif' , 'jpeg' , 'foo' )));
$_SERVER [ 'HTTP_ACCEPT' ] = '*/*;q=0.5' ;
$this -> _init ();
$this -> assertEqual ( $this -> RequestHandler -> prefers (), 'html' );
2008-09-19 19:48:22 +00:00
$this -> assertFalse ( $this -> RequestHandler -> prefers ( 'rss' ));
$this -> assertFalse ( $this -> RequestHandler -> accepts ( 'rss' ));
2008-05-30 11:40:08 +00:00
}
2008-06-05 15:20:45 +00:00
/**
* testCustomContent method
2008-06-10 22:38:05 +00:00
*
2008-06-05 15:20:45 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testCustomContent () {
$_SERVER [ 'HTTP_ACCEPT' ] = 'text/x-mobile,text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5' ;
$this -> _init ();
$this -> RequestHandler -> setContent ( 'mobile' , 'text/x-mobile' );
$this -> RequestHandler -> startup ( $this -> Controller );
$this -> assertEqual ( $this -> RequestHandler -> prefers (), 'mobile' );
$this -> _init ();
$this -> RequestHandler -> setContent ( array ( 'mobile' => 'text/x-mobile' ));
$this -> RequestHandler -> startup ( $this -> Controller );
$this -> assertEqual ( $this -> RequestHandler -> prefers (), 'mobile' );
}
2008-06-05 15:20:45 +00:00
/**
* testClientProperties method
2008-06-10 22:38:05 +00:00
*
2008-06-05 15:20:45 +00:00
* @ access public
* @ return void
*/
2008-05-30 11:40:08 +00:00
function testClientProperties () {
$_SERVER [ 'HTTP_HOST' ] = 'localhost:80' ;
$this -> assertEqual ( $this -> RequestHandler -> getReferrer (), 'localhost' );
$_SERVER [ 'HTTP_HOST' ] = null ;
$_SERVER [ 'HTTP_X_FORWARDED_HOST' ] = 'cakephp.org' ;
$this -> assertEqual ( $this -> RequestHandler -> getReferrer (), 'cakephp.org' );
$_SERVER [ 'HTTP_X_FORWARDED_FOR' ] = '192.168.1.5, 10.0.1.1, proxy.com' ;
$_SERVER [ 'HTTP_CLIENT_IP' ] = '192.168.1.2' ;
$_SERVER [ 'REMOTE_ADDR' ] = '192.168.1.3' ;
2008-12-25 22:02:36 +00:00
$this -> assertEqual ( $this -> RequestHandler -> getClientIP ( false ), '192.168.1.5' );
$this -> assertEqual ( $this -> RequestHandler -> getClientIP (), '192.168.1.2' );
2008-05-30 11:40:08 +00:00
unset ( $_SERVER [ 'HTTP_X_FORWARDED_FOR' ]);
$this -> assertEqual ( $this -> RequestHandler -> getClientIP (), '192.168.1.2' );
unset ( $_SERVER [ 'HTTP_CLIENT_IP' ]);
$this -> assertEqual ( $this -> RequestHandler -> getClientIP (), '192.168.1.3' );
$_SERVER [ 'HTTP_CLIENTADDRESS' ] = '10.0.1.2, 10.0.1.1' ;
$this -> assertEqual ( $this -> RequestHandler -> getClientIP (), '10.0.1.2' );
}
2009-03-01 06:11:03 +00:00
/**
* test that ajax requests involving redirects trigger requestAction instead .
*
* @ return void
**/
function testAjaxRedirectAsRequestAction () {
$_SERVER [ 'HTTP_X_REQUESTED_WITH' ] = 'XMLHttpRequest' ;
$this -> _init ();
$_paths = Configure :: read ( 'viewPaths' );
$testDir = array ( TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS );
Configure :: write ( 'viewPaths' , array_merge ( $testDir , $_paths ));
$this -> Controller -> RequestHandler = new NoStopRequestHandler ( $this );
$this -> Controller -> RequestHandler -> expectOnce ( '_stop' );
ob_start ();
$this -> Controller -> RequestHandler -> beforeRedirect (
$this -> Controller , array ( 'controller' => 'request_handler_test' , 'action' => 'destination' )
);
$result = ob_get_clean ();
$this -> assertPattern ( '/posts index/' , $result , 'RequestAction redirect failed.' );
Configure :: write ( 'viewPaths' , $_paths );
unset ( $_SERVER [ 'HTTP_X_REQUESTED_WITH' ]);
}
2008-06-05 15:20:45 +00:00
/**
2009-03-19 21:10:13 +00:00
* init method
2008-06-10 22:38:05 +00:00
*
2009-03-19 21:10:13 +00:00
* @ access protected
2008-06-05 15:20:45 +00:00
* @ return void
*/
2009-03-19 21:10:13 +00:00
function _init () {
$this -> Controller = new RequestHandlerTestController ( array ( 'components' => array ( 'RequestHandler' )));
$this -> Controller -> constructClasses ();
$this -> RequestHandler =& $this -> Controller -> RequestHandler ;
2008-05-30 11:40:08 +00:00
}
}
2008-06-27 08:17:02 +00:00
?>