Skip to content
Permalink
Browse files

simplified App::path(). Changed App::build() to handle all paths.

tests passing.
  • Loading branch information...
gwoo
gwoo committed Jun 11, 2009
1 parent c364376 commit f9339e3c81978aab45788f38a0a1fa9a48b3bd23

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -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');
}
/**
@@ -51,7 +52,7 @@ function setUp() {
* @return void
*/
function tearDown() {
App::path('locales', $this->_localePaths);
App::build();
Configure::write('Config.language', $this->_language);
}
/**
@@ -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
@@ -141,8 +140,7 @@ function setUp() {
* @return void
*/
function tearDown() {
App::path('plugins', $this->_pluginPaths);
Configure::write('shellPaths', $this->_shellPaths);
App::build();
}
/**
* testParseParams method
@@ -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,
@@ -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();
@@ -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
@@ -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
@@ -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);
}
/**
@@ -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
@@ -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();
@@ -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;
@@ -93,6 +93,15 @@ function tearDown() {
unset($this->Case);
unset($this->Reporter);
}
/**
* endTest
*
* @access public
* @return void
*/
function endTest() {
App::build();
}
/**
* testAssertGoodTags
*
@@ -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);
@@ -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
@@ -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();
@@ -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']);
}
}
?>
@@ -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);
Oops, something went wrong.

0 comments on commit f9339e3

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