public function testDeleteById()
 {
     $bookmarkId = 1;
     $this->bookmarkMock->expects($this->once())->method('getId')->willReturn($bookmarkId);
     $this->bookmarkResourceMock->expects($this->once())->method('load')->with($this->bookmarkMock, $bookmarkId)->willReturn($this->bookmarkMock);
     $this->bookmarkResourceMock->expects($this->once())->method('delete')->with($this->bookmarkMock);
     $this->assertTrue($this->bookmarkRepository->deleteById($bookmarkId));
 }
예제 #2
0
파일: Save.php 프로젝트: kid17/magento2
 /**
  * Update bookmarks based on request params
  *
  * @param BookmarkInterface $bookmark
  * @param string $identifier
  * @param string $title
  * @param array $config
  * @return void
  */
 protected function updateBookmark(BookmarkInterface $bookmark, $identifier, $title, array $config = [])
 {
     $this->filterVars($config);
     $bookmark->setUserId($this->userContext->getUserId())->setNamespace($this->_request->getParam('namespace'))->setIdentifier($identifier)->setTitle($title)->setConfig($config)->setCurrent($identifier !== self::CURRENT_IDENTIFIER);
     $this->bookmarkRepository->save($bookmark);
     $bookmarks = $this->bookmarkManagement->loadByNamespace($this->_request->getParam('namespace'));
     foreach ($bookmarks->getItems() as $bookmark) {
         if ($bookmark->getIdentifier() == $identifier) {
             continue;
         }
         $bookmark->setCurrent(false);
         $this->bookmarkRepository->save($bookmark);
     }
 }