Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/diffusion/remarkup/__tests__/DiffusionCommitRemarkupRuleTestCase.php
13409 views
1
<?php
2
3
final class DiffusionCommitRemarkupRuleTestCase extends PhabricatorTestCase {
4
5
public function testProjectObjectRemarkup() {
6
$cases = array(
7
'{rP12f3f6d3a9ef9c7731051815846810cb3c4cd248}' => array(
8
'embed' => array(
9
array(
10
'offset' => 1,
11
'id' => 'rP12f3f6d3a9ef9c7731051815846810cb3c4cd248',
12
),
13
),
14
'ref' => array(
15
array(
16
'offset' => 1,
17
'id' => 'rP12f3f6d3a9ef9c7731051815846810cb3c4cd248',
18
),
19
),
20
),
21
'{rP1234, key=value}' => array(
22
'embed' => array(
23
array(
24
'offset' => 1,
25
'id' => 'rP1234',
26
'tail' => ', key=value',
27
),
28
),
29
'ref' => array(
30
array(
31
'offset' => 1,
32
'id' => 'rP1234',
33
),
34
),
35
),
36
'{rP1234 key=value}' => array(
37
'embed' => array(
38
array(
39
'offset' => 1,
40
'id' => 'rP1234',
41
'tail' => ' key=value',
42
),
43
),
44
'ref' => array(
45
array(
46
'offset' => 1,
47
'id' => 'rP1234',
48
),
49
),
50
),
51
'{rP:1234 key=value}' => array(
52
'embed' => array(
53
array(
54
'offset' => 1,
55
'id' => 'rP:1234',
56
'tail' => ' key=value',
57
),
58
),
59
'ref' => array(
60
array(
61
'offset' => 1,
62
'id' => 'rP:1234',
63
),
64
),
65
),
66
'{R123:1234 key=value}' => array(
67
'embed' => array(
68
array(
69
'offset' => 1,
70
'id' => 'R123:1234',
71
'tail' => ' key=value',
72
),
73
),
74
'ref' => array(
75
array(
76
'offset' => 1,
77
'id' => 'R123:1234',
78
),
79
),
80
),
81
'{rP:12f3f6d3a9ef9c7731051815846810cb3c4cd248}' => array(
82
'embed' => array(
83
array(
84
'offset' => 1,
85
'id' => 'rP:12f3f6d3a9ef9c7731051815846810cb3c4cd248',
86
),
87
),
88
'ref' => array(
89
array(
90
'offset' => 1,
91
'id' => 'rP:12f3f6d3a9ef9c7731051815846810cb3c4cd248',
92
),
93
),
94
),
95
'{R123:12f3f6d3a9ef9c7731051815846810cb3c4cd248}' => array(
96
'embed' => array(
97
array(
98
'offset' => 1,
99
'id' => 'R123:12f3f6d3a9ef9c7731051815846810cb3c4cd248',
100
),
101
),
102
'ref' => array(
103
array(
104
'offset' => 1,
105
'id' => 'R123:12f3f6d3a9ef9c7731051815846810cb3c4cd248',
106
),
107
),
108
),
109
'{R123:12f3f6d3a9ef9c7731051815846810cb3c4cd248, key=value}' => array(
110
'embed' => array(
111
array(
112
'offset' => 1,
113
'id' => 'R123:12f3f6d3a9ef9c7731051815846810cb3c4cd248',
114
'tail' => ', key=value',
115
),
116
),
117
'ref' => array(
118
array(
119
'offset' => 1,
120
'id' => 'R123:12f3f6d3a9ef9c7731051815846810cb3c4cd248',
121
),
122
),
123
),
124
125
// After an "@", we should not be recognizing references because these
126
// are username mentions.
127
'deadbeef' => array(
128
'embed' => array(
129
),
130
'ref' => array(
131
array(
132
'offset' => 0,
133
'id' => 'deadbeef',
134
),
135
),
136
),
137
'@deadbeef' => array(
138
'embed' => array(
139
),
140
'ref' => array(
141
),
142
),
143
);
144
145
foreach ($cases as $input => $expect) {
146
$rule = new DiffusionCommitRemarkupRule();
147
$matches = $rule->extractReferences($input);
148
$this->assertEqual($expect, $matches, $input);
149
}
150
}
151
152
}
153
154