Skip to content

Commit

Permalink
Fix fixture manager vendor/plugin edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
jadb committed Jan 6, 2015
1 parent ade0190 commit 5c90686
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
1 change: 1 addition & 0 deletions composer.json
Expand Up @@ -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",
Expand Down
10 changes: 4 additions & 6 deletions src/TestSuite/Fixture/FixtureManager.php
Expand Up @@ -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;
}
Expand Down
19 changes: 19 additions & 0 deletions tests/TestCase/TestSuite/FixtureManagerTest.php
Expand Up @@ -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']
);
}
}

0 comments on commit 5c90686

Please sign in to comment.