Passed
Push — master ( 80b29e...941e97 )
by Ross
02:34
created

IpTypeTest::getClass()   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\Data;
23
24
use RossMitchell\UpdateCloudFlare\Data\IpType;
25
use RossMitchell\UpdateCloudFlare\Tests\AbstractTestClass;
26
use Symfony\Component\Console\Exception\LogicException;
27
28
/**
29
 * Class IpTypeTest
30
 * @testdox RossMitchell\UpdateCloudFlare\Data\IpType
31
 * @package RossMitchell\UpdateCloudFlare\Tests\Data
32
 */
33
class IpTypeTest extends AbstractTestClass
34
{
35
36
    /**
37
     * @test
38
     */
39
    public function canSetIpv4Type()
40
    {
41
       $type = $this->getClass();
42
       $ip4 = IpType::IP_V4;
43
       $type->setType($ip4);
44
       $this->assertEquals($ip4, $type->getType());
45
    }
46
47
    /**
48
     * @test
49
     */
50
    public function canSetIPv6Type()
51
    {
52
        $type = $this->getClass();
53
        $ip6 = IpType::IP_V6;
54
        $type->setType($ip6);
55
        $this->assertEquals($ip6, $type->getType());
56
    }
57
58
    /**
59
     * @test
60
     */
61
    public function willThrowAnExceptionIfAnUnknownTypeIsSet()
62
    {
63
        $type = $this->getClass();
64
        $unknownType = 'Unknown';
65
        $this->expectException(LogicException::class);
66
        $type->setType($unknownType);
67
    }
68
69
    /**
70
     * @test
71
     */
72
    public function willThrowAnExceptionIfNoTypeIsSet()
73
    {
74
        $type = $this->getClass();
75
        $this->expectException(LogicException::class);
76
        $type->getType();
77
    }
78
79
    /**
80
     * @return IpType
81
     */
82
    private function getClass(): IpType
83
    {
84
        return new IpType();
85
    }
86
}
87