Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
* @Given /^I send a request to google page speed for "([^"]*)" with "([^"]*)" strategy$/
public function iSendARequestToGooglePageSpeedForWithStrategy($path, $strategy) {
if ($path === 'the homepage') {
$url = $this->getMinkParameter('base_url');
else {
$url = $this->getMinkParameter('base_url') . $path;
//Try google page speed up to 5 times
for ($i=0; $i<5; $i++) {
$this->restClient = new Client();
$this->restClient->response = $this->restClient->get('' . $url . '&filter_third_party_resources=false&strategy=' . $strategy . '&fields=ruleGroups');
//Grab the response code from google
$response_code = !empty($this->restClient->response->code) ? $this->restClient->response->code : FALSE;
//Stop sending requests to google page speed if we get a valid response
if (!empty($response_code) && $response_code == 200) {
// If google does not respond, throw a PendingException. This allows us to
// continue executing the remaining steps without failing the whole build
if (empty($response_code) || $response_code != 200) {
throw new PendingException('Google did respond as with a ' . $response_code . 'code');

This comment has been minimized.

Copy link

@victorpavlov victorpavlov commented May 13, 2015

Thank you Matt! There is only one small thing. We should use:


instead of:


when we are defining $response_code variable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment