Codeception unit test Undefinedindex: HTTP_HOST

Source: Internet
Author: User
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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.