Completed
Push — master ( 461c20...02a675 )
by Chris
01:56
created

ZoneTest::testGetAllZones()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
/**
3
 * @author Chris Hilsdon <[email protected]>
4
 */
5
namespace Cloudflare\Tests;
6
7
use Cloudflare;
8
9
class ZoneTest extends BaseUnit
10
{
11
    protected $Zone;
12
13
    protected function setup()
14
    {
15
        $this->newCloudflare();
16
        $this->Zone = new Cloudflare\Zone($this->getCloudflare());
17
    }
18
19
    public function testGetAllZones()
20
    {
21
        $test = $this->Zone->getAll();
22
        $this->assertNotNull($test, "Zone info was empty");
23
    }
24
25
    public function testChangeOptions()
26
    {
27
        //Disable the curl request as we are only checking the URL
28
        $CF = $this->getCloudflare();
29
        $CF->diableRequests();
30
31
        $options = [
32
            'status' => 'pending',
33
            'page' => 2,
34
            'per_page' => 50,
35
            'order' => 'name',
36
            'direction' => 'desc',
37
            'match' => 'any',
38
        ];
39
        $domain = 'test.com';
40
41
        $this->Zone->get('test.com', $options);
42
        $RequestURL = $this->Zone->getRequestURL();
43
        $this->assertNotNull($RequestURL, "Request URL was null");
44
45
        $sting = explode('zones?', $RequestURL)[1];
46
47
        $shouldBe = "name=" . $domain
48
            . "&status=" . $options['status']
49
            . "&page=" . $options['page']
50
            . "&per_page=" . $options['per_page']
51
            . "&order=" . $options['order']
52
            . "&direction=" . $options['direction']
53
            . "&match=". $options['match'];
54
55
        $this->assertSame($sting, $shouldBe, 'Request URL is not correct');
56
    }
57
}