File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 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+ '[0;32;40m<?php [0m[0;36;40mecho [0m[0;33;40m"Hello world!"[0m[0;36;40m;[0m ' ,
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+ }
You can’t perform that action at this time.
0 commit comments