diff --git a/composer.json b/composer.json index 8f7b336..e35165c 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "jhodges/sitemap", - "description": "generate full sitemap report", + "description": "Generate full sitemap report using spatie/crawler", "type": "project", "require": { "php": "^7.1", @@ -26,6 +26,9 @@ "patches": { "spatie/crawler": { "add crawled again observer": "https://patch-diff.githubusercontent.com/raw/spatie/crawler/pull/280.patch" + }, + "guzzlehttp/guzzle": { + "Status code must be an integer value between 1xx and 5xx": "https://patch-diff.githubusercontent.com/raw/guzzle/guzzle/pull/2591.patch" } } } diff --git a/tests/CrawlerTest.php b/tests/CrawlerTest.php index 3b11706..d3b7d78 100644 --- a/tests/CrawlerTest.php +++ b/tests/CrawlerTest.php @@ -20,6 +20,7 @@ class CrawlerTest extends TestCase{ 'http://localhost:8080/interlinked2' => ['code' => 200], 'http://localhost:8080/interlinked3' => ['code' => 200], 'http://localhost:8080/internalServerError' => ['code' => 500], + 'http://localhost:8080/invalidStatusCode' => ['code' => '---'], 'http://localhost:8080/notFound' => ['code' => 404], 'http://localhost:8080/redirect1' => ['code' => 302], 'http://localhost:8080/redirect2' => ['code' => 302], @@ -165,6 +166,15 @@ class CrawlerTest extends TestCase{ ], print_r($sitemap,true)); } + public function testInvalidStatusCode(){ + $crawler=new Crawler(); + $crawler->crawl('http://localhost:8080/invalidStatusCode'); + $sitemap=$crawler->getResults(); + $this->assertTreeContains($sitemap,[ + 'http://localhost:8080/invalidStatusCode' => ['code' => '---'], + ], print_r($sitemap,true)); + } + public function assertTreeContains($haystack, $contains, $crumbs=''){ foreach($contains as $k=>$v){ $this->assertArrayHasKey($k, $haystack, $crumbs); diff --git a/tests/server/server.js b/tests/server/server.js index f90e79c..d8155d5 100644 --- a/tests/server/server.js +++ b/tests/server/server.js @@ -16,6 +16,7 @@ app.get('/', function (request, response) { '
  • redirectLoop
  • ', '
  • timeout
  • ', '
  • internalServerError
  • ', + '
  • invalidStatusCode
  • ', '
  • twoRedirectsToSameLocation
  • ', '
  • mailto
  • ', '
  • tel
  • ', @@ -78,6 +79,10 @@ app.get('/internalServerError', function (request, response) { response.status(500).end(); }); +app.get('/invalidStatusCode', function (request, response) { + response.status(999).end(); +}); + app.get('/interlinked1', function (request, response) { response.end('123'); });