44 $this->bookmarkRepository = $this->getMockBuilder(\
Magento\Ui\Api\BookmarkRepositoryInterface::class)
45 ->getMockForAbstractClass();
46 $this->filterBuilder = $this->getMockBuilder(\
Magento\Framework\Api\FilterBuilder::class)
47 ->disableOriginalConstructor()
48 ->setMethods([
'create'])
50 $this->searchCriteriaBuilder =$this->getMockBuilder(\
Magento\Framework\Api\SearchCriteriaBuilder::class)
51 ->disableOriginalConstructor()
53 $this->userContext = $this->getMockBuilder(\
Magento\Authorization\Model\UserContextInterface::class)
54 ->getMockForAbstractClass();
56 $this->bookmarkRepository,
58 $this->searchCriteriaBuilder,
66 $namespace =
'some_namespace';
67 $this->userContext->expects($this->once())
69 ->willReturn($userId);
77 $fieldNamespace =
new Filter(
85 ->getMockForAbstractClass();
86 $this->filterBuilder->expects($this->at(0))
88 ->willReturn($fieldUserId);
89 $this->filterBuilder->expects($this->at(1))
91 ->willReturn($fieldNamespace);
92 $this->searchCriteriaBuilder->expects($this->exactly(2))
93 ->method(
'addFilters')
94 ->withConsecutive([[$fieldUserId]], [[$fieldNamespace]]);
95 $this->searchCriteriaBuilder->expects($this->once())
98 $searchResult = $this->getMockBuilder(\
Magento\Ui\Api\Data\BookmarkSearchResultsInterface::class)
99 ->getMockForAbstractClass();
100 $this->bookmarkRepository->expects($this->once())
103 ->willReturn($searchResult);
104 $this->assertEquals($searchResult, $this->bookmarkManagement->loadByNamespace($namespace));
110 $namespace =
'some_namespace';
111 $identifier =
'current';
112 $this->userContext->expects($this->once())
113 ->method(
'getUserId')
114 ->willReturn($userId);
115 $fieldUserId =
new Filter(
122 $fieldIdentifier =
new Filter(
129 $fieldNamespace =
new Filter(
137 $bookmark = $this->getMockBuilder(\
Magento\Ui\Api\Data\BookmarkInterface::class)->getMockForAbstractClass();
138 $bookmark->expects($this->once())->method(
'getId')->willReturn($bookmarkId);
140 ->getMockForAbstractClass();
141 $this->filterBuilder->expects($this->at(0))
143 ->willReturn($fieldUserId);
144 $this->filterBuilder->expects($this->at(1))
146 ->willReturn($fieldIdentifier);
147 $this->filterBuilder->expects($this->at(2))
149 ->willReturn($fieldNamespace);
150 $this->searchCriteriaBuilder->expects($this->exactly(3))
151 ->method(
'addFilters')
152 ->withConsecutive([[$fieldUserId]], [[$fieldIdentifier]], [[$fieldNamespace]]);
153 $this->searchCriteriaBuilder->expects($this->once())
156 $searchResult = $this->getMockBuilder(\
Magento\Ui\Api\Data\BookmarkSearchResultsInterface::class)
157 ->getMockForAbstractClass();
158 $searchResult->expects($this->once())->method(
'getTotalCount')->willReturn(1);
159 $searchResult->expects($this->once())->method(
'getItems')->willReturn([$bookmark]);
160 $this->bookmarkRepository->expects($this->once())
163 ->willReturn($searchResult);
164 $this->bookmarkRepository->expects($this->once())
167 ->willReturn($bookmark);
170 $this->bookmarkManagement->getByIdentifierNamespace($identifier, $namespace)
testGetByIdentifierNamespace()