Skip to content

Commit 167d2f2

Browse files
committed
Readme and tests
1 parent 8e2263b commit 167d2f2

File tree

4 files changed

+61
-38
lines changed

4 files changed

+61
-38
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ foreach($result->getFormattedResults()->getRuleResults() as $rule => $ruleResult
3333
var_dump($ruleResult->getLocalizedRuleName()); // "Zielseiten-Weiterleitungen vermeiden"
3434

3535
/*
36-
* The getDetails() method returns is a wrapper to yield the summary field as well as urlblocks data.
36+
* The getDetails() method is a wrapper to get the `summary` field as well as `Urlblocks` data. You
37+
* can use $ruleResult->getUrlBlocks() and $ruleResult->getSummary() instead.
3738
*/
3839
foreach($ruleResult->getDetails() as $block) {
3940
var_dump($block->toString()); // "Auf Ihrer Seite sind keine Weiterleitungen vorhanden"

bin/phpunit.bat

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@echo off
2-
vendor/bin/phpunit --bootstrap "D:\xampp\htdocs\test\phpinsights\src\autoload.php"
2+
vendor/bin/phpunit --bootstrap "D:\xampp\htdocs\test\phpinsights\src\autoload.php" --report-useless-tests

tests/InsightsResponseTest.php

+2-36
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@ protected function setUp()
1818

1919
}
2020

21-
/**
22-
* @return InsightsResult
23-
*/
24-
protected function getMappedResult() {
25-
return $this->exampleComResponse->getMappedResult();
26-
}
27-
28-
public function testValidResponse()
21+
public function testValidResponse()
2922
{
3023
$this->assertInstanceOf(InsightsResponse::class, InsightsResponse::fromResponse(new Response(200, [], '{}')));
3124
}
@@ -53,34 +46,7 @@ public function testRawResult()
5346

5447
public function testMappedResult()
5548
{
56-
$this->assertInstanceOf(InsightsResult::class, $this->getMappedResult());
57-
}
58-
59-
public function testResponseCode()
60-
{
61-
$this->assertEquals(200, $this->getMappedResult()->getResponseCode());
62-
}
63-
64-
public function testKind()
65-
{
66-
$this->assertEquals('pagespeedonline#result', $this->getMappedResult()->getKind());
67-
}
68-
69-
public function testId()
70-
{
71-
$this->assertEquals('http://example.com/', $this->getMappedResult()->getId());
72-
}
73-
74-
public function testScreenshot()
75-
{
76-
$this->assertEquals('image/jpeg', $this->getMappedResult()->getScreenshot()->getMimeType());
77-
}
78-
79-
public function testPageStats()
80-
{
81-
$this->assertEquals(33, $this->getMappedResult()->getPageStats()->getTotalRequestBytes());
82-
$this->assertEquals(1599, $this->getMappedResult()->getPageStats()->getHtmlResponseBytes());
83-
49+
$this->assertInstanceOf(InsightsResult::class, $this->exampleComResponse->getMappedResult());
8450
}
8551

8652

tests/Result/InsightsResultTest.php

+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
3+
use GuzzleHttp\Psr7\Response;
4+
use PhpInsights\Result\InsightsResult;
5+
use PHPUnit\Framework\TestCase;
6+
use PhpInsights\InsightsResponse;
7+
8+
class InsightsResultTest extends TestCase
9+
{
10+
11+
/** @var InsightsResponse */
12+
protected $exampleComResponse;
13+
14+
15+
protected function setUp()
16+
{
17+
$this->exampleComResponse = InsightsResponse::fromJson(file_get_contents(__DIR__ . '/../example-com-response.json'));
18+
19+
}
20+
21+
/**
22+
* @return InsightsResult
23+
*/
24+
protected function getMappedResult() {
25+
return $this->exampleComResponse->getMappedResult();
26+
}
27+
28+
public function testResponseCode()
29+
{
30+
$this->assertEquals(200, $this->getMappedResult()->getResponseCode());
31+
}
32+
33+
public function testKind()
34+
{
35+
$this->assertEquals('pagespeedonline#result', $this->getMappedResult()->getKind());
36+
}
37+
38+
public function testId()
39+
{
40+
$this->assertEquals('http://example.com/', $this->getMappedResult()->getId());
41+
}
42+
43+
public function testScreenshot()
44+
{
45+
$this->assertEquals('image/jpeg', $this->getMappedResult()->getScreenshot()->getMimeType());
46+
}
47+
48+
public function testPageStats()
49+
{
50+
$this->assertEquals(33, $this->getMappedResult()->getPageStats()->getTotalRequestBytes());
51+
$this->assertEquals(1599, $this->getMappedResult()->getPageStats()->getHtmlResponseBytes());
52+
53+
}
54+
55+
56+
}

0 commit comments

Comments
 (0)