<?php /** * @file * Crawl each of the URLs on the front page, checking that each is returning a 200 (OK). */ $I = new WebGuy($scenario); $I->wantTo('crawl the front page for links and check that each link is returning a 200 (OK) status'); // Navigate to the front page. $I->amOnPage('/'); // Check the repsonse code for the front page is 200 (OK). $I->seeResponseCodeIs(200); // Grab all a[href] values. $elements = $I->grabMultiple('a', 'href'); // Loop through the links array and check the status code of each one. foreach ($elements as $element) { // Split the URL up into different parts. $el = parse_url($element); // Make sure the host and path is set. if (isset($el['host']) && isset($el['path'])) { // Check each path returns a 200 (OK) status. if ($el['host'] == $GLOBALS['host']) { // Navigate to the $I->amOnPage($el['path']); $I->seeResponseCodeIs(200); } } }
/** * Test response after failing authentication is 401. * * @param WebGuy $I * The Guy object being used to test. * * @env misconfigured */ public function testFailedAuthenticatedResponse(WebGuy $I) { $I->amOnPage(self::HTTP_AUTH_PROTECTED_PATH); $I->seeResponseCodeIs(401); }