@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 PhabricatorAnchorTestCase
4 extends PhabricatorTestCase {
5
6 public function testAnchors() {
7
8 $low_ascii = '';
9 for ($ii = 19; $ii <= 127; $ii++) {
10 $low_ascii .= chr($ii);
11 }
12
13 $snowman = "\xE2\x9B\x84";
14
15 $map = array(
16 '' => '',
17 'Bells and Whistles' => 'bells-and-whistles',
18 'Termination for Nonpayment' => 'termination-for-nonpayment',
19 $low_ascii => '0123456789-abcdefghijklmnopqrstu',
20 'xxxx xxxx xxxx xxxx xxxx on' => 'xxxx-xxxx-xxxx-xxxx-xxxx',
21 'xxxx xxxx xxxx xxxx xxxx ox' => 'xxxx-xxxx-xxxx-xxxx-xxxx-ox',
22 "So, You Want To Build A {$snowman}?" =>
23 "so-you-want-to-build-a-{$snowman}",
24 str_repeat($snowman, 128) => str_repeat($snowman, 32),
25 );
26
27 foreach ($map as $input => $expect) {
28 $anchor = PhutilRemarkupHeaderBlockRule::getAnchorNameFromHeaderText(
29 $input);
30
31 $this->assertEqual(
32 $expect,
33 $anchor,
34 pht('Anchor for "%s".', $input));
35 }
36 }
37
38}