Skip to content

DependencyChecker does not works with FileMock #120

@f3l1x

Description

@f3l1x

I have had this code in my tests. It is failing with 2.4.0.

$loader = new ContainerLoader(TEMP_DIR);
$className = $loader->load(function (Compiler $compiler) {
    $compiler->loadConfig(FileMock::create('', 'neon'));
}, 'container');

Nette\InvalidStateException: Unexpected dependency boolean

I think its cause:

// Compiler.php

/**
 * Adds new configuration from file.
 * @return self
 */
public function loadConfig($file)
{
    $loader = new Config\Loader;
    $this->addConfig($loader->load($file));
    $this->dependencies->add($loader->getDependencies());
    return $this;
}
// Loader.php

/**
 * Reads configuration from file.
 * @param  string  file name
 * @param  string  optional section to load
 * @return array
 */
public function load($file, $section = NULL)
{
    if (!is_file($file) || !is_readable($file)) {
        throw new Nette\FileNotFoundException("File '$file' is missing or is not readable.");
    }
    $this->dependencies[] = realpath($file);
       ....
}

realpath(FileMock) == bool(FALSE)


It is maybe issue in nette/tester, but I'm not sure if it is issue at all. What do you think?

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