Skip to content
Permalink
Browse files

Update Component test case.

  • Loading branch information...
markstory committed Jul 14, 2013
1 parent 543162c commit 0f5ec8345edcaf6a01133872eb1c3379f2a25a4c
@@ -20,6 +20,7 @@
use Cake\Controller\Component;
use Cake\Controller\Controller;
use Cake\Event\Event;
/**
* AppleComponent class
@@ -45,10 +46,11 @@ class AppleComponent extends Component {
/**
* startup method
*
* @param Event $event
* @param mixed $controller
* @return void
*/
public function startup(Controller $controller) {
public function startup(Event $event, Controller $controller) {
$this->testName = $controller->name;
}
}
@@ -20,6 +20,7 @@
use Cake\Controller\Component;
use Cake\Controller\Controller;
use Cake\Event\Event;
/**
* BananaComponent class
@@ -38,10 +39,11 @@ class BananaComponent extends Component {
/**
* startup method
*
* @param Event $event
* @param Controller $controller
* @return string
*/
public function startup(Controller $controller) {
public function startup(Event $event, Controller $controller) {
$controller->bar = 'fail';
}
}
@@ -16,6 +16,7 @@
use Cake\Controller\Component;
use Cake\Controller\Controller;
use Cake\Event\Event;
/**
* OrangeComponent class
@@ -33,21 +34,23 @@ class OrangeComponent extends Component {
/**
* initialize method
*
* @param mixed $controller
* @param Event $event
* @param Controller $controller
* @return void
*/
public function initialize(Controller $controller) {
public function initialize(Event $event, Controller $controller) {
$this->Controller = $controller;
$this->Banana->testField = 'OrangeField';
}
/**
* startup method
*
* @param Event $event
* @param Controller $controller
* @return string
*/
public function startup(Controller $controller) {
public function startup(Event $event, Controller $controller) {
$controller->foo = 'pass';
}
}
@@ -84,12 +84,18 @@ public function testNestedComponentLoading() {
* @return void
*/
public function testInnerComponentsAreNotEnabled() {
$Collection = new ComponentCollection();
$mock = $this->getMock('Cake\Event\EventManager');
$controller = new Controller();
$controller->setEventManager($mock);
$mock->expects($this->once())
->method('attach')
->with($this->isInstanceOf('TestApp\Controller\Component\AppleComponent'));
$Collection = new ComponentCollection($controller);
$Apple = $Collection->load('Apple');
$this->assertInstanceOf('TestApp\Controller\Component\OrangeComponent', $Apple->Orange, 'class is wrong');
$result = $Collection->enabled();
$this->assertEquals(array('Apple'), $result, 'Too many components enabled.');
}
/**

0 comments on commit 0f5ec83

Please sign in to comment.
You can’t perform that action at this time.