Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Starting to migrate internal tests files to the new file schema, and …
…fixing related tests
  • Loading branch information
lorenzo committed Apr 10, 2011
1 parent 6737380 commit 7f2734d
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 59 deletions.
9 changes: 5 additions & 4 deletions lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -181,13 +181,14 @@ public function getClassName($objectType) {
if ($this->plugin) {
$path = Inflector::pluralize($type);
if ($type === 'helper') {
$path = 'views' . DS . $path;
$path = 'View/Helper';
} elseif ($type === 'component') {
$path = 'controllers' . DS . $path;
$path = 'Controller/Component';
} elseif ($type === 'behavior') {
$path = 'models' . DS . $path;
$path = 'Model/Behavior';
}
$options = App::objects($type, App::pluginPath($this->plugin) . $path, false);
$plugin = $this->plugin . '.';
$options = App::objects($plugin . $type);
} else {
$options = App::objects($type);
}
Expand Down
10 changes: 5 additions & 5 deletions lib/Cake/tests/cases/libs/app.test.php
Expand Up @@ -253,7 +253,7 @@ function testListObjects() {

App::build(array(
'plugins' => array(
LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS
LIBS . 'tests' . DS . 'test_app' . DS . 'Lib' . DS
)
));
$result = App::objects('plugin', null, false);
Expand All @@ -270,7 +270,7 @@ function testListObjects() {
*/
function testListObjectsInPlugin() {
App::build(array(
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));

Expand Down Expand Up @@ -442,7 +442,7 @@ function testClassLoading() {
*/
function testPluginImporting() {
App::build(array(
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Lib' . DS),
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));

Expand Down Expand Up @@ -485,7 +485,7 @@ function testImportingHelpersFromAlternatePaths() {
$this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.');
App::build(array(
'View/Helper' => array(
LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'helpers' . DS
LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'Helper' . DS
)
));
$this->assertFalse(class_exists('BananaHelper', false), 'BananaHelper exists, cannot test importing it.');
Expand Down Expand Up @@ -600,7 +600,7 @@ function testMultipleLoading() {
$this->markTestSkipped('Cannot test loading of classes that exist.');
}
App::build(array(
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS)
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS)
));
$toLoad = array('PersisterOne', 'PersisterTwo');
$load = App::import('Model', $toLoad);
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/tests/cases/libs/cake_log.test.php
Expand Up @@ -47,7 +47,7 @@ function setUp() {
*/
function testImportingLoggers() {
App::build(array(
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'libs' . DS),
'libs' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Lib' . DS),
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);

Expand Down
4 changes: 3 additions & 1 deletion lib/Cake/tests/cases/libs/cake_session.test.php
Expand Up @@ -527,7 +527,9 @@ function testReadAndWriteWithCakeStorage() {
*/
function testUsingAppLibsHandler() {
App::build(array(
'Model/Datasource/Session' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS . 'datasources' . DS . 'Session' . DS),
'Model/Datasource/Session' => array(
LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS . 'Datasource' . DS . 'Session' . DS
),
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
), true);
Configure::write('Session', array(
Expand Down
Expand Up @@ -255,7 +255,7 @@ function setUp() {
ClassRegistry::addObject('view', new View($this->Controller));

App::build(array(
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));
}

Expand Down Expand Up @@ -805,7 +805,7 @@ function testSendDebugWithNoSessions() {
*/
function testMessageRetrievalWithoutTemplate() {
App::build(array(
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));

$this->Controller->EmailTest->to = 'postmaster@localhost';
Expand Down Expand Up @@ -843,7 +843,7 @@ function testMessageRetrievalWithoutTemplate() {
*/
function testMessageRetrievalWithTemplate() {
App::build(array(
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));

$this->Controller->set('value', 22091985);
Expand Down Expand Up @@ -1176,7 +1176,7 @@ function testReset() {
function testPluginCustomViewClass() {
App::build(array(
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));

$this->Controller->view = 'TestPlugin.Email';
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/tests/cases/libs/controller/scaffold.test.php
Expand Up @@ -279,7 +279,7 @@ function setUp() {
$this->Controller->response = $this->getMock('CakeResponse', array('_sendHeader'));

App::build(array(
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS),
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS),
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS)
));
}
Expand Down Expand Up @@ -349,11 +349,11 @@ function testGetViewFilename() {

$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_edit');
$expected = LIBS . 'tests' . DS . 'test_app' .DS . 'views' . DS . 'posts' . DS . 'scaffold.form.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' .DS . 'View' . DS . 'posts' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);

$result = $ScaffoldView->testGetFilename('edit');
$expected = LIBS . 'tests' . DS . 'test_app' .DS . 'views' . DS . 'posts' . DS . 'scaffold.form.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' .DS . 'View' . DS . 'posts' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);

$Controller = new ScaffoldMockController($this->request);
Expand All @@ -369,12 +369,12 @@ function testGetViewFilename() {
$ScaffoldView = new TestScaffoldView($Controller);
$result = $ScaffoldView->testGetFilename('admin_add');
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins'
. DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.form.ctp';
. DS .'test_plugin' . DS . 'View' . DS . 'tests' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);

$result = $ScaffoldView->testGetFilename('add');
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'plugins'
. DS .'test_plugin' . DS . 'views' . DS . 'tests' . DS . 'scaffold.form.ctp';
. DS .'test_plugin' . DS . 'View' . DS . 'tests' . DS . 'scaffold.form.ctp';
$this->assertEqual($result, $expected);

Configure::write('Routing.prefixes', $_admin);
Expand All @@ -392,7 +392,7 @@ function testGetViewFileNameWithTheme() {
$ScaffoldView = new TestScaffoldView($this->Controller);

$result = $ScaffoldView->testGetFilename('index');
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS
. 'themed' . DS . 'test_theme' . DS . 'posts' . DS . 'scaffold.index.ctp';
$this->assertEqual($result, $expected);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/Cake/tests/cases/libs/controller_test_case.test.php
Expand Up @@ -123,9 +123,9 @@ function setUp() {
parent::setUp();
App::build(array(
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'controllers' . DS),
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'models' . DS),
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS)
'Controller' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Controller' . DS),
'Model' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'Model' . DS),
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS)
));
$this->Case = new ControllerTestCase();
Router::reload();
Expand Down
12 changes: 6 additions & 6 deletions lib/Cake/tests/cases/libs/dispatcher.test.php
Expand Up @@ -765,7 +765,7 @@ function testMissingActionFromBaseClassMethods() {
*/
public function testDispatchBasic() {
App::build(array(
'views' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));
$Dispatcher = new TestDispatcher();
Configure::write('App.baseUrl', '/index.php');
Expand Down Expand Up @@ -1207,7 +1207,7 @@ public function testAssets() {
App::build(array(
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'vendors' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'vendors'. DS),
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));

$Dispatcher = new TestDispatcher();
Expand All @@ -1231,21 +1231,21 @@ public function testAssets() {
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/flash/theme_test.swf'));
$result = ob_get_clean();

$file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
$file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'flash' . DS . 'theme_test.swf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load swf file from the theme.', $result);

ob_start();
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/pdfs/theme_test.pdf'));
$result = ob_get_clean();
$file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
$file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'pdfs' . DS . 'theme_test.pdf');
$this->assertEqual($file, $result);
$this->assertEqual('this is just a test to load pdf file from the theme.', $result);

ob_start();
$Dispatcher->dispatch(new CakeRequest('theme/test_theme/img/test.jpg'));
$result = ob_get_clean();
$file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
$file = file_get_contents(LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'webroot' . DS . 'img' . DS . 'test.jpg');
$this->assertEqual($file, $result);

ob_start();
Expand Down Expand Up @@ -1392,7 +1392,7 @@ public function testFullPageCachingDispatch() {
Router::connect('/', array('controller' => 'test_cached_pages', 'action' => 'index'));

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

$dispatcher = new TestDispatcher();
Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/tests/cases/libs/view/helpers/cache.test.php
Expand Up @@ -83,7 +83,7 @@ function setUp() {
Configure::write('Cache.check', true);
Configure::write('Cache.disable', false);
App::build(array(
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
), true);
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Cake/tests/cases/libs/view/helpers/session.test.php
Expand Up @@ -132,7 +132,7 @@ function testFlash() {
$this->assertEqual($result, $expected);

App::build(array(
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));
$result = $this->Session->flash('notification');
$result = str_replace("\r\n", "\n", $result);
Expand Down
18 changes: 9 additions & 9 deletions lib/Cake/tests/cases/libs/view/theme.test.php
Expand Up @@ -118,7 +118,7 @@ function setUp() {
$this->ThemeView = new ThemeView($this->PostsController);
App::build(array(
'plugins' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'plugins' . DS),
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'views'. DS)
'View' => array(LIBS . 'tests' . DS . 'test_app' . DS . 'View'. DS)
));
}

Expand Down Expand Up @@ -150,15 +150,15 @@ function testPluginThemedGetTemplate() {
$this->Controller->theme = 'test_theme';

$ThemeView = new TestThemeView($this->Controller);
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'tests' . DS .'index.ctp';
$result = $ThemeView->getViewFileName('index');
$this->assertEqual($result, $expected);

$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'plugin_default.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'plugins' . DS . 'test_plugin' . DS . 'layouts' . DS .'plugin_default.ctp';
$result = $ThemeView->getLayoutFileName('plugin_default');
$this->assertEqual($result, $expected);

$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp';
$result = $ThemeView->getLayoutFileName('default');
$this->assertEqual($result, $expected);
}
Expand All @@ -178,25 +178,25 @@ function testGetTemplate() {

$ThemeView = new TestThemeView($this->Controller);
$ThemeView->theme = 'test_theme';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS .'pages' . DS .'home.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS .'pages' . DS .'home.ctp';
$result = $ThemeView->getViewFileName('home');
$this->assertEqual($result, $expected);

$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'posts' . DS .'index.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'posts' . DS .'index.ctp';
$result = $ThemeView->getViewFileName('/posts/index');
$this->assertEqual($result, $expected);

$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'themed' . DS . 'test_theme' . DS . 'layouts' . DS .'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEqual($result, $expected);

$ThemeView->layoutPath = 'rss';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'layouts' . DS . 'rss' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEqual($result, $expected);

$ThemeView->layoutPath = 'email' . DS . 'html';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'views' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp';
$expected = LIBS . 'tests' . DS . 'test_app' . DS . 'View' . DS . 'layouts' . DS . 'email' . DS . 'html' . DS . 'default.ctp';
$result = $ThemeView->getLayoutFileName();
$this->assertEqual($result, $expected);
}
Expand Down

0 comments on commit 7f2734d

Please sign in to comment.