diff --git a/CHANGELOG.md b/CHANGELOG.md index d0ba2716f5..bbe5d931f5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ * [Phalcon] **Refactored**. Moved in-memory session adapter to the separated namespace. By @sergeyklay * [Phalcon] Fixed overwriting server parameters on requests. By @sergeyklay * [Yii2] Fixed unintentional DB connection drop during exception logging, #3696 by @ivokund +* [Yii2] Added procesing for native url formats of Yii2 #3725 by @githubjeka #### 2.2.6 (October 2016) diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index 67e154a810..3b1cbf341f 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -147,7 +147,7 @@ public function _getResponseContent() return (string)$this->getRunningClient()->getInternalResponse()->getContent(); } - protected function clientRequest($method, $uri, array $parameters = array(), array $files = array(), array $server = array(), $content = null, $changeHistory = true) + protected function clientRequest($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null, $changeHistory = true) { $this->debugSection("Request Headers", $this->headers); diff --git a/src/Codeception/Module/Yii2.php b/src/Codeception/Module/Yii2.php index ad4850545b..3a32a64595 100644 --- a/src/Codeception/Module/Yii2.php +++ b/src/Codeception/Module/Yii2.php @@ -103,6 +103,18 @@ * } * ``` * + * ## URL + * This module provide to use native URL formats of Yii2 for all codeception commands that use url for work. + * This commands allows input like: + * + * ```php + * amOnPage(['site/view','page'=>'about']); + * $I->amOnPage('index-test.php?site/index'); + * $I->amOnPage('http://localhost/index-test.php?site/index'); + * $I->sendAjaxPostRequest(['/user/update', 'id' => 1], ['UserForm[name]' => 'G.Hopper'); + * ``` + * * ## Status * * Maintainer: **samdark** @@ -445,28 +457,6 @@ protected function getModelRecord($model) return $record; } - /** - * Converting $page to valid Yii 2 URL - * - * Allows input like: - * - * ```php - * amOnPage(['site/view','page'=>'about']); - * $I->amOnPage('index-test.php?site/index'); - * $I->amOnPage('http://localhost/index-test.php?site/index'); - * ``` - * - * @param $page string|array parameter for \yii\web\UrlManager::createUrl() - */ - public function amOnPage($page) - { - if (is_array($page)) { - $page = Yii::$app->getUrlManager()->createUrl($page); - } - parent::amOnPage($page); - } - /** * Similar to amOnPage but accepts route as first argument and params as second * @@ -480,6 +470,26 @@ public function amOnRoute($route, array $params = []) array_unshift($params, $route); $this->amOnPage($params); } + + /** + * To support to use the behavior of urlManager component + * for the methods like this: amOnPage(), sendAjaxRequest() and etc. + * @param $method + * @param $uri + * @param array $parameters + * @param array $files + * @param array $server + * @param null $content + * @param bool $changeHistory + * @return mixed + */ + protected function clientRequest($method, $uri, array $parameters = [], array $files = [], array $server = [], $content = null, $changeHistory = true) + { + if (is_array($uri)) { + $uri = Yii::$app->getUrlManager()->createUrl($uri); + } + return parent::clientRequest($method, $uri, $parameters, $files, $server, $content, $changeHistory); + } /** * Gets a component from Yii container. Throws exception if component is not available