Commit 9140a012 authored by Ivan Chepurnyi's avatar Ivan Chepurnyi

Merge pull request #10 from colinmollenhour/modulefixtures3

Added @colinmollenhour pull request for shared fixtures.
parents 4417a0e5 819d5251
...@@ -743,7 +743,9 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase ...@@ -743,7 +743,9 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
} }
/** /**
* Loads YAML file from directory inside of the unit test class * Loads YAML file from directory inside of the unit test class or
* the directory inside the module directory if name is prefixed with ~/
* or from another module if name is prefixed with ~My_Module/
* *
* @param string $className class name for looking fixture files * @param string $className class name for looking fixture files
* @param string $type type of YAML data (fixtures,expectations,dataproviders) * @param string $type type of YAML data (fixtures,expectations,dataproviders)
...@@ -760,9 +762,22 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase ...@@ -760,9 +762,22 @@ abstract class EcomDev_PHPUnit_Test_Case extends PHPUnit_Framework_TestCase
EcomDev_Utils_Reflection::getRelflection($className)->getFileName() EcomDev_Utils_Reflection::getRelflection($className)->getFileName()
); );
$filePath = $classFileObject->getPath() . DS // When prefixed with ~/ or ~My_Module/, load from the module's Test/<type> directory
. $classFileObject->getBasename('.php') . DS if (preg_match('#^~(?<module>[^/]*)/(?<path>.*)$#', $name, $matches)) {
. $type . DS . $name; $name = $matches['path'];
if( ! empty($matches['module'])) {
$moduleName = $matches['module'];
} else {
$moduleName = substr($className, 0, strpos($className, '_Test_'));;
}
$filePath = Mage::getModuleDir('', $moduleName) . DS . 'Test' . DS;
}
// Otherwise load from the Class/<type> directory
else {
$filePath = $classFileObject->getPath() . DS
. $classFileObject->getBasename('.php') . DS;
}
$filePath .= $type . DS . $name;
if (file_exists($filePath)) { if (file_exists($filePath)) {
return $filePath; return $filePath;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment