Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weird bug happening the first time a test is run using PhpStorm #212

Closed
caendesilva opened this issue Jul 10, 2022 · 0 comments · Fixed by #213
Closed

Weird bug happening the first time a test is run using PhpStorm #212

caendesilva opened this issue Jul 10, 2022 · 0 comments · Fixed by #213

Comments

@caendesilva
Copy link
Member

This has been bugging me a lot. When running a test file directly in PhpStorm, like this image, you sometimes get weird errors where Hyde tries to find files in that directory, causing unexpected results. However, if you re-run the test it works as normal, making it hard to debug.

image

Now, I added some breakpoints to kill the execution at various points and I think this is caused by the Hyde base path not being properly initialized. Why this only affects the first run I don't know. But I think it's because we set the base path using getcwd():

\Hyde\Framework\Hyde::setBasePath(getcwd());

This allows the HydeCLI executable to be stored in a different directory, however if the runner is initiated from another location that could mess things up. I suggest we change the implementation to use dirname(__DIR__)), same as we use to register the Laravel Application:
dirname(__DIR__)

It's very easy to change the base path at runtime, so if one is creating an integration that needs the cwd or another arbitrary path, that's easy enough to change with Hyde::setBasePath($dir).

I'm doing some preliminary testing with this fix applied, and so far it seems to work. But since reproducing it is so unpredictable it's hard to fully confirm.

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

Successfully merging a pull request may close this issue.

1 participant