Home > Backend Development > PHP Tutorial > codeception unit test Undefined index: HTTP_HOST

codeception unit test Undefined index: HTTP_HOST

WBOY
Release: 2016-08-04 09:19:51
Original
2020 people have browsed it

Such as the title codeception unit test Undefined index: HTTP_HOST error reporting

codeception unit test Undefined index: HTTP_HOST

Test driven code:

codeception unit test Undefined index: HTTP_HOST

commonconfigmain.php cross-domain login code:

codeception unit test Undefined index: HTTP_HOST

When the test driver runs to commonconfigmain.php, an Undefined index: HTTP_HOST error is reported. Please tell me how to solve it.

Reply content:

Such as the title codeception unit test Undefined index: HTTP_HOST error reporting

codeception unit test Undefined index: HTTP_HOST

Test driven code:

codeception unit test Undefined index: HTTP_HOST

commonconfigmain.php cross-domain login code:

codeception unit test Undefined index: HTTP_HOST

When the test driver runs to commonconfigmain.php, an Undefined index: HTTP_HOST error is reported. Please tell me how to solve it.

Define the following variables in the bootstrap file, such as
$_SERVER['HTTP_HOST'] = 'foo.com';
Because of the codeception unit, PHP runs in cli mode, and some variables starting with HTTP under $_SERVER are not defined. So you have to manually define and simulate some data on the web, so that no error will be reported when running there.

I suggest you use acceptance tests, or you encapsulate your code into functional classes and then use functional tests. It makes no sense to write the code directly into the test driver

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template