2008-05-30 11:40:08 +00:00
|
|
|
<?php
|
|
|
|
/**
|
2009-03-19 21:10:13 +00:00
|
|
|
* ObjectTest file
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* PHP 5
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-05-19 01:15:13 +00:00
|
|
|
* CakePHP(tm) Tests <http://book.cakephp.org/view/1196/Testing>
|
2010-01-26 19:18:20 +00:00
|
|
|
* Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-10-03 16:31:21 +00:00
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-01-26 19:18:20 +00:00
|
|
|
* @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
2010-05-19 01:15:13 +00:00
|
|
|
* @link http://book.cakephp.org/view/1196/Testing CakePHP(tm) Tests
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs
|
2008-10-30 17:30:26 +00:00
|
|
|
* @since CakePHP(tm) v 1.2.0.5432
|
2010-10-03 16:27:27 +00:00
|
|
|
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2010-12-10 06:23:27 +00:00
|
|
|
|
|
|
|
App::uses('Object', 'Core');
|
2011-05-10 05:16:24 +00:00
|
|
|
App::uses('Router', 'Routing');
|
2010-12-10 06:23:27 +00:00
|
|
|
App::uses('Controller', 'Controller');
|
|
|
|
App::uses('Model', 'Model');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2008-09-07 13:43:39 +00:00
|
|
|
* RequestActionPost class
|
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs.object
|
2008-06-02 19:22:55 +00:00
|
|
|
*/
|
2008-09-07 13:43:39 +00:00
|
|
|
class RequestActionPost extends CakeTestModel {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2008-09-07 13:43:39 +00:00
|
|
|
* name property
|
|
|
|
*
|
|
|
|
* @var string 'ControllerPost'
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $name = 'RequestActionPost';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2008-09-07 13:43:39 +00:00
|
|
|
* useTable property
|
|
|
|
*
|
|
|
|
* @var string 'posts'
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $useTable = 'posts';
|
2008-09-07 13:43:39 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* RequestActionController class
|
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs
|
2008-09-07 13:43:39 +00:00
|
|
|
*/
|
|
|
|
class RequestActionController extends Controller {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* uses property
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $uses = array('RequestActionPost');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* test_request_action method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function test_request_action() {
|
|
|
|
return 'This is a test';
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* another_ra_test method
|
|
|
|
*
|
|
|
|
* @param mixed $id
|
|
|
|
* @param mixed $other
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function another_ra_test($id, $other) {
|
|
|
|
return $id + $other;
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* normal_request_action method
|
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-09-07 13:43:39 +00:00
|
|
|
function normal_request_action() {
|
|
|
|
return 'Hello World';
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2010-08-05 03:16:26 +00:00
|
|
|
/**
|
|
|
|
* returns $this->here
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function return_here() {
|
|
|
|
return $this->here;
|
|
|
|
}
|
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* paginate_request_action method
|
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-09-07 13:43:39 +00:00
|
|
|
function paginate_request_action() {
|
|
|
|
$data = $this->paginate();
|
|
|
|
return true;
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-10-21 02:04:42 +00:00
|
|
|
/**
|
|
|
|
* post pass, testing post passing
|
|
|
|
*
|
2008-10-22 17:12:30 +00:00
|
|
|
* @return array
|
2009-11-14 12:19:25 +00:00
|
|
|
*/
|
2008-10-21 02:04:42 +00:00
|
|
|
function post_pass() {
|
|
|
|
return $this->data;
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-10-22 17:12:30 +00:00
|
|
|
/**
|
|
|
|
* test param passing and parsing.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
function params_pass() {
|
|
|
|
return $this->params;
|
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
/**
|
|
|
|
* RequestActionPersistentController class
|
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs
|
2009-03-19 21:10:13 +00:00
|
|
|
*/
|
|
|
|
class RequestActionPersistentController extends Controller {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
/**
|
|
|
|
* uses property
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $uses = array('PersisterOne');
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* persistModel property
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $persistModel = true;
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
/**
|
|
|
|
* post pass, testing post passing
|
|
|
|
*
|
|
|
|
* @return array
|
2009-11-14 12:19:25 +00:00
|
|
|
*/
|
2009-03-19 21:10:13 +00:00
|
|
|
function index() {
|
|
|
|
return 'This is a test';
|
|
|
|
}
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* TestObject class
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs
|
2008-06-02 19:22:55 +00:00
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
class TestObject extends Object {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* firstName property
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @var string 'Joel'
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $firstName = 'Joel';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* lastName property
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @var string 'Moss'
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $lastName = 'Moss';
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* methodCalls property
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @var array
|
|
|
|
* @access public
|
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $methodCalls = array();
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* emptyMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function emptyMethod() {
|
|
|
|
$this->methodCalls[] = 'emptyMethod';
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* oneParamMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function oneParamMethod($param) {
|
|
|
|
$this->methodCalls[] = array('oneParamMethod' => array($param));
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* twoParamMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
|
|
|
* @param mixed $param2
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function twoParamMethod($param, $param2) {
|
|
|
|
$this->methodCalls[] = array('twoParamMethod' => array($param, $param2));
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* threeParamMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
|
|
|
* @param mixed $param2
|
|
|
|
* @param mixed $param3
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function threeParamMethod($param, $param2, $param3) {
|
|
|
|
$this->methodCalls[] = array('threeParamMethod' => array($param, $param2, $param3));
|
|
|
|
}
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* fourParamMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
|
|
|
* @param mixed $param2
|
|
|
|
* @param mixed $param3
|
|
|
|
* @param mixed $param4
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function fourParamMethod($param, $param2, $param3, $param4) {
|
|
|
|
$this->methodCalls[] = array('fourParamMethod' => array($param, $param2, $param3, $param4));
|
|
|
|
}
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* fiveParamMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
|
|
|
* @param mixed $param2
|
|
|
|
* @param mixed $param3
|
|
|
|
* @param mixed $param4
|
|
|
|
* @param mixed $param5
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function fiveParamMethod($param, $param2, $param3, $param4, $param5) {
|
|
|
|
$this->methodCalls[] = array('fiveParamMethod' => array($param, $param2, $param3, $param4, $param5));
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* crazyMethod method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
|
|
|
* @param mixed $param2
|
|
|
|
* @param mixed $param3
|
|
|
|
* @param mixed $param4
|
|
|
|
* @param mixed $param5
|
|
|
|
* @param mixed $param6
|
|
|
|
* @param mixed $param7
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function crazyMethod($param, $param2, $param3, $param4, $param5, $param6, $param7 = null) {
|
|
|
|
$this->methodCalls[] = array('crazyMethod' => array($param, $param2, $param3, $param4, $param5, $param6, $param7));
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* methodWithOptionalParam method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
|
|
|
* @param mixed $param
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function methodWithOptionalParam($param = null) {
|
|
|
|
$this->methodCalls[] = array('methodWithOptionalParam' => array($param));
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
/**
|
|
|
|
* testPersist
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:19:25 +00:00
|
|
|
*/
|
2008-07-09 03:15:01 +00:00
|
|
|
function testPersist($name, $return = null, &$object, $type = null) {
|
|
|
|
return $this->_persist($name, $return, $object, $type);
|
|
|
|
}
|
2010-05-22 15:28:22 +00:00
|
|
|
/**
|
|
|
|
* undocumented function
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
public function set($properties = array()) {
|
|
|
|
return parent::_set($properties);
|
|
|
|
}
|
2008-07-09 03:15:01 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
/**
|
2009-03-19 21:10:13 +00:00
|
|
|
* ObjectTestModel class
|
2008-07-09 03:15:01 +00:00
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs
|
2008-07-09 03:15:01 +00:00
|
|
|
*/
|
|
|
|
class ObjectTestModel extends CakeTestModel {
|
2010-04-04 07:14:00 +00:00
|
|
|
public $useTable = false;
|
|
|
|
public $name = 'ObjectTestModel';
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
/**
|
2009-03-19 21:10:13 +00:00
|
|
|
* Object Test class
|
2008-05-30 11:40:08 +00:00
|
|
|
*
|
2010-12-24 18:57:20 +00:00
|
|
|
* @package cake.tests.cases.libs
|
2008-05-30 11:40:08 +00:00
|
|
|
*/
|
2008-07-21 02:40:58 +00:00
|
|
|
class ObjectTest extends CakeTestCase {
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
/**
|
|
|
|
* fixtures
|
|
|
|
*
|
|
|
|
* @var string
|
2009-11-14 12:19:25 +00:00
|
|
|
*/
|
2010-04-04 07:14:00 +00:00
|
|
|
public $fixtures = array('core.post', 'core.test_plugin_comment', 'core.comment');
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* setUp method
|
2008-09-07 13:43:39 +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->object = new TestObject();
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function tearDown() {
|
2009-06-11 16:13:16 +00:00
|
|
|
App::build();
|
2011-05-10 05:16:24 +00:00
|
|
|
CakePlugin::unload();
|
|
|
|
unset($this->object);
|
2009-06-11 16:13:16 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* testLog method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testLog() {
|
|
|
|
@unlink(LOGS . 'error.log');
|
|
|
|
$this->assertTrue($this->object->log('Test warning 1'));
|
|
|
|
$this->assertTrue($this->object->log(array('Test' => 'warning 2')));
|
|
|
|
$result = file(LOGS . 'error.log');
|
|
|
|
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Test warning 1$/', $result[0]);
|
|
|
|
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Error: Array$/', $result[1]);
|
|
|
|
$this->assertPattern('/^\($/', $result[2]);
|
|
|
|
$this->assertPattern('/\[Test\] => warning 2$/', $result[3]);
|
|
|
|
$this->assertPattern('/^\)$/', $result[4]);
|
|
|
|
unlink(LOGS . 'error.log');
|
|
|
|
|
2008-06-20 20:17:23 +00:00
|
|
|
@unlink(LOGS . 'error.log');
|
|
|
|
$this->assertTrue($this->object->log('Test warning 1', LOG_WARNING));
|
|
|
|
$this->assertTrue($this->object->log(array('Test' => 'warning 2'), LOG_WARNING));
|
2008-05-30 11:40:08 +00:00
|
|
|
$result = file(LOGS . 'error.log');
|
|
|
|
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Test warning 1$/', $result[0]);
|
|
|
|
$this->assertPattern('/^2[0-9]{3}-[0-9]+-[0-9]+ [0-9]+:[0-9]+:[0-9]+ Warning: Array$/', $result[1]);
|
|
|
|
$this->assertPattern('/^\($/', $result[2]);
|
|
|
|
$this->assertPattern('/\[Test\] => warning 2$/', $result[3]);
|
|
|
|
$this->assertPattern('/^\)$/', $result[4]);
|
|
|
|
unlink(LOGS . 'error.log');
|
2008-06-20 20:17:23 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* testSet method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testSet() {
|
2010-05-22 15:28:22 +00:00
|
|
|
$this->object->set('a string');
|
2008-06-20 20:17:23 +00:00
|
|
|
$this->assertEqual($this->object->firstName, 'Joel');
|
|
|
|
|
2010-05-22 15:28:22 +00:00
|
|
|
$this->object->set(array('firstName'));
|
2008-06-20 20:17:23 +00:00
|
|
|
$this->assertEqual($this->object->firstName, 'Joel');
|
|
|
|
|
2010-05-22 15:28:22 +00:00
|
|
|
$this->object->set(array('firstName' => 'Ashley'));
|
2008-06-20 20:17:23 +00:00
|
|
|
$this->assertEqual($this->object->firstName, 'Ashley');
|
|
|
|
|
2010-05-22 15:28:22 +00:00
|
|
|
$this->object->set(array('firstName' => 'Joel', 'lastName' => 'Moose'));
|
2008-06-20 20:17:23 +00:00
|
|
|
$this->assertEqual($this->object->firstName, 'Joel');
|
|
|
|
$this->assertEqual($this->object->lastName, 'Moose');
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
|
|
|
* testPersist method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testPersist() {
|
2010-06-21 03:14:14 +00:00
|
|
|
$this->markTestIncomplete('Object::persist() is totally broken right now.');
|
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
ClassRegistry::flush();
|
2008-06-20 20:17:23 +00:00
|
|
|
|
2008-09-07 13:43:39 +00:00
|
|
|
$cacheDisable = Configure::read('Cache.disable');
|
|
|
|
Configure::write('Cache.disable', false);
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'testmodel.php');
|
|
|
|
$test = new stdClass;
|
2008-07-09 03:15:01 +00:00
|
|
|
$this->assertFalse($this->object->testPersist('TestModel', null, $test));
|
|
|
|
$this->assertFalse($this->object->testPersist('TestModel', true, $test));
|
|
|
|
$this->assertTrue($this->object->testPersist('TestModel', null, $test));
|
2008-06-20 20:17:23 +00:00
|
|
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'testmodel.php'));
|
2008-07-09 03:15:01 +00:00
|
|
|
$this->assertTrue($this->object->testPersist('TestModel', true, $test));
|
2008-09-07 13:43:39 +00:00
|
|
|
$this->assertEqual($this->object->TestModel, $test);
|
2008-06-20 20:17:23 +00:00
|
|
|
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'testmodel.php');
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2010-11-13 04:05:44 +00:00
|
|
|
$model = new ObjectTestModel();
|
2008-07-09 03:15:01 +00:00
|
|
|
$expected = ClassRegistry::keys();
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
ClassRegistry::flush();
|
|
|
|
$data = array('object_test_model' => $model);
|
|
|
|
$this->assertFalse($this->object->testPersist('ObjectTestModel', true, $data));
|
|
|
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'objecttestmodel.php'));
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
$this->object->testPersist('ObjectTestModel', true, $model, 'registry');
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
$result = ClassRegistry::keys();
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
$newModel = ClassRegistry::getObject('object_test_model');
|
|
|
|
$this->assertEqual('ObjectTestModel', $newModel->name);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
@unlink(CACHE . 'persistent' . DS . 'objecttestmodel.php');
|
2008-09-07 13:43:39 +00:00
|
|
|
|
|
|
|
Configure::write('Cache.disable', $cacheDisable);
|
2008-06-20 20:17:23 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-02 19:22:55 +00:00
|
|
|
/**
|
2009-03-19 21:10:13 +00:00
|
|
|
* testPersistWithRequestAction method
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testPersistWithBehavior() {
|
2010-06-21 03:14:14 +00:00
|
|
|
$this->markTestIncomplete('Object::persist() is totally broken right now.');
|
2009-03-19 21:10:13 +00:00
|
|
|
ClassRegistry::flush();
|
|
|
|
|
|
|
|
$cacheDisable = Configure::read('Cache.disable');
|
|
|
|
Configure::write('Cache.disable', false);
|
|
|
|
|
2009-06-11 16:13:16 +00:00
|
|
|
App::build(array(
|
2011-04-17 10:35:21 +00:00
|
|
|
'models' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
|
|
|
|
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS),
|
|
|
|
'behaviors' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model'. DS . 'Behavior' . DS),
|
2009-06-11 16:13:16 +00:00
|
|
|
), true);
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
$this->assertFalse(class_exists('PersisterOneBehaviorBehavior'));
|
|
|
|
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
|
2010-01-13 13:51:36 +00:00
|
|
|
$this->assertFalse(class_exists('TestPluginPersisterBehavior'));
|
2010-01-18 17:35:30 +00:00
|
|
|
$this->assertFalse(class_exists('TestPluginAuthors'));
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
$Controller = new RequestActionPersistentController();
|
|
|
|
$Controller->persistModel = true;
|
|
|
|
$Controller->constructClasses();
|
|
|
|
|
|
|
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisterone.php'));
|
|
|
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
|
|
|
|
|
2010-01-18 17:35:30 +00:00
|
|
|
$contents = file_get_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
|
|
|
$contents = str_replace('"PersisterOne"', '"PersisterTwo"', $contents);
|
|
|
|
$contents = str_replace('persister_one', 'persister_two', $contents);
|
|
|
|
$contents = str_replace('test_plugin_comment', 'test_plugin_authors', $contents);
|
2009-03-19 21:10:13 +00:00
|
|
|
$result = file_put_contents(CACHE . 'persistent' . DS . 'persisteroneregistry.php', $contents);
|
|
|
|
|
|
|
|
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
|
2010-01-18 17:35:30 +00:00
|
|
|
$this->assertTrue(class_exists('TestPluginPersisterOneBehavior'));
|
|
|
|
$this->assertTrue(class_exists('TestPluginComment'));
|
2009-03-19 21:10:13 +00:00
|
|
|
$this->assertFalse(class_exists('PersisterTwoBehaviorBehavior'));
|
2010-01-13 13:51:36 +00:00
|
|
|
$this->assertFalse(class_exists('TestPluginPersisterTwoBehavior'));
|
2010-01-18 17:35:30 +00:00
|
|
|
$this->assertFalse(class_exists('TestPluginAuthors'));
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
$Controller = new RequestActionPersistentController();
|
|
|
|
$Controller->persistModel = true;
|
|
|
|
$Controller->constructClasses();
|
|
|
|
|
|
|
|
$this->assertTrue(class_exists('PersisterOneBehaviorBehavior'));
|
|
|
|
$this->assertTrue(class_exists('PersisterTwoBehaviorBehavior'));
|
2010-01-13 13:51:36 +00:00
|
|
|
$this->assertTrue(class_exists('TestPluginPersisterTwoBehavior'));
|
2010-01-18 17:35:30 +00:00
|
|
|
$this->assertTrue(class_exists('TestPluginAuthors'));
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
/**
|
|
|
|
* testPersistWithBehaviorAndRequestAction method
|
|
|
|
*
|
|
|
|
* @see testPersistWithBehavior
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testPersistWithBehaviorAndRequestAction() {
|
2010-06-21 03:14:14 +00:00
|
|
|
$this->markTestIncomplete('Object::persist() is totally broken right now.');
|
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
ClassRegistry::flush();
|
|
|
|
|
|
|
|
$cacheDisable = Configure::read('Cache.disable');
|
|
|
|
Configure::write('Cache.disable', false);
|
|
|
|
|
|
|
|
$this->assertFalse(class_exists('ContainableBehavior'));
|
|
|
|
|
2009-06-11 16:13:16 +00:00
|
|
|
App::build(array(
|
2011-04-17 10:35:21 +00:00
|
|
|
'models' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
|
|
|
|
'behaviors' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model'. DS . 'Behavior' . DS),
|
2009-06-11 16:13:16 +00:00
|
|
|
), true);
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
$this->assertFalse(class_exists('PersistOneBehaviorBehavior'));
|
|
|
|
$this->assertFalse(class_exists('PersistTwoBehaviorBehavior'));
|
|
|
|
|
|
|
|
$Controller = new RequestActionPersistentController();
|
|
|
|
$Controller->persistModel = true;
|
|
|
|
$Controller->constructClasses();
|
|
|
|
|
|
|
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisterone.php'));
|
|
|
|
$this->assertTrue(file_exists(CACHE . 'persistent' . DS . 'persisteroneregistry.php'));
|
|
|
|
|
|
|
|
$keys = ClassRegistry::keys();
|
2010-01-13 13:51:36 +00:00
|
|
|
$this->assertEqual($keys, array(
|
|
|
|
'persister_one',
|
|
|
|
'comment',
|
2010-01-18 17:35:30 +00:00
|
|
|
'test_plugin_comment',
|
|
|
|
'test_plugin.test_plugin_comment',
|
2010-01-13 13:51:36 +00:00
|
|
|
'persister_one_behavior_behavior',
|
|
|
|
'test_plugin_persister_one_behavior',
|
|
|
|
'test_plugin.test_plugin_persister_one_behavior'
|
|
|
|
));
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
ob_start();
|
|
|
|
$Controller->set('content_for_layout', 'cool');
|
|
|
|
$Controller->render('index', 'ajax', '/layouts/ajax');
|
|
|
|
$result = ob_get_clean();
|
|
|
|
|
|
|
|
$keys = ClassRegistry::keys();
|
2010-01-13 13:51:36 +00:00
|
|
|
$this->assertEqual($keys, array(
|
|
|
|
'persister_one',
|
|
|
|
'comment',
|
2010-01-18 17:35:30 +00:00
|
|
|
'test_plugin_comment',
|
|
|
|
'test_plugin.test_plugin_comment',
|
2010-01-13 13:51:36 +00:00
|
|
|
'persister_one_behavior_behavior',
|
|
|
|
'test_plugin_persister_one_behavior',
|
|
|
|
'test_plugin.test_plugin_persister_one_behavior',
|
|
|
|
'view'
|
|
|
|
));
|
2009-03-19 21:10:13 +00:00
|
|
|
$result = $this->object->requestAction('/request_action_persistent/index');
|
|
|
|
$expected = 'This is a test';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2009-03-19 21:10:13 +00:00
|
|
|
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
|
|
|
|
|
|
|
$Controller = new RequestActionPersistentController();
|
|
|
|
$Controller->persistModel = true;
|
|
|
|
$Controller->constructClasses();
|
|
|
|
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'persisterone.php');
|
|
|
|
@unlink(CACHE . 'persistent' . DS . 'persisteroneregistry.php');
|
|
|
|
|
|
|
|
Configure::write('Cache.disable', $cacheDisable);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2009-03-19 21:10:13 +00:00
|
|
|
/**
|
2008-06-02 19:22:55 +00:00
|
|
|
* testToString method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-02 19:22:55 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testToString() {
|
|
|
|
$result = strtolower($this->object->toString());
|
|
|
|
$this->assertEqual($result, 'testobject');
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-05 15:20:45 +00:00
|
|
|
/**
|
|
|
|
* testMethodDispatching method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-05 15:20:45 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-05-30 11:40:08 +00:00
|
|
|
function testMethodDispatching() {
|
|
|
|
$this->object->emptyMethod();
|
|
|
|
$expected = array('emptyMethod');
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->oneParamMethod('Hello');
|
|
|
|
$expected[] = array('oneParamMethod' => array('Hello'));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->twoParamMethod(true, false);
|
|
|
|
$expected[] = array('twoParamMethod' => array(true, false));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->threeParamMethod(true, false, null);
|
|
|
|
$expected[] = array('threeParamMethod' => array(true, false, null));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->crazyMethod(1, 2, 3, 4, 5, 6, 7);
|
|
|
|
$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object = new TestObject();
|
|
|
|
$this->assertIdentical($this->object->methodCalls, array());
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('emptyMethod');
|
|
|
|
$expected = array('emptyMethod');
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('oneParamMethod', array('Hello'));
|
|
|
|
$expected[] = array('oneParamMethod' => array('Hello'));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('twoParamMethod', array(true, false));
|
|
|
|
$expected[] = array('twoParamMethod' => array(true, false));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('threeParamMethod', array(true, false, null));
|
|
|
|
$expected[] = array('threeParamMethod' => array(true, false, null));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->object->dispatchMethod('fourParamMethod', array(1, 2, 3, 4));
|
|
|
|
$expected[] = array('fourParamMethod' => array(1, 2, 3, 4));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$this->object->dispatchMethod('fiveParamMethod', array(1, 2, 3, 4, 5));
|
|
|
|
$expected[] = array('fiveParamMethod' => array(1, 2, 3, 4, 5));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('crazyMethod', array(1, 2, 3, 4, 5, 6, 7));
|
|
|
|
$expected[] = array('crazyMethod' => array(1, 2, 3, 4, 5, 6, 7));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('methodWithOptionalParam', array('Hello'));
|
|
|
|
$expected[] = array('methodWithOptionalParam' => array("Hello"));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
|
|
|
|
$this->object->dispatchMethod('methodWithOptionalParam');
|
|
|
|
$expected[] = array('methodWithOptionalParam' => array(null));
|
|
|
|
$this->assertIdentical($this->object->methodCalls, $expected);
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-06-05 15:20:45 +00:00
|
|
|
/**
|
|
|
|
* testRequestAction method
|
2008-09-07 13:43:39 +00:00
|
|
|
*
|
2008-06-05 15:20:45 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
2008-06-20 20:17:23 +00:00
|
|
|
function testRequestAction() {
|
2010-08-05 03:16:26 +00:00
|
|
|
App::build(array(
|
2011-04-17 10:35:21 +00:00
|
|
|
'models' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
|
|
|
|
'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS),
|
|
|
|
'controllers' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS)
|
2011-05-24 15:01:21 +00:00
|
|
|
), true);
|
2008-05-30 11:40:08 +00:00
|
|
|
$result = $this->object->requestAction('');
|
|
|
|
$this->assertFalse($result);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
$result = $this->object->requestAction('/request_action/test_request_action');
|
|
|
|
$expected = 'This is a test';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);;
|
2008-05-30 11:40:08 +00:00
|
|
|
|
|
|
|
$result = $this->object->requestAction('/request_action/another_ra_test/2/5');
|
|
|
|
$expected = 7;
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
|
|
|
$result = $this->object->requestAction('/tests_apps/index', array('return'));
|
|
|
|
$expected = 'This is the TestsAppsController index view';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
|
|
|
$result = $this->object->requestAction('/tests_apps/some_method');
|
|
|
|
$expected = 5;
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-08-05 03:16:26 +00:00
|
|
|
$result = $this->object->requestAction('/request_action/paginate_request_action');
|
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
|
|
$result = $this->object->requestAction('/request_action/normal_request_action');
|
|
|
|
$expected = 'Hello World';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2010-08-05 03:16:26 +00:00
|
|
|
}
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-08-05 03:16:26 +00:00
|
|
|
/**
|
|
|
|
* test requestAction() and plugins.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testRequestActionPlugins() {
|
|
|
|
App::build(array(
|
2011-04-17 10:35:21 +00:00
|
|
|
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin' . DS),
|
2011-05-24 15:01:21 +00:00
|
|
|
), true);
|
2011-05-10 05:16:24 +00:00
|
|
|
CakePlugin::loadAll();
|
2010-08-05 03:16:26 +00:00
|
|
|
Router::reload();
|
2011-04-17 10:35:21 +00:00
|
|
|
|
2008-07-31 00:16:16 +00:00
|
|
|
$result = $this->object->requestAction('/test_plugin/tests/index', array('return'));
|
|
|
|
$expected = 'test plugin index';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2008-07-31 00:16:16 +00:00
|
|
|
$result = $this->object->requestAction('/test_plugin/tests/index/some_param', array('return'));
|
|
|
|
$expected = 'test plugin index';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'tests', 'action' => 'index', 'plugin' => 'test_plugin'), array('return')
|
|
|
|
);
|
2008-07-31 00:16:16 +00:00
|
|
|
$expected = 'test plugin index';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2008-07-31 00:16:16 +00:00
|
|
|
$result = $this->object->requestAction('/test_plugin/tests/some_method');
|
2008-05-30 11:40:08 +00:00
|
|
|
$expected = 25;
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-05-30 11:40:08 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'tests', 'action' => 'some_method', 'plugin' => 'test_plugin')
|
|
|
|
);
|
2008-05-30 11:40:08 +00:00
|
|
|
$expected = 25;
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2010-08-05 03:16:26 +00:00
|
|
|
}
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2010-08-05 03:16:26 +00:00
|
|
|
/**
|
|
|
|
* test requestAction() with arrays.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testRequestActionArray() {
|
|
|
|
App::build(array(
|
2011-04-17 10:35:21 +00:00
|
|
|
'models' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Model' . DS),
|
|
|
|
'views' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'View' . DS),
|
|
|
|
'controllers' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Controller' . DS),
|
|
|
|
'plugins' => array(CAKE . 'Test' . DS . 'test_app' . DS . 'Plugin'. DS)
|
2011-05-24 15:01:21 +00:00
|
|
|
), true);
|
2011-05-10 05:16:24 +00:00
|
|
|
CakePlugin::loadAll();
|
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'request_action', 'action' => 'test_request_action')
|
|
|
|
);
|
2010-08-05 03:16:26 +00:00
|
|
|
$expected = 'This is a test';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
2011-04-17 10:35:21 +00:00
|
|
|
array('controller' => 'request_action', 'action' => 'another_ra_test'),
|
2010-08-05 03:18:33 +00:00
|
|
|
array('pass' => array('5', '7'))
|
|
|
|
);
|
2010-08-05 03:16:26 +00:00
|
|
|
$expected = 12;
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'tests_apps', 'action' => 'index'), array('return')
|
|
|
|
);
|
2010-08-05 03:16:26 +00:00
|
|
|
$expected = 'This is the TestsAppsController index view';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2010-08-05 03:16:26 +00:00
|
|
|
$result = $this->object->requestAction(array('controller' => 'tests_apps', 'action' => 'some_method'));
|
|
|
|
$expected = 5;
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2010-08-05 03:16:26 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'request_action', 'action' => 'normal_request_action')
|
|
|
|
);
|
2008-09-07 13:43:39 +00:00
|
|
|
$expected = 'Hello World';
|
2011-05-16 22:49:00 +00:00
|
|
|
$this->assertEqual($expected, $result);
|
2008-09-07 13:43:39 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'request_action', 'action' => 'paginate_request_action')
|
|
|
|
);
|
2008-09-07 13:43:39 +00:00
|
|
|
$this->assertTrue($result);
|
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'request_action', 'action' => 'paginate_request_action'),
|
|
|
|
array('pass' => array(5), 'named' => array('param' => 'value'))
|
|
|
|
);
|
2009-02-25 01:36:13 +00:00
|
|
|
$this->assertTrue($result);
|
2008-07-09 03:15:01 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-10-22 17:12:30 +00:00
|
|
|
/**
|
|
|
|
* Test that requestAction() is populating $this->params properly
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testRequestActionParamParseAndPass() {
|
|
|
|
$result = $this->object->requestAction('/request_action/params_pass');
|
2011-04-22 12:16:13 +00:00
|
|
|
$this->assertEqual($result->url, 'request_action/params_pass');
|
2008-10-22 17:12:30 +00:00
|
|
|
$this->assertEqual($result['controller'], 'request_action');
|
|
|
|
$this->assertEqual($result['action'], 'params_pass');
|
|
|
|
$this->assertEqual($result['plugin'], null);
|
2009-02-25 01:36:13 +00:00
|
|
|
|
2009-01-07 20:16:52 +00:00
|
|
|
$result = $this->object->requestAction('/request_action/params_pass/sort:desc/limit:5');
|
|
|
|
$expected = array('sort' => 'desc', 'limit' => 5,);
|
|
|
|
$this->assertEqual($result['named'], $expected);
|
2009-02-25 01:36:13 +00:00
|
|
|
|
2010-08-05 03:18:33 +00:00
|
|
|
$result = $this->object->requestAction(
|
2011-04-17 10:35:21 +00:00
|
|
|
array('controller' => 'request_action', 'action' => 'params_pass'),
|
2010-08-05 03:18:33 +00:00
|
|
|
array('named' => array('sort' => 'desc', 'limit' => 5))
|
|
|
|
);
|
2009-01-07 20:16:52 +00:00
|
|
|
$this->assertEqual($result['named'], $expected);
|
2008-10-22 17:12:30 +00:00
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-10-21 02:04:42 +00:00
|
|
|
/**
|
|
|
|
* test requestAction and POST parameter passing, and not passing when url is an array.
|
|
|
|
*
|
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testRequestActionPostPassing() {
|
|
|
|
$_tmp = $_POST;
|
2008-10-22 17:12:30 +00:00
|
|
|
|
2008-10-21 02:04:42 +00:00
|
|
|
$_POST = array('data' => array(
|
|
|
|
'item' => 'value'
|
|
|
|
));
|
|
|
|
$result = $this->object->requestAction(array('controller' => 'request_action', 'action' => 'post_pass'));
|
2010-06-21 03:14:14 +00:00
|
|
|
$expected = null;
|
2010-11-14 06:01:11 +00:00
|
|
|
$this->assertEmpty($result);
|
2008-10-22 17:12:30 +00:00
|
|
|
|
2010-11-14 06:01:11 +00:00
|
|
|
$result = $this->object->requestAction(
|
|
|
|
array('controller' => 'request_action', 'action' => 'post_pass'),
|
|
|
|
array('data' => $_POST['data'])
|
|
|
|
);
|
2008-10-21 02:04:42 +00:00
|
|
|
$expected = $_POST['data'];
|
|
|
|
$this->assertEqual($expected, $result);
|
2008-10-22 17:12:30 +00:00
|
|
|
|
2008-10-21 02:04:42 +00:00
|
|
|
$result = $this->object->requestAction('/request_action/post_pass');
|
|
|
|
$expected = $_POST['data'];
|
|
|
|
$this->assertEqual($expected, $result);
|
2008-10-22 17:12:30 +00:00
|
|
|
|
2008-10-21 02:04:42 +00:00
|
|
|
$_POST = $_tmp;
|
|
|
|
}
|
2009-07-24 19:18:37 +00:00
|
|
|
|
2008-07-09 03:15:01 +00:00
|
|
|
/**
|
|
|
|
* testCakeError
|
|
|
|
*
|
|
|
|
* @return void
|
2009-11-14 12:19:25 +00:00
|
|
|
*/
|
2008-07-09 03:15:01 +00:00
|
|
|
function testCakeError() {
|
|
|
|
|
2008-05-30 11:40:08 +00:00
|
|
|
}
|
|
|
|
}
|