testExceptionIsThrownIfInvalidTypesSpecified()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
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