mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge remote branch 'origin/2.0' into 2.0-class-loading
Conflicts: lib/Cake/tests/cases/libs/controller/component.test.php lib/Cake/tests/cases/libs/controller/controller.test.php lib/Cake/tests/cases/libs/controller/pages_controller.test.php
This commit is contained in:
commit
22581516db
14 changed files with 150 additions and 263 deletions
|
@ -25,9 +25,7 @@ if (!defined('CAKE_CORE_INCLUDE_PATH')) {
|
|||
/**
|
||||
* Ensure required classes are available.
|
||||
*/
|
||||
if (!class_exists('File')) {
|
||||
uses('file');
|
||||
}
|
||||
App::import('Core', 'File');
|
||||
|
||||
/**
|
||||
* Make clean CSS
|
||||
|
|
|
@ -20,7 +20,9 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
App::import('Controller', 'Controller', false);
|
||||
App::import('Core', array('AppModel', 'Model'));
|
||||
require_once TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'lib' . DS . 'reporter' . DS . 'cake_html_reporter.php';
|
||||
require_once dirname(__FILE__) . DS . 'model' . DS . 'models.php';
|
||||
|
||||
/**
|
||||
* AppController class
|
||||
|
@ -81,13 +83,6 @@ if (!class_exists('PostsController')) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Post model
|
||||
*/
|
||||
if (!class_exists('Post')) {
|
||||
class Post extends CakeTestModel {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ControllerTestCaseTest
|
||||
|
@ -103,7 +98,7 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $fixtures = array('core.post');
|
||||
public $fixtures = array('core.post', 'core.author');
|
||||
|
||||
/**
|
||||
* reset environment.
|
||||
|
@ -111,6 +106,7 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
App::build(array(
|
||||
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
|
||||
'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
|
||||
|
@ -127,50 +123,55 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
$this->Case->controller = null;
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that ControllerTestCase::generate() creates mock objects correctly
|
||||
*/
|
||||
function testGenerate() {
|
||||
if (defined('APP_CONTROLLER_EXISTS')) {
|
||||
$this->markTestSkipped('AppController exists, cannot run.');
|
||||
}
|
||||
$Posts = $this->Case->generate('Posts');
|
||||
$this->Case->assertEquals($Posts->name, 'Posts');
|
||||
$this->Case->assertEquals($Posts->modelClass, 'Post');
|
||||
$this->Case->assertNull($Posts->response->send());
|
||||
$this->assertEquals($Posts->name, 'Posts');
|
||||
$this->assertEquals($Posts->modelClass, 'Post');
|
||||
$this->assertNull($Posts->response->send());
|
||||
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'methods' => array(
|
||||
'render'
|
||||
)
|
||||
));
|
||||
$this->Case->assertNull($Posts->render('index'));
|
||||
$this->assertNull($Posts->render('index'));
|
||||
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'models' => array('Post'),
|
||||
'components' => array('RequestHandler')
|
||||
));
|
||||
$this->Case->assertNull($Posts->Post->save(array()));
|
||||
$this->Case->assertNull($Posts->Post->find('all'));
|
||||
$this->Case->assertEquals($Posts->Post->useTable, 'posts');
|
||||
$this->Case->assertNull($Posts->RequestHandler->isAjax());
|
||||
|
||||
$this->assertInstanceOf('Post', $Posts->Post);
|
||||
$this->assertNull($Posts->Post->save(array()));
|
||||
$this->assertNull($Posts->Post->find('all'));
|
||||
$this->assertEquals($Posts->Post->useTable, 'posts');
|
||||
$this->assertNull($Posts->RequestHandler->isAjax());
|
||||
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'models' => array(
|
||||
'Post' => true
|
||||
)
|
||||
));
|
||||
$this->Case->assertNull($Posts->Post->save(array()));
|
||||
$this->Case->assertNull($Posts->Post->find('all'));
|
||||
$this->assertNull($Posts->Post->save(array()));
|
||||
$this->assertNull($Posts->Post->find('all'));
|
||||
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'models' => array(
|
||||
'Post' => array('save'),
|
||||
)
|
||||
));
|
||||
$this->Case->assertNull($Posts->Post->save(array()));
|
||||
$this->Case->assertIsA($Posts->Post->find('all'), 'array');
|
||||
$this->assertNull($Posts->Post->save(array()));
|
||||
$this->assertIsA($Posts->Post->find('all'), 'array');
|
||||
|
||||
$Posts = $this->Case->generate('Posts', array(
|
||||
'models' => array('Post'),
|
||||
|
@ -197,24 +198,24 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
function testTestAction() {
|
||||
$Controller = $this->Case->generate('TestsApps');
|
||||
$this->Case->testAction('/tests_apps/index');
|
||||
$this->Case->assertIsA($this->Case->controller->viewVars, 'array');
|
||||
$this->assertIsA($this->Case->controller->viewVars, 'array');
|
||||
|
||||
$this->Case->testAction('/tests_apps/set_action');
|
||||
$results = $this->Case->controller->viewVars;
|
||||
$expected = array(
|
||||
'var' => 'string'
|
||||
);
|
||||
$this->Case->assertEquals($expected, $results);
|
||||
$this->assertEquals($expected, $results);
|
||||
|
||||
$result = $this->Case->controller->response->body();
|
||||
$this->Case->assertPattern('/This is the TestsAppsController index view/', $result);
|
||||
$this->assertPattern('/This is the TestsAppsController index view/', $result);
|
||||
|
||||
$this->Case->testAction('/tests_apps/redirect_to');
|
||||
$results = $this->Case->headers;
|
||||
$expected = array(
|
||||
'Location' => 'http://cakephp.org'
|
||||
);
|
||||
$this->Case->assertEquals($expected, $results);
|
||||
$this->assertEquals($expected, $results);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -227,32 +228,33 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view'));
|
||||
$result = json_decode($result, true);
|
||||
$expected = array('cakephp' => 'cool');
|
||||
$this->Case->assertEquals($result, $expected);
|
||||
$this->assertEquals($result, $expected);
|
||||
|
||||
include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
|
||||
$result = $this->Case->testAction('/some_alias');
|
||||
$this->Case->assertEquals($result, 5);
|
||||
$this->assertEquals($result, 5);
|
||||
|
||||
include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
|
||||
$this->Case->testAction('/redirect_me_now');
|
||||
$result = $this->Case->headers['Location'];
|
||||
$this->Case->assertEquals($result, 'http://cakephp.org');
|
||||
$this->assertEquals($result, 'http://cakephp.org');
|
||||
|
||||
include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
|
||||
$this->Case->testAction('/redirect_me');
|
||||
$result = $this->Case->headers['Location'];
|
||||
$this->Case->assertEquals($result, Router::url(array('controller' => 'tests_apps', 'action' => 'some_method'), true));
|
||||
$this->assertEquals($result, Router::url(array('controller' => 'tests_apps', 'action' => 'some_method'), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests not using loaded routes during tests
|
||||
*
|
||||
* @expectedException MissingActionException
|
||||
*/
|
||||
function testSkipRoutes() {
|
||||
include TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'config' . DS . 'routes.php';
|
||||
|
||||
$this->Case->loadRoutes = false;
|
||||
|
||||
$this->expectException('MissingActionException');
|
||||
$result = $this->Case->testAction('/tests_apps/index.json', array('return' => 'view'));
|
||||
}
|
||||
|
||||
|
@ -263,26 +265,26 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$this->Case->autoMock = true;
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps/some_method');
|
||||
$this->Case->assertEquals($result, 5);
|
||||
$this->assertEquals($result, 5);
|
||||
|
||||
$data = array('var' => 'set');
|
||||
$result = $this->Case->testAction('/tests_apps_posts/post_var', array(
|
||||
'data' => $data,
|
||||
'return' => 'vars'
|
||||
));
|
||||
$this->Case->assertEquals($result['data'], $data);
|
||||
$this->assertEquals($result['data'], $data);
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps/set_action', array(
|
||||
'return' => 'view'
|
||||
));
|
||||
$this->Case->assertEquals($result, 'This is the TestsAppsController index view');
|
||||
$this->assertEquals($result, 'This is the TestsAppsController index view');
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps/set_action', array(
|
||||
'return' => 'contents'
|
||||
));
|
||||
$this->Case->assertPattern('/<html/', $result);
|
||||
$this->Case->assertPattern('/This is the TestsAppsController index view/', $result);
|
||||
$this->Case->assertPattern('/<\/html>/', $result);
|
||||
$this->assertPattern('/<html/', $result);
|
||||
$this->assertPattern('/This is the TestsAppsController index view/', $result);
|
||||
$this->assertPattern('/<\/html>/', $result);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -299,8 +301,8 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$this->Case->testAction('/tests_apps_posts/post_var', array(
|
||||
'data' => $data
|
||||
));
|
||||
$this->Case->assertEquals($this->Case->controller->viewVars['data'], $data);
|
||||
$this->Case->assertEquals($this->Case->controller->data, $data);
|
||||
$this->assertEquals($this->Case->controller->viewVars['data'], $data);
|
||||
$this->assertEquals($this->Case->controller->data, $data);
|
||||
|
||||
$this->Case->testAction('/tests_apps_posts/post_var/named:param', array(
|
||||
'data' => $data
|
||||
|
@ -308,8 +310,8 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$expected = array(
|
||||
'named' => 'param'
|
||||
);
|
||||
$this->Case->assertEqual($this->Case->controller->request->named, $expected);
|
||||
$this->Case->assertEquals($this->Case->controller->data, $data);
|
||||
$this->assertEqual($this->Case->controller->request->named, $expected);
|
||||
$this->assertEquals($this->Case->controller->data, $data);
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps_posts/post_var', array(
|
||||
'return' => 'vars',
|
||||
|
@ -339,8 +341,8 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
'lackof' => 'creativity'
|
||||
)
|
||||
));
|
||||
$this->Case->assertEquals($this->Case->controller->request->query['some'], 'var');
|
||||
$this->Case->assertEquals($this->Case->controller->request->query['lackof'], 'creativity');
|
||||
$this->assertEquals($this->Case->controller->request->query['some'], 'var');
|
||||
$this->assertEquals($this->Case->controller->request->query['lackof'], 'creativity');
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps_posts/url_var/var1:value1/var2:val2', array(
|
||||
'return' => 'vars',
|
||||
|
@ -378,7 +380,7 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
$expected = array(
|
||||
'var' => 'string'
|
||||
);
|
||||
$this->Case->assertEquals($expected, $results);
|
||||
$this->assertEquals($expected, $results);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -393,19 +395,19 @@ class ControllerTestCaseTest extends CakeTestCase {
|
|||
'data' => $data,
|
||||
'return' => 'vars'
|
||||
));
|
||||
$this->Case->assertEquals($result['data'], $data);
|
||||
$this->assertEquals($result['data'], $data);
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps/set_action', array(
|
||||
'return' => 'view'
|
||||
));
|
||||
$this->Case->assertEquals($result, 'This is the TestsAppsController index view');
|
||||
$this->assertEquals($result, 'This is the TestsAppsController index view');
|
||||
|
||||
$result = $this->Case->testAction('/tests_apps/set_action', array(
|
||||
'return' => 'contents'
|
||||
));
|
||||
$this->Case->assertPattern('/<html/', $result);
|
||||
$this->Case->assertPattern('/This is the TestsAppsController index view/', $result);
|
||||
$this->Case->assertPattern('/<\/html>/', $result);
|
||||
$this->assertPattern('/<html/', $result);
|
||||
$this->assertPattern('/This is the TestsAppsController index view/', $result);
|
||||
$this->assertPattern('/<\/html>/', $result);
|
||||
}
|
||||
|
||||
}
|
|
@ -242,6 +242,7 @@ class ControllerTestCase extends CakeTestCase {
|
|||
* interfere with testing.
|
||||
*
|
||||
* ### Mocks:
|
||||
*
|
||||
* - `methods` Methods to mock on the controller. `_stop()` is mocked by default
|
||||
* - `models` Models to mock. Models are added to the ClassRegistry so they any
|
||||
* time they are instatiated the mock will be created. Pass as key value pairs
|
||||
|
@ -270,6 +271,7 @@ class ControllerTestCase extends CakeTestCase {
|
|||
$_controller->name = $controller;
|
||||
$_controller->__construct();
|
||||
|
||||
$config = ClassRegistry::config('Model');
|
||||
foreach ($mocks['models'] as $model => $methods) {
|
||||
if (is_string($methods)) {
|
||||
$model = $methods;
|
||||
|
@ -278,10 +280,8 @@ class ControllerTestCase extends CakeTestCase {
|
|||
if ($methods === true) {
|
||||
$methods = array();
|
||||
}
|
||||
ClassRegistry::init($model);
|
||||
$_model = $this->getMock($model, $methods, array(), '', false);
|
||||
$_model->name = $model;
|
||||
$_model->__construct();
|
||||
$config = array_merge((array)$config, array('name' => $model));
|
||||
$_model = $this->getMock($model, $methods, array($config));
|
||||
ClassRegistry::removeObject($model);
|
||||
ClassRegistry::addObject($model, $_model);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,11 @@ class PaginatorComponent extends Component {
|
|||
if (!is_object($object)) {
|
||||
throw new MissingModelException($object);
|
||||
}
|
||||
$options = array_merge($this->Controller->request->params, $this->Controller->params['url'], $this->Controller->passedArgs);
|
||||
$options = array_merge(
|
||||
$this->Controller->request->params,
|
||||
$this->Controller->request->query,
|
||||
$this->Controller->passedArgs
|
||||
);
|
||||
|
||||
if (isset($this->settings[$object->alias])) {
|
||||
$defaults = $this->settings[$object->alias];
|
||||
|
|
|
@ -272,6 +272,15 @@ class Controller extends Object {
|
|||
*/
|
||||
public $validationErrors = null;
|
||||
|
||||
/**
|
||||
* The class name of the parent class you wish to merge with.
|
||||
* Typically this is AppController, but you may wish to merge vars with a different
|
||||
* parent class.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_mergeParent = 'AppController';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -388,7 +397,7 @@ class Controller extends Object {
|
|||
}
|
||||
|
||||
/**
|
||||
* Merge components, helpers, and uses vars from AppController and PluginAppController.
|
||||
* Merge components, helpers, and uses vars from Controller::$_mergeParent and PluginAppController.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
@ -404,8 +413,8 @@ class Controller extends Object {
|
|||
$plugin = $pluginName . '.';
|
||||
}
|
||||
|
||||
if (is_subclass_of($this, 'AppController') || !empty($pluginController)) {
|
||||
$appVars = get_class_vars('AppController');
|
||||
if (is_subclass_of($this, $this->_mergeParent) || !empty($pluginController)) {
|
||||
$appVars = get_class_vars($this->_mergeParent);
|
||||
$uses = $appVars['uses'];
|
||||
$merge = array('components', 'helpers');
|
||||
|
||||
|
@ -424,7 +433,7 @@ class Controller extends Object {
|
|||
) {
|
||||
$this->uses = array_merge($this->uses, array_diff($appVars['uses'], $this->uses));
|
||||
}
|
||||
$this->_mergeVars($merge, 'AppController', true);
|
||||
$this->_mergeVars($merge, $this->_mergeParent, true);
|
||||
}
|
||||
|
||||
if ($pluginController && $pluginName != null) {
|
||||
|
|
|
@ -61,24 +61,6 @@
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads component/components from LIBS. Takes optional number of parameters.
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* `uses('flay', 'time');`
|
||||
*
|
||||
* @param string $name Filename without the .php part
|
||||
* @deprecated Will be removed in 2.0
|
||||
* @link http://book.cakephp.org/view/1140/uses
|
||||
*/
|
||||
function uses() {
|
||||
$args = func_get_args();
|
||||
foreach ($args as $file) {
|
||||
require_once(LIBS . strtolower($file) . '.php');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints out debug information about given variable.
|
||||
*
|
||||
|
|
|
@ -168,25 +168,6 @@ class BasicsTest extends CakeTestCase {
|
|||
$_ENV = $__ENV;
|
||||
}
|
||||
|
||||
/**
|
||||
* test uses()
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
* @deprecated
|
||||
*/
|
||||
function testUses() {
|
||||
$this->skipIf(class_exists('Security') || class_exists('Sanitize'), '%s Security and/or Sanitize class already loaded');
|
||||
|
||||
$this->assertFalse(class_exists('Security'));
|
||||
$this->assertFalse(class_exists('Sanitize'));
|
||||
|
||||
uses('Security', 'Sanitize');
|
||||
|
||||
$this->assertTrue(class_exists('Security'));
|
||||
$this->assertTrue(class_exists('Sanitize'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test h()
|
||||
*
|
||||
|
|
|
@ -75,10 +75,11 @@ class ApiShellTest extends CakeTestCase {
|
|||
'16. render($action = NULL, $layout = NULL, $file = NULL)',
|
||||
'17. set($one, $two = NULL)',
|
||||
'18. setAction($action)',
|
||||
'19. shutdownProcess()',
|
||||
'20. startupProcess()',
|
||||
'21. validate()',
|
||||
'22. validateErrors()'
|
||||
'19. setRequest($request)',
|
||||
'20. shutdownProcess()',
|
||||
'21. startupProcess()',
|
||||
'22. validate()',
|
||||
'23. validateErrors()'
|
||||
);
|
||||
$this->Shell->expects($this->at(2))->method('out')->with($expected);
|
||||
|
||||
|
|
|
@ -35,7 +35,8 @@ class CakeSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function setUp() {
|
||||
$this->Socket = new CakeSocket();
|
||||
parent::setUp();
|
||||
$this->Socket = new CakeSocket(array('timeout' => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -45,6 +46,7 @@ class CakeSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Socket);
|
||||
}
|
||||
|
||||
|
@ -55,7 +57,7 @@ class CakeSocketTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testConstruct() {
|
||||
$this->Socket->__construct();
|
||||
$this->Socket = new CakeSocket();
|
||||
$config = $this->Socket->config;
|
||||
$this->assertIdentical($config, array(
|
||||
'persistent' => false,
|
||||
|
@ -109,8 +111,8 @@ class CakeSocketTest extends CakeTestCase {
|
|||
*/
|
||||
public static function invalidConnections() {
|
||||
return array(
|
||||
array(array('host' => 'invalid.host')),
|
||||
array(array('host' => '127.0.0.1', 'port' => '70000'))
|
||||
array(array('host' => 'invalid.host', 'timeout' => 1)),
|
||||
array(array('host' => '127.0.0.1', 'port' => '70000', 'timeout' => 1))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,52 +21,6 @@
|
|||
App::uses('Controller', 'Controller');
|
||||
App::uses('Component', 'Controller');
|
||||
|
||||
if (!class_exists('AppController', false)) {
|
||||
|
||||
/**
|
||||
* AppController class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
|
||||
/**
|
||||
* name property
|
||||
*
|
||||
* @var string 'App'
|
||||
* @access public
|
||||
*/
|
||||
public $name = 'App';
|
||||
|
||||
/**
|
||||
* uses property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $uses = array();
|
||||
|
||||
/**
|
||||
* helpers property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $helpers = array();
|
||||
|
||||
/**
|
||||
* components property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $components = array('Orange' => array('colour' => 'blood orange'));
|
||||
}
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')){
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* ParamTestComponent
|
||||
*
|
||||
|
@ -116,7 +70,7 @@ class ParamTestComponent extends Component {
|
|||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class ComponentTestController extends AppController {
|
||||
class ComponentTestController extends Controller {
|
||||
|
||||
/**
|
||||
* name property
|
||||
|
@ -133,6 +87,7 @@ class ComponentTestController extends AppController {
|
|||
* @access public
|
||||
*/
|
||||
public $uses = array();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -397,22 +352,4 @@ class ComponentTest extends CakeTestCase {
|
|||
$this->assertType('ComponentTestController', $Controller->SomethingWithEmail->Email->Controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test that SessionComponent doesn't get added if its already in the components array.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testDoubleLoadingOfSessionComponent() {
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$Controller = new ComponentTestController();
|
||||
$Controller->uses = false;
|
||||
$Controller->components = array('Session');
|
||||
$Controller->constructClasses();
|
||||
|
||||
$this->assertEqual($Controller->components, array('Session' => '', 'Orange' => array('colour' => 'blood orange')));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1087,13 +1087,18 @@ HTMLBLOC;
|
|||
$this->Controller->EmailTest->additionalParams = 'X-additional-header';
|
||||
$this->Controller->EmailTest->delivery = 'smtp';
|
||||
$this->Controller->EmailTest->smtpOptions['host'] = 'blah';
|
||||
$this->Controller->EmailTest->smtpOptions['timeout'] = 0.5;
|
||||
$this->Controller->EmailTest->smtpOptions['timeout'] = 0.2;
|
||||
$this->Controller->EmailTest->attachments = array('attachment1', 'attachment2');
|
||||
$this->Controller->EmailTest->textMessage = 'This is the body of the message';
|
||||
$this->Controller->EmailTest->htmlMessage = 'This is the body of the message';
|
||||
$this->Controller->EmailTest->messageId = false;
|
||||
|
||||
$this->assertFalse($this->Controller->EmailTest->send('Should not work'));
|
||||
try {
|
||||
$this->Controller->EmailTest->send('Should not work');
|
||||
$this->fail('No exception');
|
||||
} catch (SocketException $e) {
|
||||
$this->assertTrue(true, 'SocketException raised');
|
||||
}
|
||||
|
||||
$this->Controller->EmailTest->reset();
|
||||
|
||||
|
|
|
@ -23,46 +23,31 @@ App::uses('CakeResponse', 'Network');
|
|||
App::uses('SecurityComponent', 'Controller/Component');
|
||||
App::uses('CookieComponent', 'Controller/Component');
|
||||
|
||||
class ControllerTestAppController extends Controller {
|
||||
/**
|
||||
* AppController class
|
||||
* helpers property
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
if (!class_exists('AppController', false)) {
|
||||
/**
|
||||
* AppController class
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
/**
|
||||
* helpers property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $helpers = array('Html');
|
||||
/**
|
||||
* uses property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $uses = array('ControllerPost');
|
||||
/**
|
||||
* components property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $components = array('Cookie');
|
||||
}
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
public $helpers = array('Html');
|
||||
/**
|
||||
* uses property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $uses = array('ControllerPost');
|
||||
/**
|
||||
* components property
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
public $components = array('Cookie');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ControllerPost class
|
||||
*
|
||||
|
@ -138,7 +123,7 @@ class ControllerPost extends CakeTestModel {
|
|||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class ControllerCommentsController extends AppController {
|
||||
class ControllerCommentsController extends ControllerTestAppController {
|
||||
|
||||
/**
|
||||
* name property
|
||||
|
@ -147,6 +132,8 @@ class ControllerCommentsController extends AppController {
|
|||
* @access public
|
||||
*/
|
||||
public $name = 'ControllerComments';
|
||||
|
||||
protected $_mergeParent = 'ControllerTestAppController';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -260,7 +247,7 @@ class NameTest extends CakeTestModel {
|
|||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class TestController extends AppController {
|
||||
class TestController extends ControllerTestAppController {
|
||||
|
||||
/**
|
||||
* name property
|
||||
|
@ -292,6 +279,8 @@ class TestController extends AppController {
|
|||
* @access public
|
||||
*/
|
||||
public $uses = array('ControllerComment', 'ControllerAlias');
|
||||
|
||||
protected $_mergeParent = 'ControllerTestAppController';
|
||||
|
||||
/**
|
||||
* index method
|
||||
|
@ -368,7 +357,7 @@ class TestComponent extends Object {
|
|||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class AnotherTestController extends AppController {
|
||||
class AnotherTestController extends ControllerTestAppController {
|
||||
|
||||
/**
|
||||
* name property
|
||||
|
@ -383,6 +372,8 @@ class AnotherTestController extends AppController {
|
|||
* @access public
|
||||
*/
|
||||
public $uses = null;
|
||||
|
||||
protected $_mergeParent = 'ControllerTestAppController';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -871,17 +862,13 @@ class ControllerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testMergeVars() {
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
$request = new CakeRequest('controller_posts/index');
|
||||
|
||||
|
||||
$TestController = new TestController($request);
|
||||
$TestController->constructClasses();
|
||||
|
||||
$testVars = get_class_vars('TestController');
|
||||
$appVars = get_class_vars('AppController');
|
||||
$appVars = get_class_vars('ControllerTestAppController');
|
||||
|
||||
$components = is_array($appVars['components'])
|
||||
? array_merge($appVars['components'], $testVars['components'])
|
||||
|
@ -901,12 +888,12 @@ class ControllerTest extends CakeTestCase {
|
|||
$this->assertEqual(count(array_diff_assoc(Set::normalize($TestController->components), Set::normalize($components))), 0);
|
||||
|
||||
$expected = array('ControllerComment', 'ControllerAlias', 'ControllerPost');
|
||||
$this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, AppController models should be last.');
|
||||
$this->assertEquals($expected, $TestController->uses, '$uses was merged incorrectly, ControllerTestAppController models should be last.');
|
||||
|
||||
$TestController = new AnotherTestController($request);
|
||||
$TestController->constructClasses();
|
||||
|
||||
$appVars = get_class_vars('AppController');
|
||||
$appVars = get_class_vars('ControllerTestAppController');
|
||||
$testVars = get_class_vars('AnotherTestController');
|
||||
|
||||
|
||||
|
@ -919,7 +906,7 @@ class ControllerTest extends CakeTestCase {
|
|||
$TestController = new ControllerCommentsController($request);
|
||||
$TestController->constructClasses();
|
||||
|
||||
$appVars = get_class_vars('AppController');
|
||||
$appVars = get_class_vars('ControllerTestAppController');
|
||||
$testVars = get_class_vars('ControllerCommentsController');
|
||||
|
||||
|
||||
|
@ -937,9 +924,6 @@ class ControllerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testChildComponentOptionsSupercedeParents() {
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
$request = new CakeRequest('controller_posts/index');
|
||||
|
||||
$TestController = new TestController($request);
|
||||
|
@ -952,7 +936,7 @@ class ControllerTest extends CakeTestCase {
|
|||
|
||||
/**
|
||||
* Ensure that __mergeVars is not being greedy and merging with
|
||||
* AppController when you make an instance of Controller
|
||||
* ControllerTestAppController when you make an instance of Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
|
|
|
@ -21,33 +21,29 @@
|
|||
*/
|
||||
App::uses('Controller', 'Controller');
|
||||
|
||||
if (!class_exists('AppController')) {
|
||||
|
||||
/**
|
||||
* Test case AppController
|
||||
*
|
||||
* @package cake
|
||||
* @subpackage cake.tests.cases.libs.controller
|
||||
*/
|
||||
class AppController extends Controller {
|
||||
class MergeVarsAppController extends Controller {
|
||||
|
||||
/**
|
||||
* components
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $components = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false));
|
||||
public $components = array('MergeVar' => array('flag', 'otherFlag', 'redirect' => false));
|
||||
/**
|
||||
* helpers
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public $helpers = array('MergeVar' => array('format' => 'html', 'terse'));
|
||||
}
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
public $helpers = array('MergeVar' => array('format' => 'html', 'terse'));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* MergeVar Component
|
||||
*
|
||||
|
@ -62,7 +58,7 @@ class MergeVarComponent extends Object {
|
|||
*
|
||||
* @package cake.tests.cases.libs.controller
|
||||
*/
|
||||
class MergeVariablesController extends AppController {
|
||||
class MergeVariablesController extends MergeVarsAppController {
|
||||
|
||||
/**
|
||||
* name
|
||||
|
@ -77,6 +73,13 @@ class MergeVariablesController extends AppController {
|
|||
* @var arrays
|
||||
*/
|
||||
public $uses = array();
|
||||
|
||||
/**
|
||||
* parent for mergeVars
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_mergeParent = 'MergeVarsAppController';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,7 +87,7 @@ class MergeVariablesController extends AppController {
|
|||
*
|
||||
* @package cake.tests.cases.libs.controller
|
||||
*/
|
||||
class MergeVarPluginAppController extends AppController {
|
||||
class MergeVarPluginAppController extends MergeVarsAppController {
|
||||
|
||||
/**
|
||||
* components
|
||||
|
@ -99,6 +102,13 @@ class MergeVarPluginAppController extends AppController {
|
|||
* @var array
|
||||
*/
|
||||
public $helpers = array('Javascript');
|
||||
|
||||
/**
|
||||
* parent for mergeVars
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $_mergeParent = 'MergeVarsAppController';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -130,14 +140,6 @@ class MergePostsController extends MergeVarPluginAppController {
|
|||
* @package cake.tests.cases.libs.controller
|
||||
*/
|
||||
class ControllerMergeVarsTest extends CakeTestCase {
|
||||
/**
|
||||
* end test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function endTest() {
|
||||
ClassRegistry::flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* test that component settings are not duplicated when merging component settings
|
||||
|
@ -145,8 +147,6 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testComponentParamMergingNoDuplication() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller = new MergeVariablesController();
|
||||
$Controller->constructClasses();
|
||||
|
||||
|
@ -160,8 +160,6 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testComponentMergingWithRedeclarations() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller = new MergeVariablesController();
|
||||
$Controller->components['MergeVar'] = array('remote', 'redirect' => true);
|
||||
$Controller->constructClasses();
|
||||
|
@ -176,8 +174,6 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testHelperSettingMergingNoDuplication() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller = new MergeVariablesController();
|
||||
$Controller->constructClasses();
|
||||
|
||||
|
@ -192,9 +188,7 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testHelperOrderPrecedence() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller =& new MergeVariablesController();
|
||||
$Controller = new MergeVariablesController();
|
||||
$Controller->helpers = array('Custom', 'Foo' => array('something'));
|
||||
$Controller->constructClasses();
|
||||
|
||||
|
@ -212,8 +206,6 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testMergeVarsWithPlugin() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller = new MergePostsController();
|
||||
$Controller->components = array('Email' => array('ports' => 'open'));
|
||||
$Controller->plugin = 'MergeVarPlugin';
|
||||
|
@ -251,9 +243,7 @@ class ControllerMergeVarsTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testMergeVarsNotGreedy() {
|
||||
$this->skipIf(defined('APP_CONTROLLER_EXISTS'), "APP_CONTROLLER_EXISTS cannot run {$this->name}");
|
||||
|
||||
$Controller =& new Controller();
|
||||
$Controller = new Controller();
|
||||
$Controller->components = array();
|
||||
$Controller->uses = array();
|
||||
$Controller->constructClasses();
|
||||
|
|
|
@ -17,11 +17,7 @@
|
|||
* @since CakePHP(tm) v 1.2.0.5436
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
if (!class_exists('AppController', false)) {
|
||||
require_once LIBS . 'Controller' . DS . 'AppController.php';
|
||||
} elseif (!defined('APP_CONTROLLER_EXISTS')) {
|
||||
define('APP_CONTROLLER_EXISTS', true);
|
||||
}
|
||||
|
||||
App::uses('PagesController', 'Controller');
|
||||
|
||||
/**
|
||||
|
@ -49,10 +45,6 @@ class PagesControllerTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
function testDisplay() {
|
||||
if ($this->skipIf(defined('APP_CONTROLLER_EXISTS'), '%s Need a non-existent AppController')) {
|
||||
return;
|
||||
}
|
||||
|
||||
App::build(array(
|
||||
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS, TEST_CAKE_CORE_INCLUDE_PATH . 'libs' . DS . 'view' . DS)
|
||||
));
|
||||
|
|
Loading…
Reference in a new issue