SyntaxHighlighterConfigTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 32
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testExceptionIsThrownIfInvalidTypesSpecified() 0 8 1
A testExceptionIsThrownIfNotSupportedColourIsSpecified() 0 8 1
A testGetColourForType() 0 5 1
A testGetColourByTypeWhichDoesNotExistReturnsDefault() 0 5 1
1
<?php
2
3
namespace PhpSchool\PSXTest;
4
5
use InvalidArgumentException;
6
use PhpSchool\PSX\SyntaxHighlighterConfig;
7
use PHPUnit_Framework_TestCase;
8
9
/**
10
 * Class SyntaxHighlighterConfigTest
11
 * @package PhpSchool\PSXTest
12
 * @author Aydin Hassan <[email protected]>
13
 */
14
class SyntaxHighlighterConfigTest extends PHPUnit_Framework_TestCase
15
{
16
    public function testExceptionIsThrownIfInvalidTypesSpecified()
17
    {
18
        $this->setExpectedException(
19
            InvalidArgumentException::class,
20
            'Types: "type1", "type2" are not supported'
21
        );
22
        new SyntaxHighlighterConfig(['type1' => 'black', 'type2' => 'black']);
23
    }
24
25
    public function testExceptionIsThrownIfNotSupportedColourIsSpecified()
26
    {
27
        $this->setExpectedException(
28
            InvalidArgumentException::class,
29
            'Colour: "notacolour" is not valid. Check: "PhpSchool\PSX\Colours"'
30
        );
31
        new SyntaxHighlighterConfig([SyntaxHighlighterConfig::TYPE_KEYWORD => 'notacolour']);
32
    }
33
34
    public function testGetColourForType()
35
    {
36
        $config = new SyntaxHighlighterConfig;
37
        $this->assertEquals('blue', $config->getColorForType(SyntaxHighlighterConfig::TYPE_KEYWORD));
38
    }
39
40
    public function testGetColourByTypeWhichDoesNotExistReturnsDefault()
41
    {
42
        $config = new SyntaxHighlighterConfig;
43
        $this->assertEquals('default', $config->getColorForType('lol-nope'));
44
    }
45
}
46