/**
  * @param AjaxFileUploaderControl $control
  * @param FileUpload $file
  */
 public function handleFileUpload(AjaxFileUploaderControl $control, $fileName)
 {
     /** @var FileEntity $fileEntity */
     $fileEntity = $this->fileRepository->createNew();
     $fileEntity->setFile(new \SplFileInfo($this->ajaxDir . '/' . $fileName));
     $this->fileRepository->save($fileEntity);
     $this->categoryEntity->items[] = $photoEntity = new ItemEntity($this->categoryEntity->extendedPage);
     $photoEntity->route->setPhoto($fileEntity);
     $photoEntity->route->setParent($this->categoryEntity->route);
     $photoEntity->setCategory($this->categoryEntity);
     $this->itemRepository->save($photoEntity);
 }
Exemplo n.º 2
0
 public function testSave()
 {
     $itemId = 1;
     $quoteItem = $this->getMock('\\Magento\\Sales\\Model\\Quote\\Item', ['getIsVirtual', '__wakeup'], [], '', false);
     $this->quoteMock->expects($this->once())->method('getItemById')->with($itemId)->will($this->returnValue($quoteItem));
     $quoteItem->expects($this->once())->method('getIsVirtual')->will($this->returnValue(0));
     $this->storeManagerMock->expects($this->once())->method('getStore')->will($this->returnValue($this->storeMock));
     $this->helperMock->expects($this->once())->method('getIsMessagesAvailable')->with('items', $this->quoteMock, $this->storeMock)->will($this->returnValue(true));
     $this->giftMessageManagerMock->expects($this->once())->method('setMessage')->with($this->quoteMock, 'quote_item', $this->messageMock, $itemId)->will($this->returnValue($this->giftMessageManagerMock));
     $this->assertTrue($this->itemRepository->save($this->cartId, $this->messageMock, $itemId));
 }