Skip to content

Update InnerBrowser.php #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 21 additions & 25 deletions src/Codeception/Lib/InnerBrowser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1254,10 +1254,8 @@ public function attachFile($field, $filename)
}

/**
* If your page triggers an ajax request, you can perform it manually.
* This action sends a GET ajax request with specified params.
*
* See ->sendAjaxPostRequest for examples.
* Sends an ajax GET request with the passed parameters.
* See `sendAjaxPostRequest()`
*
* @param $uri
* @param $params
Expand All @@ -1268,42 +1266,40 @@ public function sendAjaxGetRequest($uri, $params = [])
}

/**
* If your page triggers an ajax request, you can perform it manually.
* This action sends a POST ajax request with specified params.
* Additional params can be passed as array.
*
* Sends an ajax POST request with the passed parameters.
* The appropriate HTTP header is added automatically:
* `X-Requested-With: XMLHttpRequest`
* Example:
*
* Imagine that by clicking checkbox you trigger ajax request which updates user settings.
* We emulate that click by running this ajax request manually.
*
* ``` php
* <?php
* $I->sendAjaxPostRequest('/updateSettings', array('notifications' => true)); // POST
* $I->sendAjaxGetRequest('/updateSettings', array('notifications' => true)); // GET
*
* $I->sendAjaxPostRequest('/add-task', ['task' => 'lorem ipsum']);
* ```
* Some frameworks (e.g. Symfony) create field names in the form of an "array":
* `<input type="text" name="form[task]">`
* In this case you need to pass the fields like this:
* ``` php
* <?php
* $I->sendAjaxPostRequest('/add-task', ['form' => [
* 'task' => 'lorem ipsum',
* 'category' => 'miscellaneous',
* ]]);
* ```
*
* @param $uri
* @param $params
* @param string $uri
* @param array $params
*/
public function sendAjaxPostRequest($uri, $params = [])
{
$this->sendAjaxRequest('POST', $uri, $params);
}

/**
* If your page triggers an ajax request, you can perform it manually.
* This action sends an ajax request with specified method and params.
*
* Sends an ajax request, using the passed HTTP method.
* See `sendAjaxPostRequest()`
* Example:
*
* You need to perform an ajax request specifying the HTTP method.
*
* ``` php
* <?php
* $I->sendAjaxRequest('PUT', '/posts/7', array('title' => 'new title'));
*
* $I->sendAjaxRequest('PUT', '/posts/7', ['title' => 'new title']);
* ```
*
* @param $method
Expand Down