/ExchangeRateTest.php Secret
Last active
April 6, 2020 22:19
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use GuzzleHttp\Client; | |
use GuzzleHttp\Handler\MockHandler; | |
use GuzzleHttp\HandlerStack; | |
use GuzzleHttp\Psr7\Response; | |
use PHPUnit\Framework\TestCase; | |
final class ExchangeRateTest extends TestCase | |
{ | |
public function setUp(): void | |
{ | |
$mock = new MockHandler([ | |
new Response(200, [], '{"rates":{"BRL":5.0929215633},"base":"USD","date":"2020-03-27"}'), | |
]); | |
$handlerStack = HandlerStack::create($mock); | |
$this->httpClient = new Client(['handler' => $handlerStack]) | |
} | |
public function testExchangeRateReturn(): void | |
{ | |
$this->assertEquals(5.0929215633, return_exchange_rate($this->httpClient)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment