Created
November 6, 2019 15:31
-
-
Save yourwebmaker/7f600954d41fa76d3b09921522bb558e to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
declare(strict_types=1); | |
namespace PHPBrasil\ExemploTest; | |
use PHPUnit\Framework\TestCase; | |
class ExemploMockStub extends TestCase | |
{ | |
public function testExemploComStub() : void | |
{ | |
$dadosCliente = []; | |
$httpClientStub = $this->createStub(HttpClient::class); | |
$clientesApi = new ClientesApi($httpClientStub); | |
self::assertEquals(201, $clientesApi->save($dadosCliente)->getResponseCode()); | |
} | |
public function testExemploComMock() : void | |
{ | |
$dadosCliente = []; | |
$httpClientMock = $this->createMock(HttpClient::class); | |
$httpClientMock | |
->method('post') | |
->expects($this->once()) | |
->willReturn($objResponse) | |
; | |
$clientesApi = new ClientesApi($httpClientMock); | |
$clientesApi->save($dadosCliente); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment