forked from bigcommerce/bigcommerce-api-php
-
Notifications
You must be signed in to change notification settings - Fork 1
/
FilterTest.php
41 lines (35 loc) · 1.19 KB
/
FilterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
namespace Bigcommerce\Test\Unit\Api;
use Bigcommerce\Api\Filter;
use PHPUnit\Framework\TestCase;
class FilterTest extends TestCase
{
public function testToQueryBuildsAnAppropriateQueryString()
{
$filter = new Filter(array('a' => 1, 'b' => 'orange'));
$this->assertSame('?a=1&b=orange', $filter->toQuery());
}
public function testUpdateParameter()
{
$filter = new Filter(array('a' => 'b'));
$this->assertSame('?a=b', $filter->toQuery());
$filter->a = 'c';
$this->assertSame('?a=c', $filter->toQuery());
}
public function testStaticCreateMethodAssumesIntegerParameterIsPageNumber()
{
$filter = Filter::create(1);
$this->assertSame('?page=1', $filter->toQuery());
}
public function testStaticCreateMethodReturnsFilterObjectIfCalledWithFilterObject()
{
$original = new Filter(array('a' => 'b'));
$filter = Filter::create($original);
$this->assertSame($original, $filter);
}
public function testStaticCreateMethodReturnsCorrectlyConfiguredFilter()
{
$filter = Filter::create(array('a' => 'b'));
$this->assertSame('?a=b', $filter->toQuery());
}
}