I'm trying to write some acceptance tests for yii2 application.
I my SiteController I have some action, which include the following piece of code:
if (!Yii::$app->request->isPost) {
throw new NotFoundHttpException('Unexpected GET method');
}
When I'm trying to test this action - it's always FAILED, because my POST requests don't passed this check Yii::$app->request->isPost . They always have $_SERVER['REQUEST_METHOD'] = 'GET' instead of POST.
I tried this variants:
$I->sendPOST($url, $options)
$I->sendAjaxPostRequest($url, $options)
Also I tried to make custom actions in Helper like this
public function makePOST($url, $params = []) {
$this->getModule('PhpBrowser')->_loadPage('POST', $url, $params);
}
And then call it from my test. In all cases I'm getting GET request instead of POST...
Please help me to understand why it happens.