Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey Andrienko committed Jul 5, 2018
1 parent ec7f2bd commit 6a7fe8c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
3 changes: 3 additions & 0 deletions src/Downloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class Downloader implements DownloaderInterface
{
/**
* @var ClientInterface
*/
protected $client;

public function __construct(ClientInterface $client)
Expand Down
7 changes: 4 additions & 3 deletions tests/DownloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public function test_download()
['test' => 'TEST_HEADER'],
['test1' => 'TEST_HEADER1'],
];
$code = 200;

$mock = new MockHandler([
new Response(200, $headers, $body)
]);
$setResponse = new Response($code, $headers, $body);
$mock = new MockHandler([$setResponse]);
$handler = HandlerStack::create($mock);
$client = new Client(['handler' => $handler]);
$downloader = new Downloader($client);
Expand All @@ -31,5 +31,6 @@ public function test_download()
$this->assertSame($body, (string)$response->getBody());
$this->assertSame($headers[0], $response->getHeaders()[0]);
$this->assertSame($headers[1], $response->getHeaders()[1]);
$this->assertSame($code, $response->getStatusCode());
}
}
13 changes: 12 additions & 1 deletion tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@ public function test_get_tag_content()
{
$parser = new Parser;

$html = "<p>wedfwefwfwef</p>";
$html = "<p>111111111111</p>";

$result = $parser->getTagContent('p', $html);

$this->assertCount(1, $result);

$html .= PHP_EOL . "<p>222222222222</p>";

$result2 = $parser->getTagContent('p', $html);

$this->assertCount(2, $result2);
}

public function test_get_meta_tag()
Expand All @@ -28,5 +33,11 @@ public function test_get_meta_tag()
$result = $parser->getMetaTags($meta);

$this->assertCount(1, $result);

$meta .= PHP_EOL . "<meta name=\"viewport2\" content=\"width=device-width, initial-scale=2\">";

$result2 = $parser->getMetaTags($meta);

$this->assertCount(2, $result2);
}
}

0 comments on commit 6a7fe8c

Please sign in to comment.