Skip to content

Commit b240bad

Browse files
committed
Setup mock web server lib
1 parent d40a157 commit b240bad

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"justinrainbow/json-schema": "^5.2 || ^6.0"
2525
},
2626
"require-dev": {
27+
"ext-sockets": "*",
2728
"cebe/indent": "*",
2829
"phpunit/phpunit": "^6.5 || ^7.5 || ^8.5 || ^9.4",
2930
"oai/openapi-specification": "3.0.3",

tests/docker/Dockerfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,13 @@ RUN apt-get update && \
1919
curl \
2020
libcurl4-openssl-dev \
2121
libssl-dev \
22+
procps \
2223
--no-install-recommends && \
2324
apt-get clean && \
2425
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \
2526
&& pecl install xdebug-2.9.6 \
27+
&& docker-php-ext-install sockets \
28+
&& docker-php-ext-enable sockets \
2629
&& docker-php-ext-enable xdebug \
2730
&& docker-php-ext-install \
2831
zip \

tests/spec/ReferenceTest.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,35 @@
11
<?php
22

33
use cebe\openapi\Reader;
4+
use cebe\openapi\spec\Example;
45
use cebe\openapi\spec\OpenApi;
56
use cebe\openapi\spec\Parameter;
67
use cebe\openapi\spec\Reference;
78
use cebe\openapi\spec\RequestBody;
89
use cebe\openapi\spec\Response;
910
use cebe\openapi\spec\Schema;
10-
use cebe\openapi\spec\Example;
11+
use donatj\MockWebServer\MockWebServer;
1112

1213
/**
1314
* @covers \cebe\openapi\spec\Reference
1415
*/
1516
class ReferenceTest extends \PHPUnit\Framework\TestCase
1617
{
18+
/** @var MockWebServer */
19+
private $server;
20+
21+
protected function setUp(): void
22+
{
23+
$this->server = new MockWebServer();
24+
$this->server->stop();
25+
$this->server->start();
26+
}
27+
28+
protected function tearDown(): void
29+
{
30+
$this->server->stop();
31+
}
32+
1733
public function testResolveInDocument()
1834
{
1935
/** @var $openapi OpenApi */
@@ -233,6 +249,19 @@ public function testResolveFileInSubdirWithMultipleRelativePaths()
233249

234250
public function testResolveFileHttp()
235251
{
252+
$url = $this->server->setResponseOfPath(
253+
'/definedPath',
254+
'This is our http body response'
255+
);
256+
257+
$content = file_get_contents($url);
258+
$this->assertSame('This is our http body response', $content);
259+
260+
261+
// TODO
262+
return;
263+
264+
236265
$file = 'https://raw.githubusercontent.com/cebe/php-openapi/290389bbd337cf4d70ecedfd3a3d886715e19552/tests/spec/data/reference/base.yaml';
237266
/** @var $openapi OpenApi */
238267
$openapi = Reader::readFromYaml(str_replace('##ABSOLUTEPATH##', dirname($file), file_get_contents($file)));

0 commit comments

Comments
 (0)