SubDomainInfoFactoryTest::itCanCreateTheClass()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
declare(strict_types = 1);
3
/**
4
 *
5
 * Copyright (C) 2018  Ross Mitchell
6
 *
7
 * This file is part of RossMitchell/UpdateCloudFlare.
8
 *
9
 * RossMitchell/UpdateCloudFlare is free software: you can redistribute
10
 * it and/or modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation, either version 3 of the
12
 * License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21
 */
22
23
namespace RossMitchell\UpdateCloudFlare\Tests\Factories\Data;
24
25
26
use RossMitchell\UpdateCloudFlare\Data\IpType;
27
use RossMitchell\UpdateCloudFlare\Data\SubDomainInfo;
28
use RossMitchell\UpdateCloudFlare\Factories\Data\SubDomainInfoFactory;
29
use RossMitchell\UpdateCloudFlare\Tests\AbstractTestClass;
30
31
/**
32
 * Class SubDomainInfoFactoryTest
33
 * @testdox RossMitchell\UpdateCloudFlare\Factories\Data\SubDomainInfoFactory
34
 * @package RossMitchell\UpdateCloudFlare\Tests\Factories\Data
35
 */
36
class SubDomainInfoFactoryTest extends AbstractTestClass
37
{
38
    /**
39
     * @Inject
40
     * @var SubDomainInfoFactory
41
     */
42
    private $factory;
43
44
    /**
45
     * @test
46
     */
47
    public function itCanCreateTheClass(): void
48
    {
49
        $class = $this->createClass();
50
        $this->assertInstanceOf(SubDomainInfo::class, $class);
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function itCanCreateAClassWhenGetIsCalled(): void
57
    {
58
        $class = $this->getClass();
59
        $this->assertInstanceOf(SubDomainInfo::class, $class);
60
    }
61
62
    /**
63
     * @test
64
     */
65
    public function callingGetWhenTheClassHasAlreadyBeenCreatedWillReturnIt(): void
66
    {
67
        $createdClass = $this->createClass();
68
        $gotClass     = $this->getClass();
69
        $this->assertEquals($createdClass, $gotClass);
70
    }
71
72
    /**
73
     * @test
74
     */
75
    public function callingGetWhenTheClassHasNotAlreadyBeenCreatedWillReturnADifferentClass(): void
76
    {
77
        $createdClass = $this->createClass();
78
        $gotClass     = $this->getClass('example');
79
        $this->assertNotEquals($createdClass, $gotClass);
80
    }
81
82
    /**
83
     * @param string $subDomain
84
     * @param string $type
85
     *
86
     * @return SubDomainInfo
87
     */
88
    private function createClass(string $subDomain = 'www', string $type = IpType::IP_V4): SubDomainInfo
89
    {
90
        return $this->factory->create($subDomain, $type);
91
    }
92
93
    /**
94
     * @param string $subDomain
95
     * @param string $type
96
     *
97
     * @return SubDomainInfo
98
     */
99
    private function getClass(string $subDomain = 'www', string $type = IpType::IP_V4): SubDomainInfo
100
    {
101
        return $this->factory->get($subDomain, $type);
102
    }
103
}
104