Passed
Push — master ( 8f9c8a...a42d4d )
by Ross
02:45
created

checkClassImplementsRequestInterface()   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 declare(strict_types = 1);
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\Interfaces\RequestInterface;
25
use RossMitchell\UpdateCloudFlare\Tests\AbstractTestClass;
26
27
/**
28
 * Class AbstractRequest - The tests for the request interfaces are going to be largely the same, so we'll abstract
29
 * them out
30
 * @package RossMitchell\UpdateCloudFlare\Tests\Requests
31
 */
32
abstract class AbstractRequest extends AbstractTestClass
33
{
34
    /**
35
     * @return mixed
36
     */
37
    abstract public function getRequest();
38
39
    /**
40
     * @return array
41
     */
42
    abstract public function getHeaders(): array;
43
44
    /**
45
     * @return string
46
     */
47
    abstract public function getRequestType(): string;
48
49
    /**
50
     * @return array
51
     */
52
    abstract public function getFields(): array;
53
54
    /**
55
     * @return string
56
     */
57
    abstract public function getUrl(): string;
58
59
    /**
60
     * @test
61
     */
62
    public function checkClassImplementsRequestInterface()
63
    {
64
        $this->assertInstanceOf(RequestInterface::class, $this->getRequest());
65
    }
66
67
    /**
68
     * @test
69
     */
70
    public function theClassReturnsTheCorrectHeadersArray()
71
    {
72
        $headers  = $this->getRequest()
73
                         ->getHeaders();
74
        $expected = $this->getHeaders();
75
        $this->assertInternalType('array', $headers);
76
        $this->assertEquals($expected, $headers);
77
    }
78
79
    /**
80
     * @test
81
     */
82
    public function theClassReturnsTheCorrectRequestType()
83
    {
84
        $this->assertEquals($this->getRequestType(),
85
                            $this->getRequest()
86
                                 ->getRequestType()
87
        );
88
    }
89
90
    /**
91
     * @test
92
     */
93
    public function theClassReturnsTheCorrectFields()
94
    {
95
        $fields   = $this->getRequest()
96
                         ->getFields();
97
        $expected = $this->getFields();
98
        $this->assertInternalType('array', $fields);
99
        $this->assertEquals($expected, $fields);
100
    }
101
102
    /**
103
     * @test
104
     */
105
    public function theClassReturnsTheCorrectUrl()
106
    {
107
        $expectedUrl = $this->getUrl();
108
        $this->assertEquals($expectedUrl,
109
                            $this->getRequest()
110
                                 ->getUrl()
111
        );
112
    }
113
}
114