V
V
Vladimir2017-06-06 13:19:10
PHP
Vladimir, 2017-06-06 13:19:10

codeception. phalcon. Undefined index: HTTP_HOST Bug?

Good afternoon.
The task is to cover the developed REST API with tests.
REST module settings:

url: http://127.0.0.1:8080/api/v1
depends: Phalcon
part: Json

Test code snippet:
$I->haveHttpHeader('Content-Type', 'application/x-www-form-urlencoded');
$I->sendPOST('/client/add', ['name' => 'Vladimir', 'sex' => 'male']);

As a result, the error: [PHPUnit\Framework\Exception] Undefined index: HTTP_HOST
Changed the Phalcon dependency to PhpBrowser - no error, the test was successful.
url: http://127.0.0.1:8080/api/v1
depends: PhpBrowser
part: Json

Is this a bug or did I do something wrong.
I use:
  1. REST
  2. phanbook

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shamin, 2017-06-15
@dyadyavasya

HTTP_HOST will not be defined since the tests are run from the command line.
You need to add an explicit definition to _bootstrap.php in the Codeception test directory:
$_SERVER['HTTP_HOST'] = 'MyHostName';

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question