Skip to content

Commit

Permalink
simplified App::path(). Changed App::build() to handle all paths.
Browse files Browse the repository at this point in the history
tests passing.
  • Loading branch information
gwoo committed Jun 11, 2009
1 parent c364376 commit f9339e3
Show file tree
Hide file tree
Showing 21 changed files with 373 additions and 280 deletions.
211 changes: 100 additions & 111 deletions cake/libs/configure.php

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions cake/tests/cases/basics.test.php
Expand Up @@ -40,8 +40,9 @@ class BasicsTest extends CakeTestCase {
* @return void
*/
function setUp() {
$this->_localePaths = App::path('locales');;
App::path('locales', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale'));
App::build(array(
'locales' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'locale')
));
$this->_language = Configure::read('Config.language');
}
/**
Expand All @@ -51,7 +52,7 @@ function setUp() {
* @return void
*/
function tearDown() {
App::path('locales', $this->_localePaths);
App::build();
Configure::write('Config.language', $this->_language);
}
/**
Expand Down
23 changes: 11 additions & 12 deletions cake/tests/cases/console/cake.test.php
Expand Up @@ -123,16 +123,15 @@ class ShellDispatcherTest extends UnitTestCase {
* @return void
*/
function setUp() {
$this->_pluginPaths = App::path('plugins');
$this->_shellPaths = App::path('shells');

App::path('plugins', array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
));
Configure::write('shellPaths', array(
CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
));
App::build(array(
'plugins' => array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS
),
'shells' => array(
CORE_PATH ? CONSOLE_LIBS : ROOT . DS . CONSOLE_LIBS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors' . DS . 'shells' . DS
)
), true);
}
/**
* tearDown method
Expand All @@ -141,8 +140,7 @@ function setUp() {
* @return void
*/
function tearDown() {
App::path('plugins', $this->_pluginPaths);
Configure::write('shellPaths', $this->_shellPaths);
App::build();
}
/**
* testParseParams method
Expand Down Expand Up @@ -407,6 +405,7 @@ function testBuildPaths() {
$Dispatcher =& new TestShellDispatcher();

$result = $Dispatcher->shellPaths;

$expected = array(
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin' . DS . 'vendors' . DS . 'shells' . DS,
TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS . 'test_plugin_two' . DS . 'vendors' . DS . 'shells' . DS,
Expand Down
15 changes: 6 additions & 9 deletions cake/tests/cases/console/libs/shell.test.php
Expand Up @@ -119,13 +119,11 @@ function testConstruct() {
* @access public
*/
function testInitialize() {
$_back = array(
'modelPaths' => App::path('models'),
'pluginPaths' => App::path('plugins'),
'viewPaths' => App::path('views'),
);
App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
App::path('models', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS));
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS)
), true);

$this->Shell->uses = array('TestPlugin.TestPluginPost');
$this->Shell->initialize();

