8000 bug #14210 [Translation][Profiler] fixed Collect empty Messages. (ait… · symfony/symfony@4d1344c · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d1344c

Browse files
committed
bug #14210 [Translation][Profiler] fixed Collect empty Messages. (aitboudad)
This PR was merged into the 2.7 branch. Discussion ---------- [Translation][Profiler] fixed Collect empty Messages. | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Fixed tickets | #14209 | Tests pass? | yes | License | MIT Commits ------- e965e59 [Translation][Profiler] fixed Collect empty Messages.
2 parents 33ff623 + e965e59 commit 4d1344c

File tree

2 files changed

+28
-6
lines changed

2 files changed

+28
-6
lines changed

src/Symfony/Component/Translation/DataCollector/TranslationDataCollector.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ private function sanitizeCollectedMessages($messages)
109109
}
110110

111111
return $result;
112-
});
112+
}, array());
113113
}
114114

115115
private function computeCount($messages)

src/Symfony/Component/Translation/Tests/DataCollector/TranslationDataCollectorTest.php

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,21 @@ protected function setUp()
2222
$this->markTestSkipped('The "DataCollector" is not available');
2323
}
2424
}
25+
26+
public function testCollectEmptyMessages()
27+
{
28+
$translator = $this->getTranslator();
29+
$translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue(array()));
30+
31+
$dataCollector = new TranslationDataCollector($translator);
32+
$dataCollector->lateCollect();
33+
34+
$this->assertEquals(0, $dataCollector->getCountMissings());
35+
$this->assertEquals(0, $dataCollector->getCountFallbacks());
36+
$this->assertEquals(0, $dataCollector->getCountDefines());
37+
$this->assertEquals(array(), $dataCollector->getMessages());
38+
}
39+
2540
public function testCollect()
2641
{
2742
$collectedMessages = array(
@@ -81,11 +96,7 @@ public function testCollect()
8196
),
8297
);
8398

84-
$translator = $this
85-
->getMockBuilder('Symfony\Component\Translation\DataCollectorTranslator')
86-
->disableOriginalConstructor()
87-
->getMock()
88-
;
99+
$translator = $this->getTranslator();
89100
$translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages));
90101

91102
$dataCollector = new TranslationDataCollector($translator);
@@ -96,4 +107,15 @@ public function testCollect()
96107
$this->assertEquals(1, $dataCollector->getCountDefines());
97108
$this->assertEquals($expectedMessages, array_values($dataCollector->getMessages()));
98109
}
110+
111+
private function getTranslator()
112+
{
113+
$translator = $this
114+
->getMockBuilder('Symfony\Component\Translation\DataCollectorTranslator')
115+
->disableOriginalConstructor()
116+
->getMock()
117+
;
118+
119+
return $translator;
120+
}
99121
}

0 commit comments

Comments
 (0)
0