EcomDev_PHPUnit
EcomDev_PHPUnit copied to clipboard
Global YAML Loader does not evaluate correctly
Hello,
it seems like that the following check is wrong
# EcomDev_PHPUnit_Model_Yaml_Loader_Global
/**
* Returns processed file path
*
* @param string $fileName
* @param string $relatedClassName
* @param string $type
* @return string|bool
*/
protected function _getFilePath($fileName, $relatedClassName, $type)
{
$reflection = EcomDev_Utils_Reflection::getReflection($relatedClassName);
$fileObject = new SplFileInfo($reflection->getFileName());
$basePath = $fileObject->getPath();
// While base path is within a base directory of Magento installment
while (strpos($basePath, Mage::getBaseDir()) && !is_dir($basePath . DS . $type)) {
$basePath = dirname($basePath);
}
if (basename($basePath)) {
return $basePath . DS . $type . DS .$fileName;
}
return false;
}
Lets assume the base path is '/var/www/html/magento/tests' and the base dir is '/var/www/html/magento', strpos will evaluate to 0, which then will be interpreted as false.
while (strpos($basePath, Mage::getBaseDir()) && !is_dir($basePath . DS . $type)) {
$basePath = dirname($basePath);
}
Correct
// While base path is within a base directory of Magento installment
while (false !== strpos($basePath, Mage::getBaseDir()) && !is_dir($basePath . DS . $type)) {
$basePath = dirname($basePath);
}
Are my assumptions correct or is there anything i missed? This are my points
- Reference http://php.net/manual/de/function.strpos.php
- the fixture folder is not in the same folder as the test file
- global loader acts as fallback which will walk up the directory tree