/** * @param string $configValue * @param array $groupData * @param array $expected * @dataProvider getListDataProvider */ public function testGetList($configValue, $groupData, $expected) { $this->productRepositoryMock->expects($this->once())->method('get')->with('product_sku', true)->will($this->returnValue($this->productMock)); $this->productMock->expects($this->once())->method('getData')->with('group_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)); $this->priceBuilderMock->expects($this->once())->method('populateWithArray')->with($expected); $this->priceBuilderMock->expects($this->once())->method('create')->will($this->returnValue('data')); $prices = $this->groupPriceManagement->getList('product_sku'); $this->assertCount(1, $prices); $this->assertEquals('data', $prices[0]); }
/** * @param string $configValue * @param array $groupData * @param array $expected * @dataProvider getListDataProvider */ public function testGetList($configValue, $groupData, $expected) { $this->productRepositoryMock->expects($this->once())->method('get')->with('product_sku', true)->will($this->returnValue($this->productMock)); $this->productMock->expects($this->once())->method('getData')->with('group_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)); $priceMock = $this->getMock('\\Magento\\Catalog\\Api\\Data\\ProductGroupPriceInterface'); $priceMock->expects($this->once())->method('setCustomerGroupId')->with($expected['customer_group_id'])->willReturnSelf(); $priceMock->expects($this->once())->method('setValue')->with($expected['value'])->willReturnSelf(); $this->priceFactoryMock->expects($this->once())->method('create')->will($this->returnValue($priceMock)); $prices = $this->groupPriceManagement->getList('product_sku'); $this->assertCount(1, $prices); $this->assertEquals($priceMock, $prices[0]); }