Skip to content

Commit 4e8764f

Browse files
committed
Don't revere-merge heading in commit messages, when doing a straight merge with "summary" template (tests)
1 parent 42da227 commit 4e8764f

File tree

6 files changed

+172
-123
lines changed

6 files changed

+172
-123
lines changed

tests/SVNBuddy/Repository/CommitMessage/AbstractGroupByMergeTemplateTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
abstract class AbstractGroupByMergeTemplateTestCase extends AbstractMergeTemplateTestCase
1919
{
2020

21-
protected function prepareMergeResult()
21+
protected function prepareMergeResult($regular_or_reverse)
2222
{
2323
$this->connector
2424
->getRelativePath('svn://repository.com/path/to/project-name/tags/stable')
@@ -44,7 +44,7 @@ protected function prepareMergeResult()
4444
->getProjectUrl('/projects/another-project-name/trunk')
4545
->willReturn('/projects/another-project-name');
4646

47-
return parent::prepareMergeResult();
47+
return parent::prepareMergeResult($regular_or_reverse);
4848
}
4949

5050
}

tests/SVNBuddy/Repository/CommitMessage/AbstractMergeTemplateTestCase.php

Lines changed: 103 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -86,21 +86,112 @@ public function testApplyWithoutMergeChanges()
8686
$this->assertEmpty($this->mergeTemplate->apply('/path/to/working-copy'));
8787
}
8888

89-
abstract public function testApplyWithMergeChanges();
89+
abstract public function testApplyWithMergeChanges($regular_or_reverse);
9090

91-
protected function prepareMergeResult()
91+
public function applyWithMergeChangesDataProvider()
9292
{
93-
$this->connector->getMergedRevisionChanges('/path/to/working-copy', true)->willReturn(array(
94-
'/projects/project-name/trunk' => array('18', '33', '47'),
95-
'/projects/project-name/branches/branch-name' => array('4'),
96-
'/projects/another-project-name/tags/stable' => array('15'),
97-
'/projects/another-project-name/trunk' => array('17'),
98-
));
93+
return array(
94+
'merge' => array(true),
95+
'reverse-merge' => array(false),
96+
);
97+
}
9998

