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

Global YAML Loader does not evaluate correctly #254

Description

@azngeek

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions