/** * @param int $qtyResult * @param int|null $expectedResult * @dataProvider processDataProvider */ public function testProcess($qtyResult, $expectedResult) { $qty = 10; $localCode = 'en_US'; $this->resolver->expects($this->once())->method('getLocale')->willReturn($localCode); $this->filter->expects($this->once())->method('setOptions')->with(['locale' => $localCode])->willReturnSelf(); $this->filter->expects($this->once())->method('filter')->with($qty)->willReturn($qtyResult); $this->assertEquals($expectedResult, $this->processor->process($qty)); }
/** * Process localized quantity to internal format * * @param float $qty * @return array|string */ public function process($qty) { $this->localFilter->setOptions(array('locale' => $this->localeResolver->getLocaleCode())); $qty = $this->localFilter->filter((double) $qty); if ($qty < 0) { $qty = null; } return $qty; }