100-
$this->connector->getMergedRevisionChanges('/path/to/working-copy', false)->willReturn(array(
101-
'/projects/project-name/trunk' => array('95', '11'),
102-
'/projects/another-project-name/trunk' => array('112'),
103-
));
99+
protected function prepareMergeResult($regular_or_reverse)
100+
{
101+
$revision_log1 = $this->getRevisionLog('svn://repository.com/projects/project-name/trunk');
102+
$revision_log2 = $this->getRevisionLog('svn://repository.com/projects/project-name/branches/branch-name');
103+
$revision_log3 = $this->getRevisionLog('svn://repository.com/projects/another-project-name/tags/stable');
104+
$revision_log4 = $this->getRevisionLog('svn://repository.com/projects/another-project-name/trunk');
105+
106+
if ( $regular_or_reverse ) {
107+
// Merged revision information.
108+
$this->connector->getMergedRevisionChanges('/path/to/working-copy', true)->willReturn(array(
109+
'/projects/project-name/trunk' => array('18', '33', '47'),
110+
'/projects/project-name/branches/branch-name' => array('4'),
111+
'/projects/another-project-name/tags/stable' => array('15'),
112+
'/projects/another-project-name/trunk' => array('17'),
113+
));
114+
115+
$revision_log1->getRevisionsData('summary', array(18, 33, 47))->willReturn(array(
116+
18 => array(
117+
'author' => 'user1',
118+
'date' => 3534535353,
119+
'msg' => 'JRA-100 - own-tr1-line1' . PHP_EOL . 'own-tr1-line2' . PHP_EOL . PHP_EOL,
120+
),
121+
33 => array(
122+
'author' => 'user2',
123+
'date' => 35345445353,
124+
'msg' => 'JRA-120 - own-tr2-line1' . PHP_EOL . 'own-tr2-line2' . PHP_EOL . PHP_EOL,
125+
),
126+
47 => array(
127+
'author' => 'user3',
128+
'date' => 35345445353,
129+
'msg' => 'JRA-100 - own-tr3-line1' . PHP_EOL . 'own-tr3-line2' . PHP_EOL . PHP_EOL,
130+
),
131+
));
132+
133+
$revision_log2->getRevisionsData('summary', array(4))->willReturn(array(
134+
4 => array(
135+
'author' => 'user2',
136+
'date' => 35345444353,
137+
'msg' => 'own-br1-line1' . PHP_EOL . 'own-br1-line2' . PHP_EOL . PHP_EOL,
138+
),
139+
));
140+
141+
$revision_log3->getRevisionsData('summary', array(15))->willReturn(array(
142+
15 => array(
143+
'author' => 'user3',
144+
'date' => 35345444353,
145+
'msg' => 'another-st1-line1' . PHP_EOL . 'another-st1-line2' . PHP_EOL . PHP_EOL,
146+
),
147+
));
148+
149+
$revision_log4->getRevisionsData('summary', array(17))->willReturn(array(
150+
17 => array(
151+
'author' => 'user4',
152+
'date' => 35345444353,
153+
'msg' => 'another-tr1-line1' . PHP_EOL . 'another-tr1-line2' . PHP_EOL . PHP_EOL,
154+
),
155+
));
156+
157+
// Reverse-merged revision information.
158+
$this->connector->getMergedRevisionChanges('/path/to/working-copy', false)->willReturn(array(
159+
'/projects/project-name/trunk' => array(),
160+
));
161+
}
162+
else {
163+
// Merged revision information.
164+
$this->connector->getMergedRevisionChanges('/path/to/working-copy', true)->willReturn(array(
165+
'/projects/project-name/trunk' => array(),
166+
));
167+
168+
// Reverse-merged revision information.
169+
$this->connector->getMergedRevisionChanges('/path/to/working-copy', false)->willReturn(array(
170+
'/projects/project-name/trunk' => array('95', '11'),
171+
'/projects/another-project-name/trunk' => array('112'),
172+
));
173+
174+
$revision_log1->getRevisionsData('summary', array(95, 11))->willReturn(array(
175+
95 => array(
176+
'author' => 'user5',
177+
'date' => 3534535353,
178+
'msg' => 'JRA-100 - own-tr1-line1' . PHP_EOL . 'own-tr1-line2(r)' . PHP_EOL . PHP_EOL,
179+
),
180+
11 => array(
181+
'author' => 'user6',
182+
'date' => 35345445353,
183+
'msg' => 'JRA-100 - own-tr2-line1' . PHP_EOL . 'own-tr2-line2(r)' . PHP_EOL . PHP_EOL,
184+
),
185+
));
186+
187+
$revision_log4->getRevisionsData('summary', array(112))->willReturn(array(
188+
112 => array(
189+
'author' => 'user7',
190+
'date' => 35345444353,
191+
'msg' => 'another-tr1-line1' . PHP_EOL . 'another-tr1-line2(r)' . PHP_EOL . PHP_EOL,
192+
),
193+
));
194+
}
104195

105196
$this->connector
106197
->getWorkingCopyUrl('/path/to/working-copy')
@@ -110,75 +201,6 @@ protected function prepareMergeResult()
110201
->getRootUrl('svn://repository.com/path/to/project-name/tags/stable')
111202
->willReturn('svn://repository.com');
112203

113-
// Merged revision information.
114-
$revision_log1 = $this->getRevisionLog('svn://repository.com/projects/project-name/trunk');
115-
$revision_log1->getRevisionsData('summary', array(18, 33, 47))->willReturn(array(
116-
18 => array(
117-
'author' => 'user1',
118-
'date' => 3534535353,
119-
'msg' => 'JRA-100 - own-tr1-line1' . PHP_EOL . 'own-tr1-line2' . PHP_EOL . PHP_EOL,
120-
),
121-
33 => array(
122-
'author' => 'user2',
123-
'date' => 35345445353,
124-
'msg' => 'JRA-120 - own-tr2-line1' . PHP_EOL . 'own-tr2-line2' . PHP_EOL . PHP_EOL,
125-
),
126-
47 => array(
127-
'author' => 'user3',
128-
'date' => 35345445353,
129-
'msg' => 'JRA-100 - own-tr3-line1' . PHP_EOL . 'own-tr3-line2' . PHP_EOL . PHP_EOL,
130-
),
131-
));
132-
133-
$revision_log2 = $this->getRevisionLog('svn://repository.com/projects/project-name/branches/branch-name');
134-
$revision_log2->getRevisionsData('summary', array(4))->willReturn(array(
135-
4 => array(
136-
'author' => 'user2',
137-
'date' => 35345444353,
138-
'msg' => 'own-br1-line1' . PHP_EOL . 'own-br1-line2' . PHP_EOL . PHP_EOL,
139-
),
140-
));
141-
142-
$revision_log3 = $this->getRevisionLog('svn://repository.com/projects/another-project-name/tags/stable');
143-
$revision_log3->getRevisionsData('summary', array(15))->willReturn(array(
144-
15 => array(
145-
'author' => 'user3',
146-
'date' => 35345444353,
147-
'msg' => 'another-st1-line1' . PHP_EOL . 'another-st1-line2' . PHP_EOL . PHP_EOL,
148-
),
149-
));
150-
151-
$revision_log4 = $this->getRevisionLog('svn://repository.com/projects/another-project-name/trunk');
152-
$revision_log4->getRevisionsData('summary', array(17))->willReturn(array(
153-
17 => array(
154-
'author' => 'user4',
155-
'date' => 35345444353,
156-
'msg' => 'another-tr1-line1' . PHP_EOL . 'another-tr1-line2' . PHP_EOL . PHP_EOL,
157-
),
158-
));
159-
160-
// Reverse-merged revision information.
161-
$revision_log1->getRevisionsData('summary', array(95, 11))->willReturn(array(
162-
95 => array(
163-
'author' => 'user5',
164-
'date' => 3534535353,
165-
'msg' => 'JRA-100 - own-tr1-line1' . PHP_EOL . 'own-tr1-line2(r)' . PHP_EOL . PHP_EOL,
166-
),
167-
11 => array(
168-
'author' => 'user6',
169-
'date' => 35345445353,
170-
'msg' => 'JRA-100 - own-tr2-line1' . PHP_EOL . 'own-tr2-line2(r)' . PHP_EOL . PHP_EOL,
171-
),
172-
));
173-
174-
$revision_log4->getRevisionsData('summary', array(112))->willReturn(array(
175-
112 => array(
176-
'author' => 'user7',
177-
'date' => 35345444353,
178-
'msg' => 'another-tr1-line1' . PHP_EOL . 'another-tr1-line2(r)' . PHP_EOL . PHP_EOL,
179-
),
180-
));
181-
182204
return array($revision_log1, $revision_log2, $revision_log3, $revision_log4);
183205
}
184206

