Exemple #1
0
 /**
  * @return void
  * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
  */
 protected function setUp()
 {
     $sourceFileOne = $this->getMock('Magento\\Theme\\Model\\Theme\\File', ['__wakeup', 'delete'], [], '', false);
     $sourceFileOne->setData(['file_path' => 'fixture_file_path_one', 'file_type' => 'fixture_file_type_one', 'content' => 'fixture_content_one', 'sort_order' => 10]);
     $sourceFileTwo = $this->getMock('Magento\\Theme\\Model\\Theme\\File', ['__wakeup', 'delete'], [], '', false);
     $sourceFileTwo->setData(['file_path' => 'fixture_file_path_two', 'file_type' => 'fixture_file_type_two', 'content' => 'fixture_content_two', 'sort_order' => 20]);
     $this->_sourceFiles = [$sourceFileOne, $sourceFileTwo];
     $this->_sourceTheme = $this->getMock('Magento\\Theme\\Model\\Theme', ['__wakeup', 'getCustomization'], [], '', false);
     $this->_targetFiles = [$this->getMock('Magento\\Theme\\Model\\Theme\\File', ['__wakeup', 'delete'], [], '', false), $this->getMock('Magento\\Theme\\Model\\Theme\\File', ['__wakeup', 'delete'], [], '', false)];
     $this->_targetTheme = $this->getMock('Magento\\Theme\\Model\\Theme', ['__wakeup', 'getCustomization'], [], '', false);
     $this->_targetTheme->setId(123);
     $this->_customizationPath = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\Customization\\Path', [], [], '', false);
     $this->_fileFactory = $this->getMock('Magento\\Framework\\View\\Design\\Theme\\FileFactory', ['create'], [], '', false);
     $this->_filesystem = $this->getMock('Magento\\Framework\\Filesystem', ['getDirectoryWrite'], [], '', false);
     $this->_dirWriteMock = $this->getMock('Magento\\Framework\\Filesystem\\Directory\\Write', ['isDirectory', 'search', 'copy', 'delete', 'read', 'copyFile', 'isExist'], [], '', false);
     $this->_filesystem->expects($this->any())->method('getDirectoryWrite')->with(DirectoryList::MEDIA)->will($this->returnValue($this->_dirWriteMock));
     /* Init \Magento\Core\Model\Resource\Layout\Collection model  */
     $this->_updateFactory = $this->getMock('Magento\\Core\\Model\\Layout\\UpdateFactory', ['create'], [], '', false);
     $this->_update = $this->getMock('Magento\\Core\\Model\\Layout\\Update', ['__wakeup', 'getCollection'], [], '', false);
     $this->_updateFactory->expects($this->at(0))->method('create')->will($this->returnValue($this->_update));
     $this->_updateCollection = $this->getMock('Magento\\Core\\Model\\Resource\\Layout\\Collection', ['addThemeFilter', 'delete', 'getIterator'], [], '', false);
     $this->_update->expects($this->any())->method('getCollection')->will($this->returnValue($this->_updateCollection));
     /* Init Link an Link_Collection model */
     $this->_link = $this->getMock('Magento\\Core\\Model\\Layout\\Link', ['__wakeup', 'getCollection'], [], '', false);
     $this->_linkCollection = $this->getMock('Magento\\Core\\Model\\Resource\\Layout\\Link\\Collection', ['addThemeFilter', 'getIterator'], [], '', false);
     $this->_link->expects($this->any())->method('getCollection')->will($this->returnValue($this->_linkCollection));
     $eventManager = $this->getMock('Magento\\Framework\\Event\\ManagerInterface', ['dispatch'], [], '', false);
     $this->_object = new \Magento\Theme\Model\CopyService($this->_filesystem, $this->_fileFactory, $this->_link, $this->_updateFactory, $eventManager, $this->_customizationPath);
 }
 public function testGetAttributeById()
 {
     $this->productResource->expects($this->any())->method('loadAllAttributes')->will($this->returnValue($this->productResource));
     $this->productResource->expects($this->any())->method('getSortedAttributes')->will($this->returnValue([$this->attribute]));
     $this->attribute->setId(1);
     $this->assertEquals($this->attribute, $this->model->getAttributeById(1, $this->product));
     $this->assertNull($this->model->getAttributeById(0, $this->product));
 }
 /**
  * @test
  * @return void
  */
 public function testHasChildThemes()
 {
     $this->_model->setId(1);
     $this->resourceCollection->expects($this->once())->method('addTypeFilter')->with(Theme::TYPE_VIRTUAL)->willReturnSelf();
     $this->resourceCollection->expects($this->once())->method('addFieldToFilter')->with('parent_id', ['eq' => 1])->willReturnSelf();
     $this->resourceCollection->expects($this->once())->method('getSize')->willReturn(10);
     $this->assertTrue($this->_model->hasChildThemes());
 }
