12
12
use eZ \Publish \API \Repository \LocationService ;
13
13
use eZ \Publish \API \Repository \PermissionResolver ;
14
14
use eZ \Publish \API \Repository \Values \Content \ContentInfo ;
15
+ use eZ \Publish \API \Repository \Values \Content \LocationList ;
15
16
use eZ \Publish \Core \Repository \BookmarkService ;
16
17
use eZ \Publish \Core \Repository \Tests \Service \Mock \Base as BaseServiceMockTest ;
17
18
use eZ \Publish \Core \Repository \Values \Content \Location ;
@@ -219,28 +220,13 @@ public function testLoadBookmarks()
219
220
$ expectedItems = array_map (function ($ locationId ) {
220
221
return $ this ->createLocation ($ locationId );
221
222
}, range (1 , $ expectedTotalCount ));
222
-
223
- $ this ->bookmarkHandler
224
- ->expects ($ this ->once ())
225
- ->method ('countUserBookmarks ' )
226
- ->with (self ::CURRENT_USER_ID )
227
- ->willReturn ($ expectedTotalCount );
228
-
229
- $ this ->bookmarkHandler
230
- ->expects ($ this ->once ())
231
- ->method ('loadUserBookmarks ' )
232
- ->with (self ::CURRENT_USER_ID , $ offset , $ limit )
233
- ->willReturn (array_map (static function ($ locationId ) {
234
- return new Bookmark (['locationId ' => $ locationId ]);
235
- }, range (1 , $ expectedTotalCount )));
223
+ $ locationList = new LocationList (['totalCount ' => $ expectedTotalCount , 'locations ' => $ expectedItems ]);
236
224
237
225
$ locationServiceMock = $ this ->createMock (LocationService::class);
238
226
$ locationServiceMock
239
- ->expects ($ this ->exactly ($ expectedTotalCount ))
240
- ->method ('loadLocation ' )
241
- ->willReturnCallback (function ($ locationId ) {
242
- return $ this ->createLocation ($ locationId );
243
- });
227
+ ->expects ($ this ->once ())
228
+ ->method ('find ' )
229
+ ->willReturn ($ locationList );
244
230
245
231
$ repository = $ this ->getRepositoryMock ();
246
232
$ repository
@@ -254,27 +240,6 @@ public function testLoadBookmarks()
254
240
$ this ->assertEquals ($ expectedItems , $ bookmarks ->items );
255
241
}
256
242
257
- /**
258
- * @covers \eZ\Publish\Core\Repository\BookmarkService::loadBookmarks
259
- */
260
- public function testLoadBookmarksEmptyList ()
261
- {
262
- $ this ->bookmarkHandler
263
- ->expects ($ this ->once ())
264
- ->method ('countUserBookmarks ' )
265
- ->with (self ::CURRENT_USER_ID )
266
- ->willReturn (0 );
267
-
268
- $ this ->bookmarkHandler
269
- ->expects ($ this ->never ())
270
- ->method ('loadUserBookmarks ' );
271
-
272
- $ bookmarks = $ this ->createBookmarkService ()->loadBookmarks (0 , 10 );
273
-
274
- $ this ->assertEquals (0 , $ bookmarks ->totalCount );
275
- $ this ->assertEmpty ($ bookmarks ->items );
276
- }
277
-
278
243
/**
279
244
* @covers \eZ\Publish\Core\Repository\BookmarkService::isBookmarked
280
245
*/
0 commit comments