| @@ 21-43 (lines=23) @@ | ||
| 18 | /** |
|
| 19 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::beginTransaction |
|
| 20 | */ |
|
| 21 | public function testBeginTransaction() |
|
| 22 | { |
|
| 23 | $this->loggerMock |
|
| 24 | ->expects($this->once()) |
|
| 25 | ->method('logCall'); |
|
| 26 | ||
| 27 | $this->cacheMock |
|
| 28 | ->expects($this->never()) |
|
| 29 | ->method($this->anything()); |
|
| 30 | ||
| 31 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\TransactionHandler'); |
|
| 32 | $this->persistenceHandlerMock |
|
| 33 | ->expects($this->once()) |
|
| 34 | ->method('transactionHandler') |
|
| 35 | ->will($this->returnValue($innerHandlerMock)); |
|
| 36 | ||
| 37 | $innerHandlerMock |
|
| 38 | ->expects($this->once()) |
|
| 39 | ->method('beginTransaction'); |
|
| 40 | ||
| 41 | $handler = $this->persistenceCacheHandler->transactionHandler(); |
|
| 42 | $handler->beginTransaction(); |
|
| 43 | } |
|
| 44 | ||
| 45 | /** |
|
| 46 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::commit |
|
| @@ 48-70 (lines=23) @@ | ||
| 45 | /** |
|
| 46 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::commit |
|
| 47 | */ |
|
| 48 | public function testCommit() |
|
| 49 | { |
|
| 50 | $this->loggerMock |
|
| 51 | ->expects($this->once()) |
|
| 52 | ->method('logCall'); |
|
| 53 | ||
| 54 | $this->cacheMock |
|
| 55 | ->expects($this->never()) |
|
| 56 | ->method($this->anything()); |
|
| 57 | ||
| 58 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\TransactionHandler'); |
|
| 59 | $this->persistenceHandlerMock |
|
| 60 | ->expects($this->once()) |
|
| 61 | ->method('transactionHandler') |
|
| 62 | ->will($this->returnValue($innerHandlerMock)); |
|
| 63 | ||
| 64 | $innerHandlerMock |
|
| 65 | ->expects($this->once()) |
|
| 66 | ->method('commit'); |
|
| 67 | ||
| 68 | $handler = $this->persistenceCacheHandler->transactionHandler(); |
|
| 69 | $handler->commit(); |
|
| 70 | } |
|
| 71 | ||
| 72 | /** |
|
| 73 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::rollback |
|
| @@ 75-97 (lines=23) @@ | ||
| 72 | /** |
|
| 73 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::rollback |
|
| 74 | */ |
|
| 75 | public function testRollback() |
|
| 76 | { |
|
| 77 | $this->loggerMock |
|
| 78 | ->expects($this->once()) |
|
| 79 | ->method('logCall'); |
|
| 80 | ||
| 81 | $this->cacheMock |
|
| 82 | ->expects($this->once()) |
|
| 83 | ->method('clear'); |
|
| 84 | ||
| 85 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\TransactionHandler'); |
|
| 86 | $this->persistenceHandlerMock |
|
| 87 | ->expects($this->once()) |
|
| 88 | ->method('transactionHandler') |
|
| 89 | ->will($this->returnValue($innerHandlerMock)); |
|
| 90 | ||
| 91 | $innerHandlerMock |
|
| 92 | ->expects($this->once()) |
|
| 93 | ->method('rollback'); |
|
| 94 | ||
| 95 | $handler = $this->persistenceCacheHandler->transactionHandler(); |
|
| 96 | $handler->rollback(); |
|
| 97 | } |
|
| 98 | } |
|
| 99 | ||
| @@ 179-200 (lines=22) @@ | ||
| 176 | /** |
|
| 177 | * @covers eZ\Publish\Core\Persistence\Cache\TrashHandler::emptyTrash |
|
| 178 | */ |
|
| 179 | public function testEmptyTrash() |
|
| 180 | { |
|
| 181 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 182 | ||
| 183 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Trash\\Handler'); |
|
| 184 | $this->persistenceHandlerMock |
|
| 185 | ->expects($this->once()) |
|
| 186 | ->method('trashHandler') |
|
| 187 | ->will($this->returnValue($innerHandlerMock)); |
|
| 188 | ||
| 189 | $innerHandlerMock |
|
| 190 | ->expects($this->once()) |
|
| 191 | ->method('emptyTrash') |
|
| 192 | ->with(); |
|
| 193 | ||
| 194 | $this->cacheMock |
|
| 195 | ->expects($this->never()) |
|
| 196 | ->method($this->anything()); |
|
| 197 | ||
| 198 | $handler = $this->persistenceCacheHandler->trashHandler(); |
|
| 199 | $handler->emptyTrash(); |
|
| 200 | } |
|
| 201 | ||
| 202 | /** |
|
| 203 | * @covers eZ\Publish\Core\Persistence\Cache\TrashHandler::deleteTrashItem |
|
| @@ 205-226 (lines=22) @@ | ||
| 202 | /** |
|
| 203 | * @covers eZ\Publish\Core\Persistence\Cache\TrashHandler::deleteTrashItem |
|
| 204 | */ |
|
| 205 | public function testDeleteTrashItem() |
|
| 206 | { |
|
| 207 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 208 | ||
| 209 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Trash\\Handler'); |
|
| 210 | $this->persistenceHandlerMock |
|
| 211 | ->expects($this->once()) |
|
| 212 | ->method('trashHandler') |
|
| 213 | ->will($this->returnValue($innerHandlerMock)); |
|
| 214 | ||
| 215 | $innerHandlerMock |
|
| 216 | ->expects($this->once()) |
|
| 217 | ->method('deleteTrashItem') |
|
| 218 | ->with(33); |
|
| 219 | ||
| 220 | $this->cacheMock |
|
| 221 | ->expects($this->never()) |
|
| 222 | ->method($this->anything()); |
|
| 223 | ||
| 224 | $handler = $this->persistenceCacheHandler->trashHandler(); |
|
| 225 | $handler->deleteTrashItem(33); |
|
| 226 | } |
|
| 227 | } |
|
| 228 | ||
| @@ 869-885 (lines=17) @@ | ||
| 866 | /** |
|
| 867 | * @param $locationCacheMissed |
|
| 868 | */ |
|
| 869 | protected function prepareDeleteMocks($locationCacheMissed) |
|
| 870 | { |
|
| 871 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 872 | ||
| 873 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler'); |
|
| 874 | $this->persistenceHandlerMock |
|
| 875 | ->expects($this->once()) |
|
| 876 | ->method('urlAliasHandler') |
|
| 877 | ->will($this->returnValue($innerHandler)); |
|
| 878 | ||
| 879 | $innerHandler->expects($this->once())->method('locationDeleted')->with(44); |
|
| 880 | ||
| 881 | $this->cacheMock |
|
| 882 | ->expects($this->once()) |
|
| 883 | ->method('getItem') |
|
| 884 | ->willReturn($locationCacheMissed); |
|
| 885 | } |
|
| 886 | } |
|
| 887 | ||