Skip to content

Commit 805512b

Browse files
committed
test: add highlighter test
1 parent 53aeb8b commit 805512b

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/HighlighterTest.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Ahc\CliSyntax\Test;
4+
5+
use Ahc\CliSyntax\Highlighter;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class HighlighterTest extends TestCase
9+
{
10+
public function testHighlightCode()
11+
{
12+
$code = (new Highlighter)->highlight('<?php echo "Hello world!";');
13+
14+
$this->assertSame(
15+
'<?php echo "Hello world!";',
16+
$code
17+
);
18+
}
19+
20+
public function testHighlightFile()
21+
{
22+
$code = Highlighter::for(__DIR__ . '/../example.php')->highlight();
23+
24+
$this->assertSame(\file_get_contents(__DIR__ . '/example.phps'), $code);
25+
}
26+
27+
/**
28+
* @expectedException \InvalidArgumentException
29+
* @expectedExceptionMessage The given file doesnot exist or is unreadable.
30+
*/
31+
public function testHighlightFileThrows()
32+
{
33+
Highlighter::for(__DIR__ . '/' . rand());
34+
}
35+
}

0 commit comments

Comments
 (0)