Completed
Push — master ( 2f2459...d82a91 )
by Ross
02:33
created

DnsRecordsTest::getRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
/**
3
 *
4
 * Copyright (C) 2018  Ross Mitchell
5
 *
6
 * This file is part of RossMitchell/UpdateCloudFlare.
7
 *
8
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
9
 * it and/or modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20
 */
21
22
namespace RossMitchell\UpdateCloudFlare\Tests\Requests;
23
24
use RossMitchell\UpdateCloudFlare\Data\IpType;
25
use RossMitchell\UpdateCloudFlare\Factories\Requests\DnsRecordsFactory;
26
27
/**
28
 * Class DnsRecordsTest
29
 * @package RossMitchell\UpdateCloudFlare\Tests\Requests
30
 */
31
class DnsRecordsTest extends AbstractRequest
32
{
33
    /**
34
     * @Inject
35
     * @var DnsRecordsFactory
36
     */
37
    private $dnsRecords;
38
39
    private $subDomain = 'www';
40
    private $type = IpType::IP_V4;
41
    private $zoneId = '12345';
42
43
44
    /**
45
     * @return mixed
46
     */
47
    public function getRequest()
48
    {
49
        return $this->dnsRecords->create($this->subDomain, $this->type, $this->zoneId);
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    public function getHeaders(): array
56
    {
57
        return [
58
            'X-Auth-Email: [email protected]',
59
            'X-Auth-Key: 123456789',
60
            'Content-Type: application/json',
61
        ];
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getRequestType(): string
68
    {
69
        return 'GET';
70
    }
71
72
    /**
73
     * @return array
74
     */
75
    public function getFields(): array
76
    {
77
        return [];
78
    }
79
80
    /**
81
     * @return string
82
     */
83
    public function getUrl(): string
84
    {
85
        $zoneId = $this->zoneId;
86
        $type = $this->type;
87
        $domain = $this->subDomain . '.example.com';
88
        return "https://api.cloudflare.com/client/v4/zones/${zoneId}/dns_records?type=${type}&name=${domain}";
89
    }
90
}
91