Skip to content

Commit bc6e817

Browse files
committed
Fix examples
1 parent 87dbfb5 commit bc6e817

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

examples/PhpUnit/AssertTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use FR3D\SwaggerAssertions\SchemaManager;
55
use GuzzleHttp\Client;
66
use GuzzleHttp\ClientInterface;
7+
use GuzzleHttp\Psr7\Request;
78
use PHPUnit\Framework\TestCase;
89

910
/**
@@ -25,9 +26,6 @@ class AssertTest extends TestCase
2526

2627
public static function setUpBeforeClass()
2728
{
28-
if (version_compare(ClientInterface::VERSION, '6.0', '>=')) {
29-
self::markTestSkipped('This example requires Guzzle V5 installed');
30-
}
3129
self::$schemaManager = SchemaManager::fromUri('http://petstore.swagger.io/v2/swagger.json');
3230
}
3331

@@ -38,11 +36,12 @@ protected function setUp()
3836

3937
public function testFetchPetBodyMatchDefinition()
4038
{
41-
$request = $this->guzzleHttpClient->createRequest('GET', 'http://petstore.swagger.io/v2/pet/findByStatus');
42-
$request->addHeader('Accept', 'application/json');
39+
$request = new Request('GET', 'http://petstore.swagger.io/v2/pet/findByStatus');
40+
$request = $request->withHeader('Accept', 'application/json');
4341

4442
$response = $this->guzzleHttpClient->send($request);
45-
$responseBody = $response->json(['object' => true]);
43+
44+
$responseBody = json_decode((string) $response->getBody());
4645

4746
$this->assertResponseBodyMatch($responseBody, self::$schemaManager, '/v2/pet/findByStatus', 'get', 200);
4847
}

examples/PhpUnit/LocalFileTest.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use FR3D\SwaggerAssertions\SchemaManager;
55
use GuzzleHttp\Client;
66
use GuzzleHttp\ClientInterface;
7+
use GuzzleHttp\Psr7\Request;
78
use PHPUnit\Framework\TestCase;
89

910
/**
@@ -33,19 +34,17 @@ public static function setUpBeforeClass()
3334

3435
protected function setUp()
3536
{
36-
if (version_compare(ClientInterface::VERSION, '6.0', '>=')) {
37-
self::markTestSkipped('This example requires Guzzle V5 installed');
38-
}
3937
$this->guzzleHttpClient = new Client(['headers' => ['User-Agent' => 'https://github.com/Maks3w/SwaggerAssertions']]);
4038
}
4139

4240
public function testFetchPetBodyMatchDefinition()
4341
{
44-
$request = $this->guzzleHttpClient->createRequest('GET', 'http://petstore.swagger.io/v2/pet/findByStatus');
45-
$request->addHeader('Accept', 'application/json');
42+
$request = new Request('GET', 'http://petstore.swagger.io/v2/pet/findByStatus');
43+
$request = $request->withHeader('Accept', 'application/json');
4644

4745
$response = $this->guzzleHttpClient->send($request);
48-
$responseBody = $response->json(['object' => true]);
46+
47+
$responseBody = json_decode((string) $response->getBody());
4948

5049
$this->assertResponseBodyMatch($responseBody, self::$schemaManager, '/v2/pet/findByStatus', 'get', 200);
5150
}

examples/PhpUnit/Psr7WithGuzzleV6Test.php

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,16 +31,13 @@ public static function setUpBeforeClass()
3131

3232
protected function setUp()
3333
{
34-
if (version_compare(ClientInterface::VERSION, '6.0', '<')) {
35-
self::markTestSkipped('This example requires Guzzle V6 installed');
36-
}
3734
$this->guzzleHttpClient = new Client(['headers' => ['User-Agent' => 'https://github.com/Maks3w/SwaggerAssertions']]);
3835
}
3936

4037
public function testFetchPetMatchDefinition()
4138
{
42-
$request = new Request('GET', 'http://petstore.swagger.io/v2/pet/findByStatus');
43-
$request->withHeader('Accept', 'application/json');
39+
$request = new Request('GET', 'http://petstore.swagger.io/v2/store/inventory');
40+
$request = $request->withHeader('Accept', 'application/json');
4441

4542
$response = $this->guzzleHttpClient->send($request);
4643

@@ -50,7 +47,7 @@ public function testFetchPetMatchDefinition()
5047
public function testOnlyResponse()
5148
{
5249
$request = new Request('GET', 'http://petstore.swagger.io/v2/pet/findByStatus');
53-
$request->withHeader('Accept', 'application/json');
50+
$request = $request->withHeader('Accept', 'application/json');
5451

5552
$response = $this->guzzleHttpClient->send($request);
5653

0 commit comments

Comments
 (0)