tests/SVNBuddy/Repository/CommitMessage/EmptyMergeTemplateTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,12 @@ public function testGetName()
2222
$this->assertEquals('empty', $this->mergeTemplate->getName());
2323
}
2424

25-
public function testApplyWithMergeChanges()
25+
/**
26+
* @dataProvider applyWithMergeChangesDataProvider
27+
*/
28+
public function testApplyWithMergeChanges($regular_or_reverse)
2629
{
27-
$this->prepareMergeResult();
30+
$this->prepareMergeResult($regular_or_reverse);
2831

2932
$this->assertEmpty($this->mergeTemplate->apply('/path/to/working-copy'));
3033
}

tests/SVNBuddy/Repository/CommitMessage/GroupByBugMergeTemplateTest.php

Lines changed: 38 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -22,36 +22,31 @@ public function testGetName()
2222
$this->assertEquals('group_by_bug', $this->mergeTemplate->getName());
2323
}
2424

25-
public function testApplyWithMergeChanges()
25+
/**
26+
* @dataProvider applyWithMergeChangesDataProvider
27+
*/
28+
public function testApplyWithMergeChanges($regular_or_reverse)
2629
{
27-
list ($revision_log1, $revision_log2, $revision_log3, $revision_log4) = $this->prepareMergeResult();
28-
29-
// Merged revision information.
30-
$revision_log1->getRevisionsData('bugs', array(18, 33, 47))->willReturn(array(
31-
18 => array('JRA-100'),
32-
33 => array('JRA-120'),
33-
47 => array('JRA-100'),
34-
));
35-
$revision_log2->getRevisionsData('bugs', array(4))->willReturn(array(
36-
4 => array(),
37-
));
38-
$revision_log3->getRevisionsData('bugs', array(15))->willReturn(array(
39-
15 => array(),
40-
));
41-
$revision_log4->getRevisionsData('bugs', array(17))->willReturn(array(
42-
17 => array(),
43-
));
44-
45-
// Reverse-merged revision information.
46-
$revision_log1->getRevisionsData('bugs', array(95, 11))->willReturn(array(
47-
95 => array('JRA-100'),
48-
11 => array('JRA-100'),
49-
));
50-
$revision_log4->getRevisionsData('bugs', array(112))->willReturn(array(
51-
112 => array(),
52-
));
53-
54-
$expected = <<<COMMIT_MSG
30+
list ($revision_log1, $revision_log2, $revision_log3, $revision_log4) = $this->prepareMergeResult($regular_or_reverse);
31+
32+
if ( $regular_or_reverse ) {
33+
// Merged revision information.
34+
$revision_log1->getRevisionsData('bugs', array(18, 33, 47))->willReturn(array(
35+
18 => array('JRA-100'),
36+
33 => array('JRA-120'),
37+
47 => array('JRA-100'),
38+
));
39+
$revision_log2->getRevisionsData('bugs', array(4))->willReturn(array(
40+
4 => array(),
41+
));
42+
$revision_log3->getRevisionsData('bugs', array(15))->willReturn(array(
43+
15 => array(),
44+
));
45+
$revision_log4->getRevisionsData('bugs', array(17))->willReturn(array(
46+
17 => array(),
47+
));
48+
49+
$expected = <<<COMMIT_MSG
5550
Merging from Trunk to Stable
5651
* JRA-100 - own-tr1-line1
5752
r18: own-tr1-line2
@@ -70,7 +65,19 @@ public function testApplyWithMergeChanges()
7065
Merge (trunk (another-project-name) > stable): Revisions without Bug IDs:
7166
* r17: another-tr1-line1
7267
another-tr1-line2
73-
68+
COMMIT_MSG;
69+
}
70+
else {
71+
// Reverse-merged revision information.
72+
$revision_log1->getRevisionsData('bugs', array(95, 11))->willReturn(array(
73+
95 => array('JRA-100'),
74+
11 => array('JRA-100'),
75+
));
76+
$revision_log4->getRevisionsData('bugs', array(112))->willReturn(array(
77+
112 => array(),
78+
));
79+
80+
$expected = <<<COMMIT_MSG
7481
Reverse-merge (trunk > stable): * JRA-100 - own-tr1-line1
7582
r95: own-tr1-line2(r)
7683
r11: own-tr2-line2(r)
@@ -79,6 +86,7 @@ public function testApplyWithMergeChanges()
7986
* r112: another-tr1-line1
8087
another-tr1-line2(r)
8188
COMMIT_MSG;
89+
}
8290

8391
$this->assertEquals($expected, $this->mergeTemplate->apply('/path/to/working-copy'));
8492
}

