Completed
Push — master ( 4a5840...1f0278 )
by
unknown
11s
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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A MoipResourceTest::testEndpointGenerateListPathNoParams() 0 5 1
A MoipResourceTest::testEndpointGenerateListPaginationFilter() 0 5 1
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);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a array.

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:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
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