Expand All @@ -144,8 +142,7 @@ function testInitialize() {
$this->assertTrue(isset($this->Shell->AppModel));
$this->assertIsA($this->Shell->AppModel, 'AppModel');

App::path('plugins', $_back['pluginPaths']);
App::path('models', $_back['modelPaths']);
App::build();
}
/**
* testOut method
Expand Down
29 changes: 13 additions & 16 deletions cake/tests/cases/dispatcher.test.php
Expand Up @@ -509,14 +509,9 @@ function startTest() {
$this->_cache = Configure::read('Cache');
Configure::write('Cache.disable', true);

$this->_vendorPaths = App::path('vendors');
$this->_pluginPaths = App::path('plugins');
$this->_viewPaths = App::path('views');
$this->_controllerPaths = App::path('controllers');
$this->_debug = Configure::read('debug');

App::path('controllers', Configure::corePaths('controller'));
App::path('views', Configure::corePaths('view'));
App::build(App::core());
}
/**
* tearDown method
Expand All @@ -529,12 +524,9 @@ function endTest() {
$_POST = $this->_post;
$_FILES = $this->_files;
$_SERVER = $this->_server;
App::build();
Configure::write('App', $this->_app);
Configure::write('Cache', $this->_cache);
App::path('vendors', $this->_vendorPaths);
App::path('plugins', $this->_pluginPaths);
App::path('views', $this->_viewPaths);
App::path('controllers', $this->_controllerPaths);
Configure::write('debug', $this->_debug);
}
/**
Expand Down Expand Up @@ -1623,16 +1615,17 @@ function testPrefixProtection() {
**/
function testTestPluginDispatch() {
$Dispatcher =& new TestDispatcher();
$_back = App::path('plugins');
App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
$url = '/test_plugin/tests/index';
$result = $Dispatcher->dispatch($url, array('return' => 1));
$this->assertTrue(class_exists('TestsController'));
$this->assertTrue(class_exists('TestPluginAppController'));
$this->assertTrue(class_exists('OtherComponentComponent'));
$this->assertTrue(class_exists('PluginsComponentComponent'));

App::path('plugins', $_back);
App::build();
}
/**
* testChangingParamsFromBeforeFilter method
Expand Down Expand Up @@ -1678,8 +1671,10 @@ function testStaticAssets() {
$Configure = Configure::getInstance();
$Configure->__objects = null;

App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
App::path('vendors', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS));
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'vendors' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'vendors'. DS)
));

$Dispatcher =& new TestDispatcher();

Expand Down Expand Up @@ -1734,7 +1729,9 @@ function testFullPageCachingDispatch() {
Router::reload();
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));

App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views'. DS));
App::build(array(
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
), true);

$dispatcher =& new Dispatcher();
$dispatcher->base = false;
Expand Down
49 changes: 21 additions & 28 deletions cake/tests/cases/libs/cake_test_case.test.php
Expand Up @@ -93,6 +93,15 @@ function tearDown() {
unset($this->Case);
unset($this->Reporter);
}
/**
* endTest
*
* @access public
* @return void
*/
function endTest() {
App::build();
}
/**
* testAssertGoodTags
*
Expand Down Expand Up @@ -238,16 +247,12 @@ function testGetTests() {
* @return void
**/
function testTestAction() {
$_back = array(
'controller' => App::path('controllers'),
'view' => App::path('views'),
'model' => App::path('models'),
'plugin' => App::path('plugins')
);
App::path('controllers', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS));
App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS));
App::path('models', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS));
App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
), true);

$result = $this->Case->testAction('/tests_apps/index', array('return' => 'view'));
$this->assertPattern('/This is the TestsAppsController index view/', $result);
Expand Down Expand Up @@ -365,12 +370,6 @@ function testTestAction() {
$db =& ConnectionManager::getDataSource('test_suite');
$db->config['prefix'] = $_backPrefix;
$fixture->drop($db);


App::path('models', $_back['model']);
App::path('controllers', $_back['controller']);
App::path('views', $_back['view']);
App::path('plugins', $_back['plugin']);
}
/**
* testSkipIf
Expand All @@ -388,14 +387,12 @@ function testSkipIf() {
* @return void
*/
function testTestDispatcher() {
$_back = array(
'controller' => App::path('controllers'),
'view' => App::path('views'),
'plugin' => App::path('plugins')
);
App::path('controllers', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS));
App::path('views', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS));
App::path('plugins', array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS));
App::build(array(
'plugins' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'models' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'views' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'views' . DS),
'controllers' => array(TEST_CAKE_CORE_INCLUDE_PATH . 'tests' . DS . 'test_app' . DS . 'controllers' . DS)
), true);

$Dispatcher =& new CakeTestDispatcher();
$Case =& new CakeDispatcherMockTestCase();
Expand All @@ -407,10 +404,6 @@ function testTestDispatcher() {
$this->assertTrue(isset($Dispatcher->testCase));

$return = $Dispatcher->dispatch('/tests_apps/index', array('autoRender' => 0, 'return' => 1, 'requested' => 1));

App::path('controllers', $_back['controller']);
App::path('views', $_back['view']);
App::path('plugins', $_back['plugin']);
}
}
?>
2 changes: 1 addition & 1 deletion cake/tests/cases/libs/code_coverage_manager.test.php
Expand Up @@ -116,7 +116,7 @@ function testGetTestObjectFileNameFromTestCaseFile() {
$expected = $manager->__testObjectFileFromCaseFile('models/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'some_file.php', $expected);

$expected = $manager->__testObjectFileFromCaseFile('datasources/some_file.test.php', true);
$expected = $manager->__testObjectFileFromCaseFile('models/datasources/some_file.test.php', true);
$this->assertIdentical(APP.'models'.DS.'datasources'.DS.'some_file.php', $expected);

$expected = $manager->__testObjectFileFromCaseFile('controllers/some_file.test.php', true);
Expand Down

0 comments on commit f9339e3

Please sign in to comment.