I'm using Codeception v2.4.1 with PHPUnit 7.1.3 in a new Symfony 4 project.
I created a functional test, and attempt to run it, and receive an error: ./vendor/bin/codecept run functional
There was 1 error:
---------
1) CustomerControllerCest: Customers on index
Test tests/functional/Controller/Internal/CustomerControllerCest.php:customersOnIndex
[Symfony\Component\DependencyInjection\Exception\EnvNotFoundException]
Environment variable not found: "CORS_ALLOW_ORIGIN".
I have a phpunit.xml file that has this environment configured:
<php>
<ini name="error_reporting" value="-1" />
<env name="KERNEL_CLASS" value="App\Kernel" />
<env name="APP_ENV" value="test" />
<env name="APP_DEBUG" value="1" />
<env name="APP_SECRET" value="191a5940854807ee081eaa57aff30562" />
<env name="SHELL_VERBOSITY" value="-1" />
<!-- define your env variables for the test env here -->
<env name="CORS_ALLOW_ORIGIN" value="^https?://localhost:?[0-9]*$" />
</php>
I also tried using .env.test, and included this same variable:
CORS_ALLOW_ORIGIN=^https?://localhost:?[0-9]*$
I checked in functional.suite.yml and my environment is set to test:
actor: FunctionalTester
modules:
enabled:
- Symfony:
app_path: 'src'
environment: 'test'
em_service: ‘doctrine.orm.entity_manager’
# - Doctrine2:
# depends: Symfony
# add a framework module here
- \Helper\Functional
Not sure where the issue is. Is there an additional config where I tell codeception where to look for these environment variables?
Use --bootstrap
option, ex.
--bootstrap=config/bootstrap.php
For Symfony 4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With