7

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?

0

2 Answers 2

1

Use --bootstrap option, ex.

--bootstrap=config/bootstrap.php 

For Symfony 4

Sign up to request clarification or add additional context in comments.

Comments

0

I used CORS_ALLOW_ORIGIN="*" php codecept run and it solved my problem.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.