You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Let's suppose i have two root folders for my tests: project/tests/unit and projects/tests/perf.
Test case:
I've got a test in .../unit/PRJ/src/SomeTest.php (Psr4) with fixtures .../unit/global.yml
I've got a test in .../perf/SomeTest.php with fixtures .../perf/global.yml
Both tests use @fixtures mysql write global.yml
In this case the ../unit/SomeTest.php will use fixtures from ../perf/global.yml because of implementation in src/DbFixturesTrait.php (line 288, method resolveFilePath), which is not desirable. This method favors the simpler path, not the more related one (I would expect relative paths to be checked first).
The text was updated successfully, but these errors were encountered:
@kambo-1st I would suggest something in the realms of:
...
private functionresolveFilePath(string $connectionName, string $filename): string {
$this->location ??= \dirname((new \ReflectionClass($this))->getFileName()); //we would use this anyway, so better to preload hereif ($includePaths = getenv('DB_FIXTURES_INCLUDE_PATHS_' .$connectionName)) {
$includePaths = explode(':', $includePaths);
foreach ($includePathsas$includePath) {
if (
str_contains($this->location, $includePath) && //maybe there's some better way to check we're in the same directory root? but you get the ideafile_exists($includePath.$filename)
) {
return$includePath.$filename;
}
}
}
if (file_exists($filename)) {
return$filename;
}
if (file_exists($filepath = $this->location . '/' . $filename)) {
return$filepath;
}
thrownew \InvalidArgumentException('Fixtures "' . $filename . '" not found');
}
...
Let's suppose i have two root folders for my tests:
project/tests/unit
andprojects/tests/perf
.Test case:
.../unit/PRJ/src/SomeTest.php
(Psr4) with fixtures.../unit/global.yml
.../perf/SomeTest.php
with fixtures.../perf/global.yml
@fixtures mysql write global.yml
In this case the
../unit/SomeTest.php
will use fixtures from../perf/global.yml
because of implementation insrc/DbFixturesTrait.php
(line 288, methodresolveFilePath
), which is not desirable. This method favors the simpler path, not the more related one (I would expect relative paths to be checked first).The text was updated successfully, but these errors were encountered: