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.
This commit is contained in:
commit
4d1344c6a9
@ -109,7 +109,7 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
|
||||
}
|
||||
|
||||
return $result;
|
||||
});
|
||||
}, array());
|
||||
}
|
||||
|
||||
private function computeCount($messages)
|
||||
|
@ -22,6 +22,21 @@ class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->markTestSkipped('The "DataCollector" is not available');
|
||||
}
|
||||
}
|
||||
|
||||
public function testCollectEmptyMessages()
|
||||
{
|
||||
$translator = $this->getTranslator();
|
||||
$translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue(array()));
|
||||
|
||||
$dataCollector = new TranslationDataCollector($translator);
|
||||
$dataCollector->lateCollect();
|
||||
|
||||
$this->assertEquals(0, $dataCollector->getCountMissings());
|
||||
$this->assertEquals(0, $dataCollector->getCountFallbacks());
|
||||
$this->assertEquals(0, $dataCollector->getCountDefines());
|
||||
$this->assertEquals(array(), $dataCollector->getMessages());
|
||||
}
|
||||
|
||||
public function testCollect()
|
||||
{
|
||||
$collectedMessages = array(
|
||||
@ -81,11 +96,7 @@ class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
),
|
||||
);
|
||||
|
||||
$translator = $this
|
||||
->getMockBuilder('Symfony\Component\Translation\DataCollectorTranslator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
$translator = $this->getTranslator();
|
||||
$translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages));
|
||||
|
||||
$dataCollector = new TranslationDataCollector($translator);
|
||||
@ -96,4 +107,15 @@ class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals(1, $dataCollector->getCountDefines());
|
||||
$this->assertEquals($expectedMessages, array_values($dataCollector->getMessages()));
|
||||
}
|
||||
|
||||
private function getTranslator()
|
||||
{
|
||||
$translator = $this
|
||||
->getMockBuilder('Symfony\Component\Translation\DataCollectorTranslator')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
return $translator;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user