/** * @expectedException \Magento\Framework\Exception\LocalizedException * @expectedExceptionMessage WrongClass doesn't extends \Magento\Catalog\Model\Product\Option\Type\DefaultType */ public function testWrongTypeException() { $className = 'WrongClass'; $filterMock = $this->getMock($className, [], [], '', false); $this->_objectManagerMock->expects($this->once())->method('create')->will($this->returnValue($filterMock)); $this->_factory->create($className); }
/** * Group model factory * * @param string $type Option type * @return \Magento\Catalog\Model\Product\Option\Type\DefaultType * @throws LocalizedException */ public function groupFactory($type) { $group = $this->getGroupByType($type); if (!empty($group)) { return $this->optionTypeFactory->create('Magento\\Catalog\\Model\\Product\\Option\\Type\\' . $this->string->upperCaseWords($group)); } throw new LocalizedException(__('The option type to get group instance is incorrect.')); }