Completed
Push — master ( a87692...4e64ba )
by Ruud
81:47 queued 68:42
created

Tests/unit/Helper/Validation/UrlValidatorTest.php (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Kunstmaan\NodeBundle\Tests\Helper;
4
5
use Kunstmaan\NodeBundle\Validation\URLValidator;
6
use PHPUnit\Framework\MockObject\MockObject;
7
use PHPUnit\Framework\TestCase;
8
9
class UrlValidatorTest extends TestCase
10
{
11
    /**
12
     * @var URLValidator|MockObject
13
     */
14
    private $validatorMock;
15
16
    protected function setUp()
17
    {
18
        $this->validatorMock = $this->getMockForTrait(URLValidator::class);
19
    }
20
21
    /**
22
     * @dataProvider emailAddressProvider
23
     */
24
    public function testIsEmailAddress($email, $result)
25
    {
26
        $this->assertSame($result, $this->validatorMock->isEmailAddress($email));
27
    }
28
29
    /**
30
     * @dataProvider internalLinkProvider
31
     */
32
    public function testIsInternalLink($link, $result)
33
    {
34
        $this->assertSame($result, $this->validatorMock->isInternalLink($link));
35
    }
36
37
    /**
38
     * @dataProvider internalMediaLinkProvider
39
     */
40
    public function testIsInternalMediaLink($link, $result)
41
    {
42
        $this->assertSame($result, $this->validatorMock->isInternalMediaLink($link));
43
    }
44
45
    public function emailAddressProvider()
46
    {
47
        return [
48
            ['abc', false],
49
            ['[email protected]', '[email protected]'],
50
            ['test@local', false],
51
        ];
52
    }
53
54 View Code Duplication
    public function internalLinkProvider()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
55
    {
56
        return [
57
            ['[NT:123]', false],
58
            ['[NT123]', true],
59
            ['[NTABC]', false],
60
            ['[NT123ABC]', false],
61
            ['[host_a:NT123]', true],
62
            ['http://www.google.com', false],
63
            ['[NT123][M20]', true],
64
        ];
65
    }
66
67 View Code Duplication
    public function internalMediaLinkProvider()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
68
    {
69
        return [
70
            ['[M:123]', false],
71
            ['[M123]', true],
72
            ['[MABC]', false],
73
            ['[M123ABC]', false],
74
            ['[host_a:M23]', true],
75
            ['http://www.google.com', false],
76
            ['[M123][NT20]', true],
77
        ];
78
    }
79
}
80