Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
LocaleQuantityProcessorTest.php
Go to the documentation of this file.
1 <?php
7 
8 use \Magento\Wishlist\Model\LocaleQuantityProcessor;
9 
10 class LocaleQuantityProcessorTest extends \PHPUnit\Framework\TestCase
11 {
15  protected $processor;
16 
20  protected $resolver;
21 
25  protected $filter;
26 
27  protected function setUp()
28  {
29  $this->resolver = $this->getMockBuilder(\Magento\Framework\Locale\ResolverInterface::class)->getMock();
30  $this->filter = $this->getMockBuilder(\Magento\Framework\Filter\LocalizedToNormalized::class)
31  ->disableOriginalConstructor()
32  ->getMock();
33  $this->processor = new LocaleQuantityProcessor($this->resolver, $this->filter);
34  }
35 
41  public function testProcess($qtyResult, $expectedResult)
42  {
43  $qty = 10;
44  $localCode = 'en_US';
45 
46  $this->resolver->expects($this->once())
47  ->method('getLocale')
48  ->willReturn($localCode);
49 
50  $this->filter->expects($this->once())
51  ->method('setOptions')
52  ->with(['locale' => $localCode])
53  ->willReturnSelf();
54 
55  $this->filter->expects($this->once())
56  ->method('filter')
57  ->with($qty)
58  ->willReturn($qtyResult);
59 
60  $this->assertEquals($expectedResult, $this->processor->process($qty));
61  }
62 
66  public function processDataProvider()
67  {
68  return [
69  'positive' => [10.00, 10.00],
70  'negative' => [0, null],
71  ];
72  }
73 }