Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/differential/parser/__tests__/DifferentialCustomFieldRevertsParserTestCase.php
12262 views
1
<?php
2
3
final class DifferentialCustomFieldRevertsParserTestCase
4
extends PhabricatorTestCase {
5
6
public function testParser() {
7
$map = array(
8
'quack quack quack' => array(),
9
10
// Git default message.
11
'This reverts commit 1234abcd.' => array(
12
array(
13
'match' => 'reverts commit 1234abcd',
14
'prefix' => 'reverts',
15
'infix' => 'commit',
16
'monograms' => array('1234abcd'),
17
'suffix' => '',
18
'offset' => 5,
19
),
20
),
21
22
// Mercurial default message.
23
'Backed out changeset 1234abcd.' => array(
24
array(
25
'match' => 'Backed out changeset 1234abcd',
26
'prefix' => 'Backed out',
27
'infix' => 'changeset',
28
'monograms' => array('1234abcd'),
29
'suffix' => '',
30
'offset' => 0,
31
),
32
),
33
34
'this undoes 1234abcd, 5678efab. they were bad' => array(
35
array(
36
'match' => 'undoes 1234abcd, 5678efab',
37
'prefix' => 'undoes',
38
'infix' => '',
39
'monograms' => array('1234abcd', '5678efab'),
40
'suffix' => '',
41
'offset' => 5,
42
),
43
),
44
45
'Reverts 123' => array(
46
array(
47
'match' => 'Reverts 123',
48
'prefix' => 'Reverts',
49
'infix' => '',
50
'monograms' => array('123'),
51
'suffix' => '',
52
'offset' => 0,
53
),
54
),
55
56
57
'Reverts r123' => array(
58
array(
59
'match' => 'Reverts r123',
60
'prefix' => 'Reverts',
61
'infix' => '',
62
'monograms' => array('r123'),
63
'suffix' => '',
64
'offset' => 0,
65
),
66
),
67
68
"Backs out commit\n99\n100" => array(
69
array(
70
'match' => "Backs out commit\n99\n100",
71
'prefix' => 'Backs out',
72
'infix' => 'commit',
73
'monograms' => array('99', '100'),
74
'suffix' => '',
75
'offset' => 0,
76
),
77
),
78
79
// This tests a degenerate regex behavior, see T9268.
80
'Reverts aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaz' => array(),
81
82
"This doesn't revert anything" => array(),
83
'nonrevert of r11' => array(),
84
'fixed a bug' => array(),
85
);
86
87
foreach ($map as $input => $expect) {
88
$parser = new DifferentialCustomFieldRevertsParser();
89
$output = $parser->parseCorpus($input);
90
91
$this->assertEqual($expect, $output, $input);
92
}
93
}
94
95
}
96
97