Skip to content

Commit

Permalink
Making more tests no longer skip in test suites.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 16, 2010
1 parent 95f5832 commit 42754c6
Showing 1 changed file with 38 additions and 47 deletions.
85 changes: 38 additions & 47 deletions cake/tests/cases/libs/controller/controller.test.php
Expand Up @@ -22,46 +22,38 @@
App::import('Component', 'Security');
App::import('Component', 'Cookie');


/**
* AppController class
*
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
if (!class_exists('AppController')) {
/**
* 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);
class ControllerTestAppController 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');
}


/**
* ControllerPost class
*
Expand Down Expand Up @@ -137,7 +129,7 @@ function find($type, $options = array()) {
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class ControllerCommentsController extends AppController {
class ControllerCommentsController extends ControllerTestAppController {

/**
* name property
Expand All @@ -146,6 +138,8 @@ class ControllerCommentsController extends AppController {
* @access public
*/
public $name = 'ControllerComments';

protected $_mergeParent = 'ControllerTestAppController';
}

/**
Expand Down Expand Up @@ -259,7 +253,7 @@ class NameTest extends CakeTestModel {
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class TestController extends AppController {
class TestController extends ControllerTestAppController {

/**
* name property
Expand Down Expand Up @@ -291,6 +285,8 @@ class TestController extends AppController {
* @access public
*/
public $uses = array('ControllerComment', 'ControllerAlias');

protected $_mergeParent = 'ControllerTestAppController';

/**
* index method
Expand Down Expand Up @@ -367,7 +363,7 @@ function beforeRender(&$controller) {
* @package cake
* @subpackage cake.tests.cases.libs.controller
*/
class AnotherTestController extends AppController {
class AnotherTestController extends ControllerTestAppController {

/**
* name property
Expand All @@ -382,6 +378,8 @@ class AnotherTestController extends AppController {
* @access public
*/
public $uses = null;

protected $_mergeParent = 'ControllerTestAppController';
}

/**
Expand Down Expand Up @@ -870,17 +868,13 @@ function testRedirectBeforeRedirectModifyingParamsArrayReturn() {
* @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'])
Expand All @@ -900,12 +894,12 @@ function testMergeVars() {
$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');


Expand All @@ -918,7 +912,7 @@ function testMergeVars() {
$TestController = new ControllerCommentsController($request);
$TestController->constructClasses();

$appVars = get_class_vars('AppController');
$appVars = get_class_vars('ControllerTestAppController');
$testVars = get_class_vars('ControllerCommentsController');


Expand All @@ -936,9 +930,6 @@ function testMergeVars() {
* @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);
Expand All @@ -951,7 +942,7 @@ function testChildComponentOptionsSupercedeParents() {

/**
* 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
*/
Expand Down

0 comments on commit 42754c6

Please sign in to comment.