Completed
Push — master ( df95c6...f74e51 )
by
unknown
13s
created

MoipResourceTest::provider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 10
nc 1
nop 0
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
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
    public function testEndpointGeneratePath()
15
    {
16
        $path = $this->moip->notifications()->generatePath('notifications', 'NPR-CQU74AQOIVCV');
17
        $expected = sprintf('%s/%s/%s/%s', MoipResource::VERSION, NotificationPreferences::PATH, 'notifications', 'NPR-CQU74AQOIVCV');
18
        $this->assertEquals($expected, $path);
19
    }
20
21
    /**
22
     * @dataProvider provider
23
     */
24
    public function testEndpointGenerateListPath($pagination, $filter, $qParam, $expected)
25
    {
26
        $path = $this->moip->orders()->generateListPath($pagination, $filter, $qParam);
27
        $this->assertEquals($expected, $path);
28
    }
29
30
    public function provider()
31
    {
32
        $testCases = [];
33
34
        $filter = new Filters();
35
        $filter->between('amount', 1000, 10000);
36
        $filter->in('status', ['NOT_PAID', 'WAITING']);
37
        $pagination = new Pagination(10, 0);
38
39
        $testCases[] = [null, null, null, sprintf('/%s/%s?%s', MoipResource::VERSION, OrdersList::PATH, '')];
40
        $testCases[] = [$pagination, $filter, null, sprintf('/%s/%s?%s', MoipResource::VERSION, OrdersList::PATH, 'limit=10&offset=0&filters='.urlencode('amount::bt(1000,10000)|status::in(NOT_PAID,WAITING)'))];
41
        $testCases[] = [$pagination, $filter, 'jose augusto', 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'))];
42
43
        return $testCases;
44
    }
45
}
46