@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class PhutilPygmentizeParserTestCase extends PhutilTestCase {
4
5 public function testPygmentizeParser() {
6 $this->tryParser(
7 '',
8 '',
9 array(),
10 pht('Empty'));
11
12 $this->tryParser(
13 '<span class="mi">1</span>',
14 '<span style="color: #ff0000">1</span>',
15 array(
16 'mi' => 'color: #ff0000',
17 ),
18 pht('Simple'));
19
20 $this->tryParser(
21 '<span class="mi">1</span>',
22 '<span class="mi">1</span>',
23 array(),
24 pht('Missing Class'));
25
26 $this->tryParser(
27 '<span data-symbol-name="X" class="nc">X</span>',
28 '<span data-symbol-name="X" style="color: #ff0000">X</span>',
29 array(
30 'nc' => 'color: #ff0000',
31 ),
32 pht('Extra Attribute'));
33 }
34
35 private function tryParser($input, $expect, array $map, $label) {
36 $actual = id(new PhutilPygmentizeParser())
37 ->setMap($map)
38 ->parse($input);
39
40 $this->assertEqual($expect, $actual, pht('Pygmentize Parser: %s', $label));
41 }
42
43}