Skip to content

Commit 5c90686

Browse files
committed
Fix fixture manager vendor/plugin edge case
1 parent ade0190 commit 5c90686

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"autoload-dev": {
4343
"psr-4": {
4444
"Cake\\Test\\": "tests",
45+
"Company\\TestPluginThree\\Test\\": "tests/test_app/Plugin/Company/TestPluginThree/tests",
4546
"TestApp\\": "tests/test_app/TestApp",
4647
"TestPlugin\\": "tests/test_app/Plugin/TestPlugin/src",
4748
"TestPlugin\\Test\\": "tests/test_app/Plugin/TestPlugin/tests",

src/TestSuite/Fixture/FixtureManager.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -150,12 +150,10 @@ protected function _loadFixtures($test)
150150
} elseif ($type === 'app') {
151151
$baseNamespace = Configure::read('App.namespace');
152152
} elseif ($type === 'plugin') {
153-
if (strlen($additionalPath)) {
154-
list($plugin, $additionalPath) = explode('.', $additionalPath);
155-
} else {
156-
list($plugin, $name) = explode('.', $name);
157-
}
158-
$baseNamespace = Inflector::camelize(str_replace('\\', '\ ', $plugin));
153+
list($plugin, $name) = explode('.', $pathName);
154+
$path = implode('\\', explode('/', $plugin));
155+
$baseNamespace = Inflector::camelize(str_replace('\\', '\ ', $path));
156+
$additionalPath = null;
159157
} else {
160158
$name = $fixture;
161159
}

tests/TestCase/TestSuite/FixtureManagerTest.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,23 @@ public function testFixturizePlugin()
7272
$fixtures['plugin.test_plugin.articles']
7373
);
7474
}
75+
76+
/**
77+
* Test loading app fixtures.
78+
*
79+
* @return void
80+
*/
81+
public function testFixturizeCustom()
82+
{
83+
$test = $this->getMock('Cake\TestSuite\TestCase');
84+
$test->fixtures = ['plugin.Company/TestPluginThree.articles'];
85+
$this->manager->fixturize($test);
86+
$fixtures = $this->manager->loaded();
87+
$this->assertCount(1, $fixtures);
88+
$this->assertArrayHasKey('plugin.Company/TestPluginThree.articles', $fixtures);
89+
$this->assertInstanceOf(
90+
'Company\TestPluginThree\Test\Fixture\ArticlesFixture',
91+
$fixtures['plugin.Company/TestPluginThree.articles']
92+
);
93+
}
7594
}

0 commit comments

Comments
 (0)