Passed
Push — main ( b1fbff...0e72dc )
by Johny
02:35
created

InternetTest   A

Complexity

Total Complexity 19

Size/Duplication

Total Lines 105
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 19
eloc 31
dl 0
loc 105
c 0
b 0
f 0
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace DummyGenerator\Test\Extension;
6
7
use DummyGenerator\Container\DefinitionContainer;
8
use DummyGenerator\Core\Internet;
9
use DummyGenerator\Core\Lorem;
10
use DummyGenerator\Core\Person;
11
use DummyGenerator\Definitions\Extension\InternetExtensionInterface;
12
use DummyGenerator\Definitions\Extension\LoremExtensionInterface;
13
use DummyGenerator\Definitions\Extension\PersonExtensionInterface;
14
use DummyGenerator\Definitions\Randomizer\RandomizerInterface;
15
use DummyGenerator\Definitions\Replacer\ReplacerInterface;
16
use DummyGenerator\Definitions\Transliterator\TransliteratorInterface;
17
use DummyGenerator\DummyGenerator;
18
use DummyGenerator\Core\Randomizer\Randomizer;
19
use DummyGenerator\Core\Replacer\Replacer;
20
use DummyGenerator\Core\Transliterator\Transliterator;
21
use PHPUnit\Framework\TestCase;
22
23
class InternetTest extends TestCase
24
{
25
    private DummyGenerator $generator;
26
27
    public function setUp(): void
28
    {
29
        parent::setUp();
30
31
        $container = new DefinitionContainer([]);
32
        $container->add(RandomizerInterface::class, Randomizer::class);
33
        $container->add(TransliteratorInterface::class, Transliterator::class);
34
        $container->add(ReplacerInterface::class, Replacer::class);
35
        $container->add(PersonExtensionInterface::class, Person::class);
36
        $container->add(LoremExtensionInterface::class, Lorem::class);
37
        $container->add(InternetExtensionInterface::class, Internet::class);
38
        $this->generator = new DummyGenerator($container);
39
    }
40
41
    public function testEmail(): void
42
    {
43
        self::assertStringContainsString('@', $this->generator->email());
44
    }
45
46
    public function testSafeEmail(): void
47
    {
48
        self::assertStringContainsString('@', $this->generator->safeEmail());
49
    }
50
51
    public function testFreeEmail(): void
52
    {
53
        self::assertStringContainsString('@', $this->generator->freeEmail());
54
    }
55
56
    public function testCompanyEmail(): void
57
    {
58
        self::assertStringContainsString('@', $this->generator->companyEmail());
59
    }
60
61
    public function testFreeEmailDomain(): void
62
    {
63
        self::assertStringContainsString('.', $this->generator->companyEmail());
64
    }
65
66
    public function testSafeEmailDomain(): void
67
    {
68
        self::assertStringContainsString('.', $this->generator->safeEmailDomain());
69
        self::assertStringContainsString('example', $this->generator->safeEmailDomain());
70
    }
71
72
    public function testUsername(): void
73
    {
74
        self::assertNotEmpty($this->generator->userName());
75
    }
76
77
    public function testPassword(): void
78
    {
79
        $length = strlen($this->generator->password(minLength: 3, maxLength: 8));
80
81
        self::assertTrue($length >= 3 && $length <= 8);
82
    }
83
84
    public function testDomainName(): void
85
    {
86
        self::assertStringContainsString('.', $this->generator->domainName());
87
    }
88
89
    public function testDomainWord(): void
90
    {
91
        self::assertNotEmpty($this->generator->domainWord());
92
    }
93
94
    public function testTld(): void
95
    {
96
        self::assertNotEmpty($this->generator->tld());
97
    }
98
99
    public function testUrl(): void
100
    {
101
        self::assertStringStartsWith('http', $this->generator->url());
102
        self::assertStringContainsString('://', $this->generator->url());
103
    }
104
105
    public function testSlug(): void
106
    {
107
        self::assertCount(5, explode('-', $this->generator->slug(nbWords: 5, variableNbWords: false)));
108
    }
109
110
    public function testIPv4(): void
111
    {
112
        self::assertNotEmpty($this->generator->ipv4());
113
    }
114
115
    public function testIPv6(): void
116
    {
117
        self::assertNotEmpty($this->generator->ipv6());
118
    }
119
120
    public function testLocalIPv4(): void
121
    {
122
        self::assertNotEmpty($this->generator->localIpv4());
123
    }
124
125
    public function testMacAddress(): void
126
    {
127
        self::assertCount(6, explode(':', $this->generator->macAddress()));
128
    }
129
130
}
131