Browse Source

Fixed few test cases related with namespaces

Juan Basso 13 years ago
parent
commit
7917481a9c

+ 1 - 1
lib/Cake/I18n/I18n.php

@@ -303,7 +303,7 @@ class I18n {
 		$this->_noLocale = true;
 		$core = true;
 		$merge = array();
-		$searchPaths = App::path('locales');
+		$searchPaths = App::path('Locale');
 		$plugins = Plugin::loaded();
 
 		if (!empty($plugins)) {

+ 1 - 4
lib/Cake/Test/TestCase/TestSuite/ControllerTestCaseTest.php

@@ -143,9 +143,6 @@ class ControllerTestCaseTest extends TestCase {
  * Test that ControllerTestCase::generate() creates mock objects correctly
  */
 	public function testGenerate() {
-		if (defined('APP_CONTROLLER_EXISTS')) {
-			$this->markTestSkipped('AppController exists, cannot run.');
-		}
 		$Posts = $this->Case->generate(__NAMESPACE__ . '\PostsController');
 		$this->assertEquals('Posts', $Posts->name);
 		$this->assertEquals('Post', $Posts->modelClass);
@@ -221,7 +218,7 @@ class ControllerTestCaseTest extends TestCase {
 		$result = ClassRegistry::init('TestPlugin.TestPluginComment');
 		$this->assertInstanceOf('TestPlugin\Model\TestPluginComment', $result);
 
-		$Tests = $this->Case->generate(__NAMESPACE__ . '\ControllerTestCaseTest', array(
+		$Tests = $this->Case->generate(__NAMESPACE__ . '\ControllerTestCaseTestController', array(
 			'models' => array(
 				'TestPlugin.TestPluginComment' => array('save')
 			)

+ 11 - 11
lib/Cake/Test/TestCase/Utility/ClassRegistryTest.php

@@ -173,17 +173,17 @@ class ClassRegistryTest extends TestCase {
  * @return void
  */
 	public function testAddModel() {
-		$Tag = ClassRegistry::init('RegisterArticleTag');
-		$this->assertTrue(is_a($Tag, 'RegisterArticleTag'));
+		$Tag = ClassRegistry::init(__NAMESPACE__ . '\RegisterArticleTag');
+		$this->assertInstanceOf(__NAMESPACE__ . '\RegisterArticleTag', $Tag);
 
-		$TagCopy = ClassRegistry::isKeySet('RegisterArticleTag');
+		$TagCopy = ClassRegistry::isKeySet(__NAMESPACE__ . '\RegisterArticleTag');
 		$this->assertTrue($TagCopy);
 
 		$Tag->name = 'SomeNewName';
 
-		$TagCopy = ClassRegistry::getObject('RegisterArticleTag');
+		$TagCopy = ClassRegistry::getObject(__NAMESPACE__ . '\RegisterArticleTag');
 
-		$this->assertTrue(is_a($TagCopy, 'RegisterArticleTag'));
+		$this->assertInstanceOf(__NAMESPACE__ . '\RegisterArticleTag', $TagCopy);
 		$this->assertSame($Tag, $TagCopy);
 
 		$NewTag = ClassRegistry::init(array('class' => 'RegisterArticleTag', 'alias' => 'NewTag'));
@@ -311,16 +311,16 @@ class ClassRegistryTest extends TestCase {
  */
 	public function testPrefixedTestDatasource() {
 		ClassRegistry::config(array('testing' => true));
-		$Model = ClassRegistry::init('RegisterPrefixedDs');
+		$Model = ClassRegistry::init(__NAMESPACE__ . '\RegisterPrefixedDs');
 		$this->assertEquals('test', $Model->useDbConfig);
-		ClassRegistry::removeObject('RegisterPrefixedDs');
+		ClassRegistry::removeObject(__NAMESPACE__ . '\RegisterPrefixedDs');
 
 		$testConfig = ConnectionManager::getDataSource('test')->config;
 		ConnectionManager::create('test_doesnotexist', $testConfig);
 
-		$Model = ClassRegistry::init('RegisterArticle');
+		$Model = ClassRegistry::init(__NAMESPACE__ . '\RegisterArticle');
 		$this->assertEquals('test', $Model->useDbConfig);
-		$Model = ClassRegistry::init('RegisterPrefixedDs');
+		$Model = ClassRegistry::init(__NAMESPACE__ . '\RegisterPrefixedDs');
 		$this->assertEquals('test_doesnotexist', $Model->useDbConfig);
 	}
 
@@ -339,7 +339,7 @@ class ClassRegistryTest extends TestCase {
  * @return void
  */
 	public function testInitAbstractClass() {
-		ClassRegistry::init('ClassRegistryAbstractModel');
+		ClassRegistry::init(__NAMESPACE__ . '\ClassRegistryAbstractModel');
 	}
 
 /**
@@ -349,6 +349,6 @@ class ClassRegistryTest extends TestCase {
  * @return void
  */
 	public function testInitInterface() {
-		ClassRegistry::init('ClassRegistryInterfaceTest');
+		ClassRegistry::init(__NAMESPACE__ . '\ClassRegistryInterfaceTest');
 	}
 }

+ 1 - 1
lib/Cake/Test/TestCase/View/HelperTest.php

@@ -925,7 +925,7 @@ class HelperTest extends TestCase {
 	public function testThatHelperHelpersAreNotAttached() {
 		App::build(array(
 			'Plugin' => array(CAKE . 'Test' . DS . 'TestApp' . DS . 'Plugin' . DS),
-		));
+		), App::RESET);
 		Plugin::loadAll();
 
 		$Helper = new TestHelper($this->View);

+ 1 - 1
lib/Cake/View/HelperCollection.php

@@ -65,7 +65,7 @@ class HelperCollection extends ObjectCollection implements EventListener {
 
 		try {
 			$this->load($helper);
-		} catch (MissingHelperException $exception) {
+		} catch (Error\MissingHelperException $exception) {
 			if ($this->_View->plugin) {
 				$this->load($this->_View->plugin . '.' . $helper);
 				return true;