Passed
Push — master ( ec1f20...2f2459 )
by Ross
02:33
created

itCanCreateAClassWhenGetIsCalled()   A

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
/**
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\Factories\Data;
23
24
25
use RossMitchell\UpdateCloudFlare\Data\IpType;
26
use RossMitchell\UpdateCloudFlare\Data\SubDomainInfo;
27
use RossMitchell\UpdateCloudFlare\Factories\Data\SubDomainInfoFactory;
28
use RossMitchell\UpdateCloudFlare\Tests\AbstractTestClass;
29
30
/**
31
 * Class SubDomainInfoFactoryTest
32
 * @testdox RossMitchell\UpdateCloudFlare\Factories\Data\SubDomainInfoFactory
33
 * @package RossMitchell\UpdateCloudFlare\Tests\Factories\Data
34
 */
35
class SubDomainInfoFactoryTest extends AbstractTestClass
36
{
37
    /**
38
     * @Inject
39
     * @var SubDomainInfoFactory
40
     */
41
    private $factory;
42
43
    /**
44
     * @test
45
     */
46
    public function itCanCreateTheClass()
47
    {
48
        $class = $this->createClass();
49
        $this->assertInstanceOf(SubDomainInfo::class, $class);
50
    }
51
52
    /**
53
     * @test
54
     */
55
    public function itCanCreateAClassWhenGetIsCalled()
56
    {
57
        $class = $this->getClass();
58
        $this->assertInstanceOf(SubDomainInfo::class, $class);
59
    }
60
61
    /**
62
     * @test
63
     */
64
    public function callingGetWhenTheClassHasAlreadyBeenCreatedWillReturnIt()
65
    {
66
        $createdClass = $this->createClass();
67
        $gotClass = $this->getClass();
68
        $this->assertEquals($createdClass, $gotClass);
69
    }
70
71
    /**
72
     * @test
73
     */
74
    public function callingGetWhenTheClassHasNotAlreadyBeenCreatedWillReturnADifferentClass()
75
    {
76
        $createdClass = $this->createClass();
77
        $gotClass = $this->getClass('example');
78
        $this->assertNotEquals($createdClass, $gotClass);
79
    }
80
81
    /**
82
     * @param string $subDomain
83
     * @param string $type
84
     *
85
     * @return SubDomainInfo
86
     */
87
    private function createClass(string $subDomain = 'www', string $type = IpType::IP_V4): SubDomainInfo
88
    {
89
        return $this->factory->create($subDomain, $type);
90
    }
91
92
    /**
93
     * @param string $subDomain
94
     * @param string $type
95
     *
96
     * @return SubDomainInfo
97
     */
98
    private function getClass(string $subDomain = 'www', string $type = IpType::IP_V4): SubDomainInfo
99
    {
100
        return $this->factory->get($subDomain, $type);
101
    }
102
}
103