Completed
Push — master ( f88f6e...5d85cb )
by Pavel
03:14
created

AbstractNormalizerTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 42
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testValidObjectNormalization() 0 7 1
A testUnsupportedNormalizerThrowsException() 0 13 2
getValidSubjects() 0 1 ?
getInvalidSubjects() 0 1 ?
createNormalizer() 0 1 ?
1
<?php
2
3
namespace Bankiru\Seo\Tests\Unit\Normalizer;
4
5
use Bankiru\Seo\Destination\DestinationNormalizer;
6
use Bankiru\Seo\Exception\DestinationException;
7
8
abstract class AbstractNormalizerTest extends \PHPUnit_Framework_TestCase
9
{
10
    /**
11
     * @dataProvider getValidSubjects
12
     *
13
     * @param string $expected
14
     * @param mixed  $subject
15
     */
16
    public function testValidObjectNormalization($expected, $subject)
17
    {
18
        $normalizer = $this->createNormalizer();
19
20
        self::assertTrue($normalizer->supports($subject));
21
        self::assertEquals($expected, $normalizer->normalize($subject));
22
    }
23
24
    /**
25
     * @dataProvider getInvalidSubjects
26
     *
27
     * @param mixed $subject
28
     */
29
    public function testUnsupportedNormalizerThrowsException($subject)
30
    {
31
        $normalizer = $this->createNormalizer();
32
        self::assertFalse($normalizer->supports($subject));
33
34
        try {
35
            $normalizer->normalize($subject);
36
        } catch (DestinationException $exception) {
37
            return;
38
        }
39
40
        self::fail('DestinationException is not thrown on invalid normalization');
41
    }
42
43
    abstract public function getValidSubjects();
44
45
    abstract public function getInvalidSubjects();
46
47
    /** @return DestinationNormalizer */
48
    abstract protected function createNormalizer();
49
}
50