| @@ 1354-1375 (lines=22) @@ | ||
| 1351 | /** |
|
| 1352 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::getContentCount |
|
| 1353 | */ |
|
| 1354 | public function testGetContentCount() |
|
| 1355 | { |
|
| 1356 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 1357 | $this->cacheMock |
|
| 1358 | ->expects($this->never()) |
|
| 1359 | ->method($this->anything()); |
|
| 1360 | ||
| 1361 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler'); |
|
| 1362 | $this->persistenceHandlerMock |
|
| 1363 | ->expects($this->once()) |
|
| 1364 | ->method('contentTypeHandler') |
|
| 1365 | ->will($this->returnValue($innerHandler)); |
|
| 1366 | ||
| 1367 | $innerHandler |
|
| 1368 | ->expects($this->once()) |
|
| 1369 | ->method('getContentCount') |
|
| 1370 | ->with(1) |
|
| 1371 | ->will($this->returnValue(18)); |
|
| 1372 | ||
| 1373 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 1374 | $handler->getContentCount(1); |
|
| 1375 | } |
|
| 1376 | } |
|
| 1377 | ||
| @@ 82-103 (lines=22) @@ | ||
| 79 | /** |
|
| 80 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::policiesCount |
|
| 81 | */ |
|
| 82 | public function testPoliciesCount() |
|
| 83 | { |
|
| 84 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 85 | $this->cacheMock |
|
| 86 | ->expects($this->never()) |
|
| 87 | ->method($this->anything()); |
|
| 88 | ||
| 89 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler'); |
|
| 90 | $this->persistenceHandlerMock |
|
| 91 | ->expects($this->once()) |
|
| 92 | ->method('sectionHandler') |
|
| 93 | ->will($this->returnValue($innerHandler)); |
|
| 94 | ||
| 95 | $innerHandler |
|
| 96 | ->expects($this->once()) |
|
| 97 | ->method('policiesCount') |
|
| 98 | ->with(1) |
|
| 99 | ->will($this->returnValue(7)); |
|
| 100 | ||
| 101 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 102 | $handler->policiesCount(1); |
|
| 103 | } |
|
| 104 | ||
| 105 | /** |
|
| 106 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::countRoleAssignmentsUsingSection |
|
| @@ 108-129 (lines=22) @@ | ||
| 105 | /** |
|
| 106 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::countRoleAssignmentsUsingSection |
|
| 107 | */ |
|
| 108 | public function testCountRoleAssignmentsUsingSection() |
|
| 109 | { |
|
| 110 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 111 | $this->cacheMock |
|
| 112 | ->expects($this->never()) |
|
| 113 | ->method($this->anything()); |
|
| 114 | ||
| 115 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler'); |
|
| 116 | $this->persistenceHandlerMock |
|
| 117 | ->expects($this->once()) |
|
| 118 | ->method('sectionHandler') |
|
| 119 | ->will($this->returnValue($innerHandler)); |
|
| 120 | ||
| 121 | $innerHandler |
|
| 122 | ->expects($this->once()) |
|
| 123 | ->method('countRoleAssignmentsUsingSection') |
|
| 124 | ->with(1) |
|
| 125 | ->will($this->returnValue(0)); |
|
| 126 | ||
| 127 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 128 | $handler->countRoleAssignmentsUsingSection(1); |
|
| 129 | } |
|
| 130 | ||
| 131 | /** |
|
| 132 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::create |
|
| @@ 19-41 (lines=23) @@ | ||
| 16 | /** |
|
| 17 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::beginTransaction |
|
| 18 | */ |
|
| 19 | public function testBeginTransaction() |
|
| 20 | { |
|
| 21 | $this->loggerMock |
|
| 22 | ->expects($this->once()) |
|
| 23 | ->method('logCall'); |
|
| 24 | ||
| 25 | $this->cacheMock |
|
| 26 | ->expects($this->never()) |
|
| 27 | ->method($this->anything()); |
|
| 28 | ||
| 29 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\TransactionHandler'); |
|
| 30 | $this->persistenceHandlerMock |
|
| 31 | ->expects($this->once()) |
|
| 32 | ->method('transactionHandler') |
|
| 33 | ->will($this->returnValue($innerHandlerMock)); |
|
| 34 | ||
| 35 | $innerHandlerMock |
|
| 36 | ->expects($this->once()) |
|
| 37 | ->method('beginTransaction'); |
|
| 38 | ||
| 39 | $handler = $this->persistenceCacheHandler->transactionHandler(); |
|
| 40 | $handler->beginTransaction(); |
|
| 41 | } |
|
| 42 | ||
| 43 | /** |
|
| 44 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::commit |
|
| @@ 46-68 (lines=23) @@ | ||
| 43 | /** |
|
| 44 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::commit |
|
| 45 | */ |
|
| 46 | public function testCommit() |
|
| 47 | { |
|
| 48 | $this->loggerMock |
|
| 49 | ->expects($this->once()) |
|
| 50 | ->method('logCall'); |
|
| 51 | ||
| 52 | $this->cacheMock |
|
| 53 | ->expects($this->never()) |
|
| 54 | ->method($this->anything()); |
|
| 55 | ||
| 56 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\TransactionHandler'); |
|
| 57 | $this->persistenceHandlerMock |
|
| 58 | ->expects($this->once()) |
|
| 59 | ->method('transactionHandler') |
|
| 60 | ->will($this->returnValue($innerHandlerMock)); |
|
| 61 | ||
| 62 | $innerHandlerMock |
|
| 63 | ->expects($this->once()) |
|
| 64 | ->method('commit'); |
|
| 65 | ||
| 66 | $handler = $this->persistenceCacheHandler->transactionHandler(); |
|
| 67 | $handler->commit(); |
|
| 68 | } |
|
| 69 | ||
| 70 | /** |
|
| 71 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::rollback |
|
| @@ 73-95 (lines=23) @@ | ||
| 70 | /** |
|
| 71 | * @covers eZ\Publish\Core\Persistence\Cache\TransactionHandler::rollback |
|
| 72 | */ |
|
| 73 | public function testRollback() |
|
| 74 | { |
|
| 75 | $this->loggerMock |
|
| 76 | ->expects($this->once()) |
|
| 77 | ->method('logCall'); |
|
| 78 | ||
| 79 | $this->cacheMock |
|
| 80 | ->expects($this->once()) |
|
| 81 | ->method('clear'); |
|
| 82 | ||
| 83 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\TransactionHandler'); |
|
| 84 | $this->persistenceHandlerMock |
|
| 85 | ->expects($this->once()) |
|
| 86 | ->method('transactionHandler') |
|
| 87 | ->will($this->returnValue($innerHandlerMock)); |
|
| 88 | ||
| 89 | $innerHandlerMock |
|
| 90 | ->expects($this->once()) |
|
| 91 | ->method('rollback'); |
|
| 92 | ||
| 93 | $handler = $this->persistenceCacheHandler->transactionHandler(); |
|
| 94 | $handler->rollback(); |
|
| 95 | } |
|
| 96 | } |
|
| 97 | ||
| @@ 177-198 (lines=22) @@ | ||
| 174 | /** |
|
| 175 | * @covers eZ\Publish\Core\Persistence\Cache\TrashHandler::emptyTrash |
|
| 176 | */ |
|
| 177 | public function testEmptyTrash() |
|
| 178 | { |
|
| 179 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 180 | ||
| 181 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Trash\\Handler'); |
|
| 182 | $this->persistenceHandlerMock |
|
| 183 | ->expects($this->once()) |
|
| 184 | ->method('trashHandler') |
|
| 185 | ->will($this->returnValue($innerHandlerMock)); |
|
| 186 | ||
| 187 | $innerHandlerMock |
|
| 188 | ->expects($this->once()) |
|
| 189 | ->method('emptyTrash') |
|
| 190 | ->with(); |
|
| 191 | ||
| 192 | $this->cacheMock |
|
| 193 | ->expects($this->never()) |
|
| 194 | ->method($this->anything()); |
|
| 195 | ||
| 196 | $handler = $this->persistenceCacheHandler->trashHandler(); |
|
| 197 | $handler->emptyTrash(); |
|
| 198 | } |
|
| 199 | ||
| 200 | /** |
|
| 201 | * @covers eZ\Publish\Core\Persistence\Cache\TrashHandler::deleteTrashItem |
|
| @@ 203-224 (lines=22) @@ | ||
| 200 | /** |
|
| 201 | * @covers eZ\Publish\Core\Persistence\Cache\TrashHandler::deleteTrashItem |
|
| 202 | */ |
|
| 203 | public function testDeleteTrashItem() |
|
| 204 | { |
|
| 205 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 206 | ||
| 207 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Trash\\Handler'); |
|
| 208 | $this->persistenceHandlerMock |
|
| 209 | ->expects($this->once()) |
|
| 210 | ->method('trashHandler') |
|
| 211 | ->will($this->returnValue($innerHandlerMock)); |
|
| 212 | ||
| 213 | $innerHandlerMock |
|
| 214 | ->expects($this->once()) |
|
| 215 | ->method('deleteTrashItem') |
|
| 216 | ->with(33); |
|
| 217 | ||
| 218 | $this->cacheMock |
|
| 219 | ->expects($this->never()) |
|
| 220 | ->method($this->anything()); |
|
| 221 | ||
| 222 | $handler = $this->persistenceCacheHandler->trashHandler(); |
|
| 223 | $handler->deleteTrashItem(33); |
|
| 224 | } |
|
| 225 | } |
|
| 226 | ||
| @@ 1140-1156 (lines=17) @@ | ||
| 1137 | /** |
|
| 1138 | * @param $locationCacheMissed |
|
| 1139 | */ |
|
| 1140 | protected function prepareDeleteMocks($locationCacheMissed) |
|
| 1141 | { |
|
| 1142 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 1143 | ||
| 1144 | $innerHandler = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\UrlAlias\\Handler'); |
|
| 1145 | $this->persistenceHandlerMock |
|
| 1146 | ->expects($this->once()) |
|
| 1147 | ->method('urlAliasHandler') |
|
| 1148 | ->will($this->returnValue($innerHandler)); |
|
| 1149 | ||
| 1150 | $innerHandler->expects($this->once())->method('locationDeleted')->with(44); |
|
| 1151 | ||
| 1152 | $this->cacheMock |
|
| 1153 | ->expects($this->once()) |
|
| 1154 | ->method('getItem') |
|
| 1155 | ->willReturn($locationCacheMissed); |
|
| 1156 | } |
|
| 1157 | } |
|
| 1158 | ||