/** * @test * @expectedException \TYPO3\Fluid\Core\ViewHelper\Exception */ public function viewHelperConvertsI18nExceptionsIntoViewHelperExceptions() { $localizationConfiguration = new \TYPO3\Flow\I18n\Configuration('de_DE'); $mockLocalizationService = $this->getMockBuilder(\TYPO3\Flow\I18n\Service::class)->setMethods(array('getConfiguration'))->getMock(); $mockLocalizationService->expects($this->once())->method('getConfiguration')->will($this->returnValue($localizationConfiguration)); $this->inject($this->viewHelper, 'localizationService', $mockLocalizationService); $mockNumberFormatter = $this->getMockBuilder(\TYPO3\Flow\I18n\Formatter\NumberFormatter::class)->setMethods(array('formatDecimalNumber'))->getMock(); $mockNumberFormatter->expects($this->once())->method('formatDecimalNumber')->will($this->throwException(new \TYPO3\Flow\I18n\Exception())); $this->inject($this->viewHelper, 'numberFormatter', $mockNumberFormatter); $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue(123.456)); $this->viewHelper->setArguments(array('forceLocale' => true)); $this->viewHelper->render(); }
/** * @test */ public function renderUsesChildNodesIfValueArgumentIsOmitted() { $this->viewHelper->expects($this->once())->method('renderChildren')->will($this->returnValue(12345)); $actualResult = $this->viewHelper->render(); $this->assertEquals('12 KB', $actualResult); }