@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 HeraldTranscriptTestCase extends PhabricatorTestCase {
4
5 public function testTranscriptTruncation() {
6 $long_string = str_repeat('x', 1024 * 1024);
7 $short_string = str_repeat('x', 4096)."\n<...>";
8
9 $long_array = array(
10 'a' => $long_string,
11 'b' => $long_string,
12 );
13
14 $mixed_array = array(
15 'a' => 'abc',
16 'b' => 'def',
17 'c' => $long_string,
18 );
19
20 $fields = array(
21 'ls' => $long_string,
22 'la' => $long_array,
23 'ma' => $mixed_array,
24 );
25
26 $truncated_fields = id(new HeraldObjectTranscript())
27 ->setFields($fields)
28 ->getFields();
29
30 $this->assertEqual($short_string, $truncated_fields['ls']);
31
32 $this->assertEqual(
33 array('a', '<...>'),
34 array_keys($truncated_fields['la']));
35 $this->assertEqual(
36 $short_string.'!<...>',
37 implode('!', $truncated_fields['la']));
38
39 $this->assertEqual(
40 array('a', 'b', 'c'),
41 array_keys($truncated_fields['ma']));
42 $this->assertEqual(
43 'abc!def!'.substr($short_string, 6),
44 implode('!', $truncated_fields['ma']));
45
46 }
47}