Skip to content

Commit

Permalink
Test enhancements about assertions (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
peter279k committed Jan 9, 2021
1 parent 2042e4d commit 226aa5f
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion tests/DownloadGoogleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testDownloadGoogle($base)

$this->assertTrue(count($uriClient->sitemap()->export()) > 0);

$this->assertTrue(is_string($uriClient->host()->getWithUriFallback()));
$this->assertInternalType('string', $uriClient->host()->getWithUriFallback());

$txtClient = new RobotsTxtParser\TxtClient($uriClient->getBaseUri(), $uriClient->getStatusCode(), $uriClient->getContents(), $uriClient->getEncoding(), $uriClient->getEffectiveUri());
$this->assertInstanceOf('vipnytt\RobotsTxtParser\TxtClient', $txtClient);
Expand Down
2 changes: 1 addition & 1 deletion tests/DownloadMicrosoftTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function testDownloadMicrosoft($base)

$this->assertTrue(count($uriClient->sitemap()->export()) > 0);

$this->assertTrue(is_string($uriClient->host()->getWithUriFallback()));
$this->assertInternalType('string', $uriClient->host()->getWithUriFallback());

$txtClient = new RobotsTxtParser\TxtClient($uriClient->getBaseUri(), $uriClient->getStatusCode(), $uriClient->getContents(), $uriClient->getEncoding(), $uriClient->getEffectiveUri());
$this->assertInstanceOf('vipnytt\RobotsTxtParser\TxtClient', $txtClient);
Expand Down
12 changes: 6 additions & 6 deletions tests/MysqlDelayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,18 @@ public function testDelay($uri, $userAgent)

$handler = (new RobotsTxtParser\Database($pdo))->delay();
$parser = new RobotsTxtParser\UriClient($uri);
$this->assertTrue(is_numeric($parser->userAgent($userAgent)->crawlDelay()->handle($handler)->checkQueue()));
$this->assertTrue(is_numeric($parser->userAgent($userAgent)->crawlDelay()->handle($handler)->getTimeSleepUntil()));
$this->assertTrue(is_numeric($parser->userAgent($userAgent)->crawlDelay()->handle($handler)->sleep()));
$this->assertInternalType('numeric', $parser->userAgent($userAgent)->crawlDelay()->handle($handler)->checkQueue());
$this->assertInternalType('numeric', $parser->userAgent($userAgent)->crawlDelay()->handle($handler)->getTimeSleepUntil());
$this->assertInternalType('numeric', $parser->userAgent($userAgent)->crawlDelay()->handle($handler)->sleep());

$this->assertInstanceOf('vipnytt\RobotsTxtParser\Client\Delay\ManageInterface', $handler);
$this->assertFalse($pdo->getAttribute(\PDO::ATTR_ERRMODE) === \PDO::ERRMODE_SILENT);

$client = $handler->base($uri, $userAgent, $parser->userAgent($userAgent)->crawlDelay()->getValue());
$this->assertInstanceOf('vipnytt\RobotsTxtParser\Client\Delay\BaseInterface', $client);
$this->assertTrue(is_numeric($client->getTimeSleepUntil()));
$this->assertInternalType('numeric', $client->getTimeSleepUntil());

$this->assertTrue(is_numeric($client->checkQueue()));
$this->assertInternalType('numeric', $client->checkQueue());
$start = microtime(true);
$sleepTime = $client->sleep();
$stop = microtime(true);
Expand All @@ -56,7 +56,7 @@ public function testDelay($uri, $userAgent)
$sleepTime <= ($stop - $start + 1)
);

$this->assertTrue(is_array($handler->getTopWaitTimes()));
$this->assertInternalType('array', $handler->getTopWaitTimes());

$client->reset();
$this->assertTrue($client->getTimeSleepUntil() === 0);
Expand Down
2 changes: 1 addition & 1 deletion tests/RequestRateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function testRequestRate($robotsTxtContent, $result, $rendered)
foreach ($result as $value) {
$validRates[] = $value['rate'];
}
$this->assertTrue(in_array($parser->userAgent('Legacy')->requestRate()->getValue(), $validRates));
$this->assertContains($parser->userAgent('Legacy')->requestRate()->getValue(), $validRates);

if ($rendered !== false) {
$this->assertEquals($result, $parser->userAgent('*')->requestRate()->export());
Expand Down

0 comments on commit 226aa5f

Please sign in to comment.