Completed
Push — develop ( 461c20...bca833 )
by Chris
02:17
created

ZoneTest::testChangeOptions()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 32
rs 8.8571
cc 1
eloc 23
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 function setup()
12
    {
13
        $this->newCloudflare();
14
        $this->Zone = new Cloudflare\Zone($this->getCloudflare());
0 ignored issues
show
Bug introduced by
The property Zone does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
    }
16
17
    public function testGetAllZones()
18
    {
19
        $test = $this->Zone->getAll();
20
        $this->assertNotNull($test, "Zone info was empty");
21
    }
22
23
    public function testChangeOptions()
24
    {
25
        //Disable the curl request as we are only checking the URL
26
        $CF = $this->getCloudflare();
27
        $CF->diableRequests();
28
29
        $options = [
30
            'status' => 'pending',
31
            'page' => 2,
32
            'per_page' => 50,
33
            'order' => 'name',
34
            'direction' => 'desc',
35
            'match' => 'any',
36
        ];
37
        $domain = 'test.com';
38
39
        $this->Zone->get('test.com', $options);
40
        $RequestURL = $this->Zone->getRequestURL();
41
        $this->assertNotNull($RequestURL, "Request URL was null");
42
43
        $sting = explode('zones?', $RequestURL)[1];
44
45
        $shouldBe = "name=" . $domain
46
            . "&status=" . $options['status']
47
            . "&page=" . $options['page']
48
            . "&per_page=" . $options['per_page']
49
            . "&order=" . $options['order']
50
            . "&direction=" . $options['direction']
51
            . "&match=". $options['match'];
52
53
        $this->assertSame($sting, $shouldBe, 'Request URL is not correct');
54
    }
55
}