From 5c9068653902db776e2a3f56f0b895d6e69b39b4 Mon Sep 17 00:00:00 2001 From: Jad Bitar Date: Tue, 6 Jan 2015 09:47:20 -0500 Subject: [PATCH] Fix fixture manager vendor/plugin edge case --- composer.json | 1 + src/TestSuite/Fixture/FixtureManager.php | 10 ++++------ .../TestCase/TestSuite/FixtureManagerTest.php | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+), 6 deletions(-) diff --git a/composer.json b/composer.json index f3701da81d9..9ae97a5d3bd 100644 --- a/composer.json +++ b/composer.json @@ -42,6 +42,7 @@ "autoload-dev": { "psr-4": { "Cake\\Test\\": "tests", + "Company\\TestPluginThree\\Test\\": "tests/test_app/Plugin/Company/TestPluginThree/tests", "TestApp\\": "tests/test_app/TestApp", "TestPlugin\\": "tests/test_app/Plugin/TestPlugin/src", "TestPlugin\\Test\\": "tests/test_app/Plugin/TestPlugin/tests", diff --git a/src/TestSuite/Fixture/FixtureManager.php b/src/TestSuite/Fixture/FixtureManager.php index aaf347b8b0c..48f78cefdce 100644 --- a/src/TestSuite/Fixture/FixtureManager.php +++ b/src/TestSuite/Fixture/FixtureManager.php @@ -150,12 +150,10 @@ protected function _loadFixtures($test) } elseif ($type === 'app') { $baseNamespace = Configure::read('App.namespace'); } elseif ($type === 'plugin') { - if (strlen($additionalPath)) { - list($plugin, $additionalPath) = explode('.', $additionalPath); - } else { - list($plugin, $name) = explode('.', $name); - } - $baseNamespace = Inflector::camelize(str_replace('\\', '\ ', $plugin)); + list($plugin, $name) = explode('.', $pathName); + $path = implode('\\', explode('/', $plugin)); + $baseNamespace = Inflector::camelize(str_replace('\\', '\ ', $path)); + $additionalPath = null; } else { $name = $fixture; } diff --git a/tests/TestCase/TestSuite/FixtureManagerTest.php b/tests/TestCase/TestSuite/FixtureManagerTest.php index 4b8c9b7a3bb..4e2d752824b 100644 --- a/tests/TestCase/TestSuite/FixtureManagerTest.php +++ b/tests/TestCase/TestSuite/FixtureManagerTest.php @@ -72,4 +72,23 @@ public function testFixturizePlugin() $fixtures['plugin.test_plugin.articles'] ); } + + /** + * Test loading app fixtures. + * + * @return void + */ + public function testFixturizeCustom() + { + $test = $this->getMock('Cake\TestSuite\TestCase'); + $test->fixtures = ['plugin.Company/TestPluginThree.articles']; + $this->manager->fixturize($test); + $fixtures = $this->manager->loaded(); + $this->assertCount(1, $fixtures); + $this->assertArrayHasKey('plugin.Company/TestPluginThree.articles', $fixtures); + $this->assertInstanceOf( + 'Company\TestPluginThree\Test\Fixture\ArticlesFixture', + $fixtures['plugin.Company/TestPluginThree.articles'] + ); + } }