Skip to content
This repository has been archived by the owner on May 27, 2023. It is now read-only.

Global YAML Loader does not evaluate correctly #254

Open
azngeek opened this issue May 6, 2015 · 0 comments
Open

Global YAML Loader does not evaluate correctly #254

azngeek opened this issue May 6, 2015 · 0 comments

Comments

@azngeek
Copy link

azngeek commented May 6, 2015

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant