2007-07-09 20:45:29 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Short description for file.
|
|
|
|
*
|
|
|
|
* Long description for file
|
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP(tm) Tests <https://trac.cakephp.org/wiki/Developement/TestSuite>
|
2008-01-01 22:18:17 +00:00
|
|
|
* Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 20:45:29 +00:00
|
|
|
* 1785 E. Sahara Avenue, Suite 490-204
|
|
|
|
* Las Vegas, Nevada 89104
|
|
|
|
*
|
|
|
|
* Licensed under The Open Group Test Suite License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
2008-01-01 22:18:17 +00:00
|
|
|
* @copyright Copyright 2005-2008, Cake Software Foundation, Inc.
|
2007-07-09 20:45:29 +00:00
|
|
|
* @link https://trac.cakephp.org/wiki/Developement/TestSuite CakePHP(tm) Tests
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.controller
|
|
|
|
* @since CakePHP(tm) v 1.2.0.5436
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
|
|
|
*/
|
2008-01-12 17:35:12 +00:00
|
|
|
uses('controller' . DS . 'component', 'controller' . DS . 'app_controller');
|
2007-07-09 20:45:29 +00:00
|
|
|
/**
|
|
|
|
* Short description for class.
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.libs.controller
|
|
|
|
*/
|
2008-01-12 17:35:12 +00:00
|
|
|
class ComponentTestController extends AppController {
|
|
|
|
var $name = 'ComponentTestController';
|
|
|
|
var $uses = array();
|
|
|
|
}
|
2007-07-09 20:45:29 +00:00
|
|
|
class ComponentTest extends CakeTestCase {
|
|
|
|
|
2008-01-12 17:35:12 +00:00
|
|
|
function setUp() {
|
|
|
|
Configure::write('pluginPaths', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
|
|
|
|
}
|
|
|
|
|
|
|
|
function testLoadComponents() {
|
2008-01-13 03:53:01 +00:00
|
|
|
$Controller = new ComponentTestController();
|
|
|
|
$Controller->components = array('RequestHandler');
|
|
|
|
|
2008-01-13 04:06:01 +00:00
|
|
|
$Component = new Component();
|
2008-01-13 03:53:01 +00:00
|
|
|
$Component->init($Controller);
|
|
|
|
|
|
|
|
$this->assertTrue(is_a($Controller->RequestHandler, 'RequestHandlerComponent'));
|
|
|
|
|
|
|
|
$Controller = new ComponentTestController();
|
|
|
|
$Controller->plugin = 'test_plugin';
|
|
|
|
$Controller->components = array('RequestHandler', 'TestPluginComponent');
|
|
|
|
|
2008-01-13 04:06:01 +00:00
|
|
|
$Component = new Component();
|
2008-01-13 03:53:01 +00:00
|
|
|
$Component->init($Controller);
|
|
|
|
|
|
|
|
$this->assertTrue(is_a($Controller->RequestHandler, 'RequestHandlerComponent'));
|
|
|
|
$this->assertTrue(is_a($Controller->TestPluginComponent, 'TestPluginComponentComponent'));
|
|
|
|
$this->assertTrue(is_a($Controller->TestPluginComponent->TestPluginOtherComponent, 'TestPluginOtherComponentComponent'));
|
|
|
|
$this->assertFalse(isset($Controller->TestPluginOtherComponent));
|
2008-01-12 17:35:12 +00:00
|
|
|
|
2008-01-13 03:53:01 +00:00
|
|
|
$Controller = new ComponentTestController();
|
|
|
|
$Controller->components = array('Security');
|
2008-01-12 17:35:12 +00:00
|
|
|
|
2008-01-13 04:06:01 +00:00
|
|
|
$Component = new Component();
|
|
|
|
$Component->init($Controller);
|
|
|
|
|
|
|
|
$this->assertTrue(is_a($Controller->Security, 'SecurityComponent'));
|
|
|
|
$this->assertTrue(is_a($Controller->Security->Session, 'SessionComponent'));
|
2008-01-12 17:35:12 +00:00
|
|
|
|
2008-01-13 03:53:01 +00:00
|
|
|
$Controller = new ComponentTestController();
|
|
|
|
$Controller->components = array('Security', 'Cookie', 'RequestHandler');
|
2008-01-12 17:35:12 +00:00
|
|
|
|
2008-01-13 04:06:01 +00:00
|
|
|
$Component = new Component();
|
|
|
|
$Component->init($Controller);
|
|
|
|
|
2008-01-13 03:53:01 +00:00
|
|
|
$this->assertTrue(is_a($Controller->Security, 'SecurityComponent'));
|
|
|
|
$this->assertTrue(is_a($Controller->Security->RequestHandler, 'RequestHandlerComponent'));
|
|
|
|
$this->assertTrue(is_a($Controller->RequestHandler, 'RequestHandlerComponent'));
|
|
|
|
$this->assertTrue(is_a($Controller->Cookie, 'CookieComponent'));
|
2007-07-09 20:45:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|