コード例 #1
0
 /**
  * Retrieve stock option array
  *
  * @return array
  */
 public function getStockOption()
 {
     if ($this->moduleManager->isEnabled('Magento_CatalogInventory')) {
         return $this->stock->toOptionArray();
     }
     return [];
 }
コード例 #2
0
ファイル: Inventory.php プロジェクト: aiesh/magento2
 /**
  * Retrieve stock option array
  *
  * @return array
  */
 public function getStockOption()
 {
     if ($this->catalogData->isModuleEnabled('Magento_CatalogInventory')) {
         return $this->stock->toOptionArray();
     }
     return array();
 }
コード例 #3
0
 /**
  * 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));
 }