grav icon indicating copy to clipboard operation
grav copied to clipboard

How to use Utils::fullPath() in Unit tests (Codeception)

Open pamtbaau opened this issue 4 years ago • 0 comments

Because USER_PATH has been deprecated, I'm accessing my user/data/comments/comments.yaml file using:

$fullPath = Utils::fullPath($filename); // with $filename like: 'user-data://comments/en/comments.yaml'

When fetching/saving the comments while running the browser, all goes well. However, during Unit tests Utils::fullPath($filename) always returns an empty string.

What do I need to set in tests/unit/_bootstap.php of Codeception to make it work?

I've tried using $grav['locator']->addPath('user-data', '', '/path/to/library/tests/_fake/data', true) and other variants but that doesn't seem to help.

In the root of my library, I'm running my unit tests as follows:

$ vendor/bin/codecept --debug run unit

[Edit] When running the following command:

$ cd /path/to/site && /path/to/library/vendor/bin/codecept -c /path/to/library/codeception.yml run unit

Utils::fullPath($filename) does return the correct path. user-data:// is replaced with /path/to/site/user/data/. I do not understand why though...

pamtbaau avatar Nov 20 '21 12:11 pamtbaau