Beispiel #1
0
 /**
  * Create new import object
  *
  * @param string $serviceName
  * @param array $data
  * @throws \InvalidArgumentException
  * @throws \UnexpectedValueException
  * @return \Magento\Directory\Model\Currency\Import\ImportInterface
  */
 public function create($serviceName, array $data = [])
 {
     $serviceClass = $this->_serviceConfig->getServiceClass($serviceName);
     if (!$serviceClass) {
         throw new \InvalidArgumentException("Currency import service '{$serviceName}' is not defined.");
     }
     $serviceInstance = $this->_objectManager->create($serviceClass, $data);
     if (!$serviceInstance instanceof \Magento\Directory\Model\Currency\Import\ImportInterface) {
         throw new \UnexpectedValueException("Class '{$serviceClass}' has to implement \\Magento\\Directory\\Model\\Currency\\Import\\ImportInterface.");
     }
     return $serviceInstance;
 }
 /**
  * @param string $serviceName
  * @param mixed $expectedResult
  * @dataProvider getServiceClassDataProvider
  */
 public function testGetServiceClass($serviceName, $expectedResult)
 {
     $this->assertEquals($expectedResult, $this->_model->getServiceClass($serviceName));
 }