Ejemplo n.º 1
0
 /**
  * @dataProvider getOptionTextProvider
  * @param array $optionsIds
  * @param array|string $value
  * @param array $options
  * @param array|string $expectedResult
  */
 public function testGetOptionText($optionsIds, $value, $options, $expectedResult)
 {
     $attributeId = 1;
     $storeId = 5;
     $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' => $optionsIds])->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);
     $this->assertEquals($expectedResult, $this->model->getOptionText($value));
 }