orchestral / testbench

Laravel Testing Helper for Packages Development
https://packages.tools/testbench
MIT License
2.1k stars 136 forks source link

Error "Failed to open stream: No such file or directory" due to missing .env file when running tests after updating Laravel and Testbench versions #364

Closed lotyp closed 1 year ago

lotyp commented 1 year ago

Description:

After updating to the latest version of Laravel and Testbench I have an error when performing tests:

 WARNINGS  WayOfDev\RQL\Tests\Bridge\Cycle\Processors\CycleProcessorTest > it tests expr between
  file_get_contents(/Projects/wayofdev/laravel-request-query-builder/vendor/orchestra/testbench-core/laravel/.env): Failed to open stream: No such file or directory

Steps To Reproduce:

  1. Install testbench into the composer package that depends on Laravel 10.13
  2. Run any test

By going to testbench-core and manually copying .env.example into .env problem disappears

crynobone commented 1 year ago

Please provide complete reproducing steps.

lotyp commented 1 year ago

I can't reproduce this inside GitHub Actions. I will close this for now.

moranda commented 1 year ago

I did experience the same problem using Pest. As I had to do multiple operations to reach this state, I don't have a reasonable reproduction steps.

crynobone commented 1 year ago

@moranda you mentioned you need to have done multiple steps to reach that step, it's different from the Step to reproduce listed in the original issue above.

lotyp commented 1 year ago

It happens in all my packages that are created from template.

image

Reproduction steps:

  1. git clone https://github.com/wayofdev/laravel-cycle-orm-factories
  2. cd laravel-cycle-orm-factories
  3. composer install
  4. make test or vendor/bin/pest

Result:

image
moranda commented 1 year ago

@moranda you mentioned you need to have done multiple steps to reach that step, it's different from the Step to reproduce listed in the original issue above.

I have been progressively updating an old package. I am not able to tell you exactly the multiple steps I made, sorry. If I can find time, I will try to rebuild my setup with more obvious steps.

moranda commented 1 year ago

for now, I just modified my test script in composer.json like this:

cp .env.test vendor/orchestra/testbench-core/laravel/.env && vendor/bin/pest

and it makes it possible to execute tests.

looksystems commented 1 year ago

to add to @moranda comments, I have found that previously working test suite, now reports the same error message for the first two tests that are run. so, if i run a single test file, i get an error... where as the same test file, in the middle of a suite, reports no errors.

all i have done differently is re-run composer install for my package.

i do not use pest.

unfortunately the project i am working on is private so i cannot provide exact steps to reproduce the bug - but - hopefully this feedback is of some help.

update: i only see the warnings when using the following extension

<extensions>
    <bootstrap class="RobinIngelbrecht\PHPUnitPrettyPrint\PhpUnitExtension">
    </bootstrap>
</extensions>

By going to testbench-core and manually copying .env.example into .env problem disappears

And this fix works for me.