|
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
|
|
|
|