Permalink
Browse files

Allow sub-directories for Fixture folder

Allow sub-directories for Test/Fixture folder (for app. and plugin.)
The directory separator is '/'.
A file ``MyClassFixture.php` in the folder `Fixture/MyFolder` will be included like this :
`'app.MyFolder/my_class'`
  • Loading branch information...
1 parent aa0f1c1 commit 316fd50443f9713094c978caef52cbf5ea0ca619 @Tounu Tounu committed Mar 11, 2014
Showing with 18 additions and 7 deletions.
  1. +18 −7 lib/Cake/TestSuite/Fixture/CakeFixtureManager.php
@@ -114,17 +114,28 @@ protected function _loadFixtures($fixtures) {
$fixture = substr($fixture, strlen('core.'));
$fixturePaths[] = CAKE . 'Test' . DS . 'Fixture';
} elseif (strpos($fixture, 'app.') === 0) {
- $fixture = substr($fixture, strlen('app.'));
+ $fixturePrefixLess = substr($fixture, strlen('app.'));
+ $pathTokenArray = explode('/', $fixturePrefixLess);
+ $fixture = array_pop($pathTokenArray);
+ $additionalPath = '';
+ foreach ($pathTokenArray as $pathToken) {
+ $additionalPath .= DS . $pathToken;
+ }
$fixturePaths = array(
- TESTS . 'Fixture'
+ TESTS . 'Fixture' . $additionalPath
);
} elseif (strpos($fixture, 'plugin.') === 0) {
- $parts = explode('.', $fixture, 3);
- $pluginName = $parts[1];
- $fixture = $parts[2];
+ $explodedFixture = explode('.', $fixturePrefixLess,3);
+ $pluginName = $explodedFixture[1];
+ $pathTokenArray = explode('/', $explodedFixture[2]);
+ $fixture = array_pop($pathTokenArray);
+ $additionalPath = '';
+ foreach ($pathTokenArray as $pathToken) {
+ $additionalPath .= DS . $pathToken;
+ }
$fixturePaths = array(
- CakePlugin::path(Inflector::camelize($pluginName)) . 'Test' . DS . 'Fixture',
- TESTS . 'Fixture'
+ CakePlugin::path(Inflector::camelize($pluginName)) . 'Test' . DS . 'Fixture' . $additionalPath,
+ TESTS . 'Fixture' . $additionalPath
);
} else {
$fixturePaths = array(

0 comments on commit 316fd50

Please sign in to comment.