|
@@ 85-102 (lines=18) @@
|
| 82 |
|
* @covers \eZ\Publish\Core\Repository\BookmarkService::createBookmark |
| 83 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 84 |
|
*/ |
| 85 |
|
public function testCreateBookmarkThrowsInvalidArgumentException() |
| 86 |
|
{ |
| 87 |
|
$location = $this->createLocation(self::LOCATION_ID); |
| 88 |
|
|
| 89 |
|
$this->assertLocationIsLoaded($location); |
| 90 |
|
|
| 91 |
|
$this->bookmarkHandler |
| 92 |
|
->expects($this->once()) |
| 93 |
|
->method('loadByUserIdAndLocationId') |
| 94 |
|
->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) |
| 95 |
|
->willReturn([self::LOCATION_ID => new Bookmark()]); |
| 96 |
|
|
| 97 |
|
$this->assertTransactionIsNotStarted(function () { |
| 98 |
|
$this->bookmarkHandler->expects($this->never())->method('create'); |
| 99 |
|
}); |
| 100 |
|
|
| 101 |
|
$this->createBookmarkService()->createBookmark($location); |
| 102 |
|
} |
| 103 |
|
|
| 104 |
|
/** |
| 105 |
|
* @covers \eZ\Publish\Core\Repository\BookmarkService::createBookmark |
|
@@ 108-128 (lines=21) @@
|
| 105 |
|
* @covers \eZ\Publish\Core\Repository\BookmarkService::createBookmark |
| 106 |
|
* @expectedException \Exception |
| 107 |
|
*/ |
| 108 |
|
public function testCreateBookmarkWithRollback() |
| 109 |
|
{ |
| 110 |
|
$location = $this->createLocation(self::LOCATION_ID); |
| 111 |
|
|
| 112 |
|
$this->assertLocationIsLoaded($location); |
| 113 |
|
|
| 114 |
|
$this->bookmarkHandler |
| 115 |
|
->expects($this->once()) |
| 116 |
|
->method('loadByUserIdAndLocationId') |
| 117 |
|
->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) |
| 118 |
|
->willReturn([]); |
| 119 |
|
|
| 120 |
|
$this->assertTransactionIsRollback(function () { |
| 121 |
|
$this->bookmarkHandler |
| 122 |
|
->expects($this->once()) |
| 123 |
|
->method('create') |
| 124 |
|
->willThrowException($this->createMock(Exception::class)); |
| 125 |
|
}); |
| 126 |
|
|
| 127 |
|
$this->createBookmarkService()->createBookmark($location); |
| 128 |
|
} |
| 129 |
|
|
| 130 |
|
/** |
| 131 |
|
* @covers \eZ\Publish\Core\Repository\BookmarkService::deleteBookmark |
|
@@ 187-204 (lines=18) @@
|
| 184 |
|
* @covers \eZ\Publish\Core\Repository\BookmarkService::deleteBookmark |
| 185 |
|
* @expectedException \eZ\Publish\API\Repository\Exceptions\InvalidArgumentException |
| 186 |
|
*/ |
| 187 |
|
public function testDeleteBookmarkNonExisting() |
| 188 |
|
{ |
| 189 |
|
$location = $this->createLocation(self::LOCATION_ID); |
| 190 |
|
|
| 191 |
|
$this->assertLocationIsLoaded($location); |
| 192 |
|
|
| 193 |
|
$this->bookmarkHandler |
| 194 |
|
->expects($this->once()) |
| 195 |
|
->method('loadByUserIdAndLocationId') |
| 196 |
|
->with(self::CURRENT_USER_ID, [self::LOCATION_ID]) |
| 197 |
|
->willReturn([]); |
| 198 |
|
|
| 199 |
|
$this->assertTransactionIsNotStarted(function () { |
| 200 |
|
$this->bookmarkHandler->expects($this->never())->method('delete'); |
| 201 |
|
}); |
| 202 |
|
|
| 203 |
|
$this->createBookmarkService()->deleteBookmark($location); |
| 204 |
|
} |
| 205 |
|
|
| 206 |
|
/** |
| 207 |
|
* @covers \eZ\Publish\Core\Repository\BookmarkService::loadBookmarks |