Skip to content

Commit

Permalink
Tests updated to match PHP 7 improved sorting algorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPetterMG committed Feb 14, 2018
1 parent 3c04cf8 commit 64c6827
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
10 changes: 8 additions & 2 deletions tests/AllowTest.php
Expand Up @@ -88,6 +88,9 @@ public function testDisAllow($robotsTxtContent, $rendered)
$this->assertFalse($parser->userAgent('crawlerZ')->isAllowed("/public"));

if ($rendered !== false) {
if (version_compare(phpversion(), '7.0.0', '<')) {
$this->markTestIncomplete('Sort algorithm changed as of PHP 7');
}
$this->assertEquals($rendered, $parser->render()->normal("\n"));
$this->testDisAllow($rendered, false);
}
Expand All @@ -102,6 +105,9 @@ public function testDisAllowIsListed($robotsTxtContent, $rendered)
{
$parser = new RobotsTxtParser\TxtClient('http://example.com', 200, $robotsTxtContent);
$this->assertInstanceOf('vipnytt\RobotsTxtParser\TxtClient', $parser);
if (version_compare(phpversion(), '7.0.0', '<')) {
$this->markTestIncomplete('Sort algorithm changed as of PHP 7');
}
$this->assertEquals($rendered, $parser->render()->normal("\n"));

// Expected result: String length of matching rule
Expand Down Expand Up @@ -157,8 +163,8 @@ public function generateDataForTest()
User-agent: *
User-agent: anyone
Disallow: /temp
Disallow: /admin
Disallow: /forum
Disallow: /admin
Disallow: /Admin
Disallow: /admin/cp/test/
Expand All @@ -169,8 +175,8 @@ public function generateDataForTest()
User-agent: boty
Disallow: /
Allow: /article
Allow: /forum/$
Allow: /article
User-agent: crawlerz
Disallow: /
Expand Down
5 changes: 4 additions & 1 deletion tests/EndAnchorTest.php
Expand Up @@ -42,6 +42,9 @@ public function testEndAnchor($robotsTxtContent, $rendered)
$this->assertFalse($parser->userAgent('DenyMe')->isAllowed('http://example.com/deny_all/'));

if ($rendered !== false) {
if (version_compare(phpversion(), '7.0.0', '<')) {
$this->markTestIncomplete('Sort algorithm changed as of PHP 7');
}
$this->assertEquals($rendered, $parser->render()->normal("\n"));
$this->testEndAnchor($rendered, false);
}
Expand Down Expand Up @@ -74,8 +77,8 @@ public function generateDataForTest()
Allow: /$
User-agent: denyme
Disallow: *deny_all/$
Disallow: /deny_all/$
Disallow: *deny_all/$
RENDERED
]
];
Expand Down
7 changes: 5 additions & 2 deletions tests/EscapingTest.php
Expand Up @@ -39,6 +39,9 @@ public function testEscaping($robotsTxtContent, $rendered)
//$this->assertFalse($parser->userAgent()->isAllowed("/("));

if ($rendered !== false) {
if (version_compare(phpversion(), '7.0.0', '<')) {
$this->markTestIncomplete('Sort algorithm changed as of PHP 7');
}
$this->assertEquals($rendered, $parser->render()->normal("\n"));
$this->testEscaping($rendered, false);
}
Expand All @@ -62,9 +65,9 @@ public function generateDataForTest()
,
<<<RENDERED
User-agent: *
Disallow: /(
Disallow: /)
Disallow: /.
Disallow: /)
Disallow: /(
RENDERED
]
];
Expand Down

0 comments on commit 64c6827

Please sign in to comment.