Exemple #4
0
 public function testIsCanDelete()
 {
     $this->assertFalse($this->model->isCanDelete());
     $this->model->load(1);
     $this->assertFalse($this->model->isCanDelete());
     $this->model->setId(100);
     $this->assertFalse($this->model->isCanDelete());
 }
Exemple #5
0
 /**
  * @covers \Magento\Framework\Data\Form\Element\AbstractElement::getHtmlContainerId()
  */
 public function testGetHtmlContainerIdWithFieldContainerIdPrefix()
 {
     $id = 'id';
     $prefix = 'prefix_';
     $formMock = $this->getMock('Magento\\Framework\\Data\\Form\\AbstractForm', ['getFieldContainerIdPrefix'], [], '', false);
     $formMock->expects($this->once())->method('getFieldContainerIdPrefix')->will($this->returnValue($prefix));
     $this->_model->setId($id);
     $this->_model->setForm($formMock);
     $this->assertEquals($prefix . $id, $this->_model->getHtmlContainerId());
 }
Exemple #6
0
 public function testSetOrder()
 {
     $orderId = 1111;
     $storeId = 2221;
     $this->orderMock->setId($orderId);
     $this->orderMock->setStoreId($storeId);
     $this->assertNull($this->model->getOrderId());
     $this->assertNull($this->model->getStoreId());
     $this->assertEquals($this->model, $this->model->setOrder($this->orderMock));
     $this->assertEquals($this->orderMock, $this->model->getOrder());
     $this->assertEquals($orderId, $this->model->getOrderId());
     $this->assertEquals($storeId, $this->model->getStoreId());
 }
 /**
  * Callback for delete method in mocked model
  */
 public function deleteModelSuccessfully()
 {
     $this->_model->setId(null);
 }
 public function testProcessTemplate()
 {
     $this->mockModel();
     $this->model->setId('customer_create_account_email_template');
     $this->assertContains('<body', $this->model->processTemplate());
 }
 /**
  * @covers \Magento\Framework\View\Design\Theme\Customization\Path::getCustomViewConfigPath
  */
 public function testGetCustomViewConfigPath()
 {
     $expectedPath = implode('/', [\Magento\Framework\View\Design\Theme\Customization\Path::DIR_NAME, '123', \Magento\Framework\View\ConfigInterface::CONFIG_FILE_NAME]);
     $this->assertEquals($expectedPath, $this->_model->getCustomViewConfigPath($this->_theme->setId(123)));
     $this->assertNull($this->_model->getCustomViewConfigPath($this->_theme->setId(null)));
 }
 /**
  * @param \PHPUnit_Framework_MockObject_MockObject $criteria
  * @return \PHPUnit_Framework_MockObject_MockObject
  *
  * @depends testImplementCriteriaInterface
  * @covers Sellsy\Criteria\Generic\GetOneCriteria::setId
  */
 public function testSetId(\PHPUnit_Framework_MockObject_MockObject $criteria)
 {
     $criteria->setId(12);
     $this->assertEquals(12, $criteria->getId());
     return $criteria;
 }