[Translation][Profiler] fixed Collect empty Messages.
This commit is contained in:
parent
33ff623cb0
commit
e965e59920
@ -109,7 +109,7 @@ class TranslationDataCollector extends DataCollector implements LateDataCollecto
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
});
|
}, array());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function computeCount($messages)
|
private function computeCount($messages)
|
||||||
|
@ -22,6 +22,21 @@ class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->markTestSkipped('The "DataCollector" is not available');
|
$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()
|
public function testCollect()
|
||||||
{
|
{
|
||||||
$collectedMessages = array(
|
$collectedMessages = array(
|
||||||
@ -81,11 +96,7 @@ class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
$translator = $this
|
$translator = $this->getTranslator();
|
||||||
->getMockBuilder('Symfony\Component\Translation\DataCollectorTranslator')
|
|
||||||
->disableOriginalConstructor()
|
|
||||||
->getMock()
|
|
||||||
;
|
|
||||||
$translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages));
|
$translator->expects($this->any())->method('getCollectedMessages')->will($this->returnValue($collectedMessages));
|
||||||
|
|
||||||
$dataCollector = new TranslationDataCollector($translator);
|
$dataCollector = new TranslationDataCollector($translator);
|
||||||
@ -96,4 +107,15 @@ class TranslationDataCollectorTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals(1, $dataCollector->getCountDefines());
|
$this->assertEquals(1, $dataCollector->getCountDefines());
|
||||||
$this->assertEquals($expectedMessages, array_values($dataCollector->getMessages()));
|
$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