Пример #1
0
 /**
  * @param $configValue
  * @param $customerGroupId
  * @param $groupData
  * @param $expected
  * @dataProvider getListDataProvider
  */
 public function testGetList($configValue, $customerGroupId, $groupData, $expected)
 {
     $this->repositoryMock->expects($this->once())->method('get')->with('product_sku')->will($this->returnValue($this->productMock));
     $this->productMock->expects($this->once())->method('getData')->with('tier_price')->will($this->returnValue([$groupData]));
     $this->configMock->expects($this->once())->method('getValue')->with('catalog/price/scope', \Magento\Framework\Store\ScopeInterface::SCOPE_WEBSITE)->will($this->returnValue($configValue));
     if ($expected) {
         $this->priceBuilderMock->expects($this->once())->method('populateWithArray')->with($expected);
         $this->priceBuilderMock->expects($this->once())->method('create')->will($this->returnValue('data'));
     } else {
         $this->priceBuilderMock->expects($this->never())->method('populateWithArray');
     }
     $prices = $this->service->getList('product_sku', $customerGroupId);
     $this->assertCount($expected ? 1 : 0, $prices);
     if ($expected) {
         $this->assertEquals('data', $prices[0]);
     }
 }
 /**
  * @param $configValue
  * @param $customerGroupId
  * @param $groupData
  * @param $expected
  * @dataProvider getListDataProvider
  */
 public function testGetList($configValue, $customerGroupId, $groupData, $expected)
 {
     $this->repositoryMock->expects($this->once())->method('get')->with('product_sku')->will($this->returnValue($this->productMock));
     $this->productMock->expects($this->once())->method('getData')->with('tier_price')->will($this->returnValue([$groupData]));
     $this->configMock->expects($this->once())->method('getValue')->with('catalog/price/scope', \Magento\Store\Model\ScopeInterface::SCOPE_WEBSITE)->will($this->returnValue($configValue));
     if ($expected) {
         $priceMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductTierPriceInterface');
         $priceMock->expects($this->once())->method('setValue')->with($expected['value'])->willReturnSelf();
         $priceMock->expects($this->once())->method('setQty')->with($expected['qty'])->willReturnSelf();
         $this->priceFactoryMock->expects($this->once())->method('create')->will($this->returnValue($priceMock));
     } else {
         $this->priceFactoryMock->expects($this->never())->method('create');
     }
     $prices = $this->service->getList('product_sku', $customerGroupId);
     $this->assertCount($expected ? 1 : 0, $prices);
     if ($expected) {
         $this->assertEquals($priceMock, $prices[0]);
     }
 }