Skip to content

Commit 25d1a80

Browse files
committed
test: fix highlighter test
1 parent 32aa562 commit 25d1a80

2 files changed

Lines changed: 20 additions & 13 deletions

File tree

tests/HighlighterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ public function testHighlightCode()
2020
{
2121
$code = (new Highlighter)->highlight('<?php echo "Hello world!";');
2222

23-
$this->assertSame(
24-
'[0;32;40m<?php [0m[0;36;40mecho [0m[0;33;40m"Hello world!"[0m[0;36;40m;[0m',
23+
$this->assertContains(
24+
'[0;32;40m<?php [0m[0;31;40mecho [0m[0;33;40m"Hello world!"[0m[0;31;40m;[0m',
2525
$code
2626
);
2727
}

tests/example.phps

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
[0m[1;30;40m/*
3+
[0m[0;34;40m/*
44
 * This file is part of the CLI-SYNTAX package.
55
 *
66
 * (c) Jitendra Adhikari <jiten.adhikary@gmail.com>
@@ -9,17 +9,24 @@
99
 * Licensed under MIT license.
1010
 */
1111

12-
use Ahc\CliSyntax\Highlighter;
12+
use Ahc\CliSyntax\Exporter;
13+
use Ahc\CliSyntax\Highlighter;
1314

14-
require_once __DIR__ . '/src/Highlighter.php';
15+
require_once __DIR__ . '/src/Pretty.php';
16+
require_once __DIR__ . '/src/Exporter.php';
17+
require_once __DIR__ . '/src/Highlighter.php';
1518

16-
// Highlight code
17-
echo (new Highlighter("<?php echo 'Hello world!'?>\n"))->highlight();
19+
// Highlight code
20+
echo (new Highlighter("<?php echo 'Hello world!'?>" . PHP_EOL))
21+
    ->highlight();
1822

19-
[0m[1;30;40m// Highlight file
20-
[0m[0;36;40mecho [0m[0;32;40mHighlighter[0m[0;36;40m::for([0m[0;32;40m__FILE__[0m[0;36;40m)->[0m[0;32;40mhighlight[0m[0;36;40m();
23+
[0m[0;34;40m// Highlight file
24+
[0m[0;31;40mecho [0m[0;32;40mHighlighter[0m[0;31;40m::for([0m[0;32;40m__FILE__[0m[0;31;40m)->[0m[0;32;40mhighlight[0m[0;31;40m();
2125

22-
// Magic string works too:
23-
// echo new Highlighter('<?php echo "Hello world!";');
24-
// echo Highlighter::for(__FILE__);
25-

26+
// Export highlighted file as image
27+
Exporter::for(__FILE__)->export(__DIR__ . '/example.png');
28+
29+
// Magic string works too:
30+
echo new Highlighter('<?php echo "Hello Again!";' . PHP_EOL);
31+
// echo Highlighter::for(__FILE__);
32+


0 commit comments

Comments
 (0)