1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Moip\Tests\Resource; |
4
|
|
|
|
5
|
|
|
use Moip\Helper\Filters; |
6
|
|
|
use Moip\Helper\Pagination; |
7
|
|
|
use Moip\Resource\MoipResource; |
8
|
|
|
use Moip\Resource\NotificationPreferences; |
9
|
|
|
use Moip\Resource\OrdersList; |
10
|
|
|
use Moip\Tests\TestCase; |
11
|
|
|
|
12
|
|
|
class MoipResourceTest extends TestCase |
13
|
|
|
{ |
14
|
|
|
private $filter; |
15
|
|
|
private $pagination; |
16
|
|
|
|
17
|
|
|
public function __construct() |
18
|
|
|
{ |
19
|
|
|
parent::__construct(); |
20
|
|
|
$this->filter = new Filters(); |
21
|
|
|
$this->filter->between('amount', 1000, 10000); |
22
|
|
|
$this->filter->in('status', ['NOT_PAID', 'WAITING']); |
23
|
|
|
$this->pagination = new Pagination(10, 0); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testEndpointGeneratePath() |
27
|
|
|
{ |
28
|
|
|
$path = $this->moip->notifications()->generatePath('notifications', 'NPR-CQU74AQOIVCV'); |
29
|
|
|
$expected = sprintf('%s/%s/%s/%s', MoipResource::VERSION, NotificationPreferences::PATH, 'notifications', 'NPR-CQU74AQOIVCV'); |
30
|
|
|
$this->assertEquals($expected, $path); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testEndpointGenerateListPathNoParams() |
34
|
|
|
{ |
35
|
|
|
$path = $this->moip->orders()->generateListPath(); |
36
|
|
|
$this->assertEquals(sprintf('/%s/%s', MoipResource::VERSION, OrdersList::PATH), $path); |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
public function testEndpointGenerateListPaginationFilter() |
40
|
|
|
{ |
41
|
|
|
$path = $this->moip->orders()->generateListPath($this->pagination, $this->filter, null); |
|
|
|
|
42
|
|
|
$this->assertEquals(sprintf('/%s/%s?%s', MoipResource::VERSION, OrdersList::PATH, 'limit=10&offset=0&filters='.urlencode('amount::bt(1000,10000)|status::in(NOT_PAID,WAITING)')), $path); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testEndpointGenerateListAllParams() |
46
|
|
|
{ |
47
|
|
|
$path = $this->moip->orders()->generateListPath($this->pagination, $this->filter, ['q' => 'jose augusto']); |
48
|
|
|
$this->assertEquals(sprintf('/%s/%s?%s', MoipResource::VERSION, OrdersList::PATH, 'limit=10&offset=0&filters='.urlencode('amount::bt(1000,10000)|status::in(NOT_PAID,WAITING)').'&q='.urlencode('jose augusto')), $path); |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: