Answer the question
In order to leave comments, you need to log in
Why doesn't this construction work in Codeception?
my application is launched through the index.php file, which looks like this
$container = new Container();
$app = new Application($container);
$app->run
The container contains configs, including a database connection.
For testing, I have my own database and the test environment starts when I pass the test string to the container
$container = new Container('test');
I was racking my brains on how to connect a test environment in Codeception and decided to use such a life hack, in index.php I wrote
$env = $_GET['env'] ?? '';
Accordingly, when I launch the site like this mysite.ru/?env=test
test settings are launched.
Next, I write in PhpBrowser
codeception settings:
url: mysite.ru/?env=test
But it still runs the standard settings, as if it just ignores the line ?env=test
how can this be solved, how do you solve the problem of replacing the config with a test one?
I don't use frameworks
Answer the question
In order to leave comments, you need to log in
?env=test
I can assume that further in the tests themselves you do not substitute this GET parameter,
for example, with such calls, your url is lost:
<?php
$I->amOnPage('/quickstart'); // moves to http://codeception.com/quickstart
?>
query
url: mysite.ru
you need to add query: ['env', 'test']
modules:
enabled:
- PhpBrowser:
url: 'http://localhost'
query: ['env', 'test']
query:
env: test
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question