Skip to content

Commit

Permalink
Tests to increase coverage + UserAgentTools class - pass by reference…
Browse files Browse the repository at this point in the history
… regression
  • Loading branch information
JanPetterMG committed Aug 10, 2016
1 parent 17cd7a2 commit b262efd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Client/Directives/UserAgentTools.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ private function checkPath($directive, $uri)
self::DIRECTIVE_NO_INDEX => $this->handler->noIndex(),
self::DIRECTIVE_DISALLOW => $this->handler->disallow(),
self::DIRECTIVE_ALLOW => $this->handler->allow(),
] as $currentDirective => &$handler) {
] as $currentDirective => $handler) {
if ($handler->client()->isListed($uri)) {
if ($currentDirective === self::DIRECTIVE_NO_INDEX) {
return $directive === self::DIRECTIVE_DISALLOW;
Expand Down
8 changes: 5 additions & 3 deletions tests/CleanParamTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public function testCleanParam($robotsTxtContent, $result, $rendered)

$this->assertEquals($result['Clean-param'], $parser->cleanParam()->export());

$this->assertEquals($result['NoIndex'], $parser->userAgent()->noIndex()->cleanParam()->export());
$this->assertEquals($result['Disallow'], $parser->userAgent()->disallow()->cleanParam()->export());
$this->assertEquals($result['Allow'], $parser->userAgent()->allow()->cleanParam()->export());
for ($i = 1; $i <= 2; $i++) {
$this->assertEquals($result['NoIndex'], $parser->userAgent()->noIndex()->cleanParam()->export());
$this->assertEquals($result['Disallow'], $parser->userAgent()->disallow()->cleanParam()->export());
$this->assertEquals($result['Allow'], $parser->userAgent()->allow()->cleanParam()->export());
}

if ($rendered !== false) {
$this->assertEquals($rendered, $parser->render()->normal("\n"));
Expand Down
8 changes: 5 additions & 3 deletions tests/HostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ public function testHost($robotsTxtContent, $rendered)
$this->assertEquals('myhost.com', $parser->host()->getWithUriFallback());
$this->assertFalse($parser->host()->isPreferred());

$this->assertFalse($parser->userAgent()->allow()->host()->isListed('http://www.myhost.com/'));
$this->assertTrue($parser->userAgent()->disallow()->host()->isListed('http://www.myhost.com/'));
$this->assertFalse($parser->userAgent()->noIndex()->host()->isListed('http://www.myhost.com/'));
for ($i = 1; $i <= 2; $i++) {
$this->assertFalse($parser->userAgent()->allow()->host()->isListed('http://www.myhost.com/'));
$this->assertTrue($parser->userAgent()->disallow()->host()->isListed('http://www.myhost.com/'));
$this->assertFalse($parser->userAgent()->noIndex()->host()->isListed('http://www.myhost.com/'));
}

if ($rendered !== false) {
$this->assertEquals($rendered, $parser->render()->normal("\n"));
Expand Down

0 comments on commit b262efd

Please sign in to comment.