Example #1
0
 /**
  * @dataProvider specificOptionsProvider
  * @param array $optionIds
  * @param bool $withEmpty
  */
 public function testGetSpecificOptions($optionIds, $withEmpty)
 {
     $attributeId = 1;
     $storeId = 5;
     $options = [['label' => 'The label', 'value' => 'A value']];
     $attribute = $this->getMock('Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute', ['getId', 'getStoreId', '__wakeup'], [], '', false);
     $attribute->expects($this->once())->method('getId')->willReturn($attributeId);
     $attribute->expects($this->once())->method('getStoreId')->willReturn($storeId);
     $this->model->setAttribute($attribute);
     $this->collectionFactory->expects($this->once())->method('create')->willReturnSelf();
     $this->collectionFactory->expects($this->once())->method('setPositionOrder')->willReturnSelf();
     $this->collectionFactory->expects($this->once())->method('setAttributeFilter')->with($attributeId)->willReturnSelf();
     $this->collectionFactory->expects($this->once())->method('addFieldToFilter')->with('main_table.option_id', ['in' => $optionIds])->willReturnSelf();
     $this->collectionFactory->expects($this->once())->method('setStoreFilter')->with($storeId)->willReturnSelf();
     $this->collectionFactory->expects($this->once())->method('load')->willReturnSelf();
     $this->collectionFactory->expects($this->once())->method('toOptionArray')->willReturn($options);
     if ($withEmpty) {
         array_unshift($options, ['label' => '', 'value' => '']);
     }
     $this->assertEquals($options, $this->model->getSpecificOptions($optionIds, $withEmpty));
 }