tests/SVNBuddy/Repository/CommitMessage/GroupByRevisionMergeTemplateTest.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,15 @@ public function testGetName()
2222
$this->assertEquals('group_by_revision', $this->mergeTemplate->getName());
2323
}
2424

25-
public function testApplyWithMergeChanges()
25+
/**
26+
* @dataProvider applyWithMergeChangesDataProvider
27+
*/
28+
public function testApplyWithMergeChanges($regular_or_reverse)
2629
{
27-
$this->prepareMergeResult();
30+
$this->prepareMergeResult($regular_or_reverse);
2831

29-
$expected = <<<COMMIT_MSG
32+
if ( $regular_or_reverse ) {
33+
$expected = <<<COMMIT_MSG
3034
Merging from Trunk to Stable
3135
* r18: JRA-100 - own-tr1-line1
3236
own-tr1-line2
@@ -43,7 +47,10 @@ public function testApplyWithMergeChanges()
4347
4448
Merge (trunk (another-project-name) > stable): * r17: another-tr1-line1
4549
another-tr1-line2
46-
50+
COMMIT_MSG;
51+
}
52+
else {
53+
$expected = <<<COMMIT_MSG
4754
Reverse-merging from Trunk to Stable
4855
* r95: JRA-100 - own-tr1-line1
4956
own-tr1-line2(r)
@@ -53,6 +60,7 @@ public function testApplyWithMergeChanges()
5360
Reverse-merge (trunk (another-project-name) > stable): * r112: another-tr1-line1
5461
another-tr1-line2(r)
5562
COMMIT_MSG;
63+
}
5664

5765
$this->assertEquals($expected, $this->mergeTemplate->apply('/path/to/working-copy'));
5866
}

0 commit comments

Comments
 (0)