/** * @test * @dataProvider sampleDataForSpecificFormattingMethods */ public function specificFormattingMethodsWork($number, array $parsedFormat, $expectedResult, $formatType, $currencySign = null) { $mockNumbersReader = $this->createMock(I18n\Cldr\Reader\NumbersReader::class); $mockNumbersReader->expects($this->once())->method('parseFormatFromCldr')->with($this->sampleLocale, $formatType, 'default')->will($this->returnValue($parsedFormat)); $mockNumbersReader->expects($this->once())->method('getLocalizedSymbolsForLocale')->with($this->sampleLocale)->will($this->returnValue($this->sampleLocalizedSymbols)); $formatter = new I18n\Formatter\NumberFormatter(); $formatter->injectNumbersReader($mockNumbersReader); if ($formatType === 'currency') { $result = $formatter->formatCurrencyNumber($number, $this->sampleLocale, $currencySign); } else { $methodName = 'format' . ucfirst($formatType) . 'Number'; $result = $formatter->{$methodName}($number, $this->sampleLocale); } $this->assertEquals($expectedResult, $result); }