orchestral/testbench

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

lotyp opened this issue · 8 comments

lotyp commented
  • Testbench Version: 8.5.5
  • Laravel Version: 10.13
  • PHP Version: 8.2
  • Database Driver & Version: (not used)

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

Please provide complete reproducing steps.

lotyp commented

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

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.

@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

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 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.

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.

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.