jobcloud / jobcloud-http-mock-server
This package is abandoned and no longer maintained.
No replacement package was suggested.
A minimal http mock server.
3.0.0
2022-10-20 08:47 UTC
Requires
- php: ^7.1|^8.0
- ext-json: *
- react/event-loop: >=0.4
- react/http: ^1.8.0
- symfony/process: ^3.4|^4.2
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.15.1
- phpstan/phpstan: ^0.12.99
- phpunit/phpunit: ^7.5.14|^8.3.4
README
Description
A minimal http mock server.
Requirements
- php: ^7.1|^8.0
- react/event-loop: >=0.4,
- react/http: ^0.8.4,
- symfony/process: ^3.4|^4.2
Installation
Through Composer as jobcloud/jobcloud-http-mock-server.
Usage
<?php declare(strict_types=1); namespace MyProject\Tests; use Jobcloud\HttpMockServer\HttpMockServer; use Jobcloud\HttpMockServer\Response; use PHPUnit\Framework\TestCase; class MyTest extends TestCase { public function testSomthingWithHttpCalls() { $httpMockServer = new HttpMockServer(); $httpMockServer->run(8080, [ Response::create() ->withStatus(200) ->withHeader('Content-Type', 'application/json') ->withBody('{"id":1, "email":"john.doe@jobcloud.ch"}'), ]); file_get_contents( 'http://localhost:8080/', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => 'Content-Type: application/json', 'content' => json_encode(['email' => 'john.doe@jobcloud.ch']), ], ]) ); } }
Copyright
Jobcloud AG 2019