/** * {@inheritdoc} * * @return CustomizationFileInterface * @throws \UnexpectedValueException */ public function getCustomizationService() { if (!$this->_fileService && $this->hasData('file_type')) { $this->_fileService = $this->_fileServiceFactory->create($this->getData('file_type')); } elseif (!$this->_fileService) { throw new \UnexpectedValueException('Type of file is empty'); } return $this->_fileService; }
/** * @test * @return void */ public function testBeforeSaveDelete() { $fileServiceName = 'service_name'; $customization = $this->getMockBuilder('Magento\\Framework\\View\\Design\\Theme\\Customization\\FileInterface')->getMock(); $this->fileServiceFactory->expects($this->once())->method('create')->with($fileServiceName)->willReturn($customization); $customization->expects($this->once())->method('prepareFile')->with($this->model)->willReturnSelf(); $customization->expects($this->once())->method('save')->with($this->model)->willReturnSelf(); $customization->expects($this->once())->method('delete')->with($this->model)->willReturnSelf(); $this->model->setData('file_type', $fileServiceName); $this->model->beforeSave(); $this->model->beforeDelete(); }