/** * Retrieve stock option array * * @return array */ public function getStockOption() { if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) { return $this->stock->toOptionArray(); } return []; }
/** * Retrieve stock option array * * @return array */ public function getStockOption() { if ($this->catalogData->isModuleEnabled('Magento_CatalogInventory')) { return $this->stock->toOptionArray(); } return array(); }
/** * Run test getStockOption method * * @param bool $moduleEnabled * @return void * * @dataProvider dataProviderModuleEnabled */ public function testGetStockOption($moduleEnabled) { $this->moduleManager->expects($this->once())->method('isEnabled')->with('Magento_CatalogInventory')->will($this->returnValue($moduleEnabled)); if ($moduleEnabled) { $this->stockMock->expects($this->once())->method('toOptionArray')->will($this->returnValue(['test-value', 'test-value'])); } $result = $this->inventory->getStockOption(); $this->assertEquals($moduleEnabled, !empty($result)); }