/** * @param array $config * @param float $expected * @dataProvider getMinSaleQtyDataProvider */ public function testGetMinSaleQty($config, $expected) { $groupId = $config['customer_group_id']; $useConfigMinSaleQty = $config['use_config_min_sale_qty']; $minSaleQty = $config['min_sale_qty']; $property = new \ReflectionProperty($this->item, 'customerGroupId'); $property->setAccessible(true); $property->setValue($this->item, $groupId); $this->setDataArrayValue('use_config_min_sale_qty', $useConfigMinSaleQty); if ($useConfigMinSaleQty) { $this->stockConfiguration->expects($this->once())->method('getMinSaleQty')->with($this->storeId, $this->equalTo($groupId))->will($this->returnValue($minSaleQty)); } else { $this->setDataArrayValue('min_sale_qty', $minSaleQty); } $this->assertSame($expected, $this->item->getMinSaleQty()); }
/** * @param array $config * @param float $expected * @dataProvider getMinSaleQtyDataProvider */ public function testGetMinSaleQty($config, $expected) { $groupId = $config['customer_group_id']; $useConfigMinSaleQty = $config['use_config_min_sale_qty']; $minSaleQty = $config['min_sale_qty']; $property = new \ReflectionProperty($this->item, '_customerGroupId'); $property->setAccessible(true); $property->setValue($this->item, $groupId); $property = new \ReflectionProperty($this->item, '_minSaleQtyCache'); $property->setAccessible(true); $this->assertEmpty($property->getValue($this->item)); $this->setDataArrayValue('use_config_min_sale_qty', $useConfigMinSaleQty); if ($useConfigMinSaleQty) { $this->catalogInventoryMinsaleqty->expects($this->once())->method('getConfigValue')->with($this->equalTo($groupId))->will($this->returnValue($minSaleQty)); } else { $this->setDataArrayValue('min_sale_qty', $minSaleQty); } $this->assertSame($expected, $this->item->getMinSaleQty()); // check lazy load $this->assertSame($expected, $this->item->getMinSaleQty()); }