For example, codeception unit test Undefinedindex: HTTP_HOST error test driver code: commonconfigmain. php cross-origin login code: test driver run to commonconfigmain. php times Undefinedindex: HTTP_HOST error. how can I solve this problem.
Example: codeception unit test Undefined index: HTTP_HOST error
Test driver code:
Commonconfigmain. php:
The Undefined index: HTTP_HOST error is reported when the test driver runs to common \ config \ main. php. how can this problem be solved.
Reply content:
Example: codeception unit test Undefined index: HTTP_HOST error
Test driver code:
Commonconfigmain. php:
The Undefined index: HTTP_HOST error is reported when the test driver runs to common \ config \ main. php. how can this problem be solved.
Define the following variables in the bootstrap file, such
$ _ SERVER ['http _ host'] = 'foo. com ';
Because of the codeception unit, PHP runs in cli mode, some variables starting with HTTP under $ _ SERVER are not defined, so you have to manually define them to simulate some web data, in this way, no error will be reported when running to that place.
I suggest you use the acceptance test, or you encapsulate your code into the function class, and then use the function test. it makes no sense to directly write the code to the test driver.