Created
April 20, 2019 16:41
-
-
Save rslhdyt/b34bacc49f22d57681bfe112b0a8deaf to your computer and use it in GitHub Desktop.
[Mock Koperasi Api Request] example mocking koperasi io request #mocking #phpunit #laravel
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 | |
... | |
/** | |
* A basic test example. | |
* | |
* @return void | |
*/ | |
public function testSearchPageResult() | |
{ | |
// Create a mock and queue two responses. | |
$mockUser = \Mockery::mock(\KoperasiIo\KoperasiApi\Api\User::class, ['getMember' => ['data' => [ | |
'id' => 1, | |
'name' => 'Foo', | |
'number' => '1234', | |
'gender' => 'Male', | |
'photo_url' => 'http://photo.com/image.jpg' | |
]]]); | |
$mock = \Mockery::mock(\KoperasiIo\KoperasiApi\KoperasiApi::class, ['user' => $mockUser]); | |
$this->app->instance(\KoperasiIo\KoperasiApi\KoperasiApi::class, $mock); | |
$response = $this->actingAs($this->authUser) | |
->get('deposits/transactions/search?' . http_build_query([ | |
'member_id' => 1, | |
'deposit_type_id' => 1, | |
'start_date' => '2018-01-01', | |
'end_date' => '2018-01-02', | |
])); | |
$response->assertStatus(200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment