Completed
Push — master ( fc84c5...f8f0da )
by Razon
02:54
created

UrlValidatorTest::testValidateValue()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
nc 2
nop 3
dl 0
loc 11
rs 9.9666
c 1
b 0
f 0
1
<?php
2
namespace App\Tests\Unit\Validator;
3
4
use App\Validator\UrlValidator;
5
use Codeception\Test\Unit;
6
7
class UrlValidatorTest extends Unit
8
{
9
    /**
10
     * @dataProvider dataProviderUrl
11
     */
12
    public function testValidateValue(string $url, bool $valid, array $config = []): void
13
    {
14
        $validator = new UrlValidator($config);
15
        $method = new \ReflectionMethod(UrlValidator::class, 'validateValue');
16
        $method->setAccessible(true);
17
        $result = $method->invoke($validator, $url);
18
        if ($valid) {
19
            $this->assertNull($result);
20
        } else {
21
            $this->assertTrue(is_array($result));
22
            $this->assertCount(2, $result);
23
        }
24
    }
25
26
    public function dataProviderUrl(): array
27
    {
28
        return [
29
            ['http://localhost', true],
30
            ['http://localhost:8080', true],
31
            ['localhost:8080', false],
32
            ['ftp://localhost:8080', false],
33
        ];
34
    }
35
}
36