composer require fgsl/http
Run command:
composer install
For getting Composer: https://getcomposer.org/download/
phpunit --bootstrap tests/bootstrap.php tests/Fgsl/Test/TestSuite.php
See below a sample of method request
.
use Fgsl\Http\Http;
$ctx = Http::getContext('GET', null);
@$response = Http::request("http://www.horalegalbrasil.mct.on.br/SincronismoPublico.html", $ctx);
$this->assertStringContainsString('Sincronismo', $response);
The variable $ctx
receives a HTTP context, that is a resource with elements of HTTP protocol.
The variable $response
receives HTTP response text, according context defined by $ctx
.
Sometimes method request
may not work. Then you can use method curl
.
See ApiTest class for more examples.