orchestral / testbench

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

phpunit.xml Env Variables Not Loaded in `testbench package:test` Command #380

Closed SupianIDz closed 1 year ago

SupianIDz commented 1 year ago

Description:

when running ./vendor/bin/phpunit directly all tests work correctly, but when testing with the command ./vendor/bin/testbench package:test it shows No application encryption key has been specified.

This occurs when the encrypt function is used

Screenshot 2023-09-22 at 04 04 13

I tried dd($_ENV) in testing, it seems the ./vendor/bin/testbench package:test command doesn't load the env defined in phpunit.xml

  1. ./vendor/bin/phpunit

    Screenshot 2023-09-22 at 04 05 43
  2. ./vendor/bin/testbench package:test

    Screenshot 2023-09-22 at 04 05 56

Steps To Reproduce:

  1. git clone https://github.com/SupianIDz/testbench-test
  2. composer install
  3. ./vendor/bin/phpunit
  4. ./vendor/bin/testbench package:test
crynobone commented 1 year ago

https://github.com/orchestral/testbench-core/commit/5cc96a43478e0178b4adc4ed90314dd2c54eb9a0

Unable to reproduce, our GitHub Action also being tested using package:test and package:test --parallel without issue.

SupianIDz commented 1 year ago

Hi @crynobone

could you take a look reproduction of the repository? I tried in 3 different environments + github action but got the same error.

github action workflow : https://github.com/SupianIDz/testbench-test/blob/main/.github/workflows/testbench.yml github action result : https://github.com/SupianIDz/testbench-test/actions/runs/6271550982/job/17031352888

Screenshot 2023-09-22 at 15 47 40
  1. result from linux server Screenshot 2023-09-22 at 15 31 50

  1. result from ubuntu desktop Screenshot from 2023-09-22 15-28-32
crynobone commented 1 year ago

could you take a look reproduction of the repository? I tried in 3 different environments + github action but got the same error.

You can try submit a failing test to https://github.com/orchestral/testbench-core

SupianIDz commented 1 year ago

I think this is enough: https://github.com/orchestral/testbench-core/commit/b9fc730788b42b37812454e915fd515ca9f7b43f

but I am very confused about this problem, it can be seen from the reproduction of the repo, everything is very minimal but the error still occurs.

https://github.com/SupianIDz/testbench-test/blob/main/tests/FooBarTest.php#L14