Skip to content

Commit

Permalink
tests: add tests to the search endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sfwill-dev authored and murilohns committed May 13, 2020
1 parent 7158c6f commit d24434d
Show file tree
Hide file tree
Showing 3 changed files with 462 additions and 0 deletions.
55 changes: 55 additions & 0 deletions tests/unit/Endpoints/SearchTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php

namespace PagarMe\Endpoints\Test;

use PagarMe\Client;
use PagarMe\Endpoints\Search;
use PagarMe\Test\Endpoints\PagarMeTestCase;
use GuzzleHttp\Handler\MockHandler;
use GuzzleHttp\Psr7\Response;

final class SearchTest extends PagarMeTestCase
{
public function searchProvider()
{
return [[[
'list' => new MockHandler([
new Response(200, [], self::jsonMock('SearchListMock')),
new Response(200, [], '[]'),
]),
]]];
}

/**
* @dataProvider SearchProvider
*/
public function testSearchGet($mock)
{
$requestsContainer = [];

$client = self::buildClient($requestsContainer, $mock['list']);

$response = $client->search()->get([
"type" => "transaction",
"query" => [
"query" => [
"terms" => [
"items.id" => [9]
]
]
]
]);

$query = self::getQueryString($requestsContainer[0]);

$this->assertEquals(
Search::GET,
self::getRequestMethod($requestsContainer[0])
);
$this->assertContains('type=transaction', $query);
$this->assertEquals(
json_decode(self::jsonMock('SearchListMock')),
$response
);
}
}
Loading

0 comments on commit d24434d

Please sign in to comment.