| @@ 102-153 (lines=52) @@ | ||
| 99 | /** |
|
| 100 | * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| 101 | */ |
|
| 102 | public function testLoadCacheIsMiss() |
|
| 103 | { |
|
| 104 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 105 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 106 | $this->cacheMock |
|
| 107 | ->expects($this->once()) |
|
| 108 | ->method('getItem') |
|
| 109 | ->with('language', 2) |
|
| 110 | ->will($this->returnValue($cacheItemMock)); |
|
| 111 | ||
| 112 | $cacheItemMock |
|
| 113 | ->expects($this->once()) |
|
| 114 | ->method('get') |
|
| 115 | ->will($this->returnValue(null)); |
|
| 116 | ||
| 117 | $cacheItemMock |
|
| 118 | ->expects($this->once()) |
|
| 119 | ->method('isMiss') |
|
| 120 | ->will($this->returnValue(true)); |
|
| 121 | ||
| 122 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Language\\Handler'); |
|
| 123 | $this->persistenceHandlerMock |
|
| 124 | ->expects($this->once()) |
|
| 125 | ->method('contentLanguageHandler') |
|
| 126 | ->will($this->returnValue($innerHandlerMock)); |
|
| 127 | ||
| 128 | $innerHandlerMock |
|
| 129 | ->expects($this->once()) |
|
| 130 | ->method('load') |
|
| 131 | ->with(2) |
|
| 132 | ->will( |
|
| 133 | $this->returnValue( |
|
| 134 | new SPILanguage( |
|
| 135 | array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB') |
|
| 136 | ) |
|
| 137 | ) |
|
| 138 | ); |
|
| 139 | ||
| 140 | $cacheItemMock |
|
| 141 | ->expects($this->once()) |
|
| 142 | ->method('set') |
|
| 143 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Language')) |
|
| 144 | ->will($this->returnValue($cacheItemMock)); |
|
| 145 | ||
| 146 | $cacheItemMock |
|
| 147 | ->expects($this->once()) |
|
| 148 | ->method('save') |
|
| 149 | ->with(); |
|
| 150 | ||
| 151 | $handler = $this->persistenceCacheHandler->contentLanguageHandler(); |
|
| 152 | $handler->load(2); |
|
| 153 | } |
|
| 154 | ||
| 155 | /** |
|
| 156 | * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| @@ 342-393 (lines=52) @@ | ||
| 339 | /** |
|
| 340 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| 341 | */ |
|
| 342 | public function testLoadCacheIsMiss() |
|
| 343 | { |
|
| 344 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 345 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 346 | $this->cacheMock |
|
| 347 | ->expects($this->once()) |
|
| 348 | ->method('getItem') |
|
| 349 | ->with('contentType', 55) |
|
| 350 | ->will($this->returnValue($cacheItemMock)); |
|
| 351 | ||
| 352 | $cacheItemMock |
|
| 353 | ->expects($this->once()) |
|
| 354 | ->method('get') |
|
| 355 | ->will($this->returnValue(null)); |
|
| 356 | ||
| 357 | $cacheItemMock |
|
| 358 | ->expects($this->once()) |
|
| 359 | ->method('isMiss') |
|
| 360 | ->will($this->returnValue(true)); |
|
| 361 | ||
| 362 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler'); |
|
| 363 | $this->persistenceHandlerMock |
|
| 364 | ->expects($this->once()) |
|
| 365 | ->method('contentTypeHandler') |
|
| 366 | ->will($this->returnValue($innerHandlerMock)); |
|
| 367 | ||
| 368 | $innerHandlerMock |
|
| 369 | ->expects($this->once()) |
|
| 370 | ->method('load') |
|
| 371 | ->with(55) |
|
| 372 | ->will( |
|
| 373 | $this->returnValue( |
|
| 374 | new SPIType( |
|
| 375 | array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum') |
|
| 376 | ) |
|
| 377 | ) |
|
| 378 | ); |
|
| 379 | ||
| 380 | $cacheItemMock |
|
| 381 | ->expects($this->once()) |
|
| 382 | ->method('set') |
|
| 383 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type')) |
|
| 384 | ->will($this->returnValue($cacheItemMock)); |
|
| 385 | ||
| 386 | $cacheItemMock |
|
| 387 | ->expects($this->once()) |
|
| 388 | ->method('save') |
|
| 389 | ->with(); |
|
| 390 | ||
| 391 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 392 | $handler->load(55); |
|
| 393 | } |
|
| 394 | ||
| 395 | /** |
|
| 396 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| @@ 216-261 (lines=46) @@ | ||
| 213 | /** |
|
| 214 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| 215 | */ |
|
| 216 | public function testLoadParentLocationsForDraftContentIsMiss() |
|
| 217 | { |
|
| 218 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 219 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 220 | $this->cacheMock |
|
| 221 | ->expects($this->once()) |
|
| 222 | ->method('getItem') |
|
| 223 | ->with('content', 'locations', '44', 'parentLocationsForDraftContent') |
|
| 224 | ->will($this->returnValue($cacheItemMock)); |
|
| 225 | ||
| 226 | $cacheItemMock |
|
| 227 | ->expects($this->once()) |
|
| 228 | ->method('get') |
|
| 229 | ->will($this->returnValue(null)); |
|
| 230 | ||
| 231 | $cacheItemMock |
|
| 232 | ->expects($this->once()) |
|
| 233 | ->method('isMiss') |
|
| 234 | ->will($this->returnValue(true)); |
|
| 235 | ||
| 236 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler'); |
|
| 237 | $this->persistenceHandlerMock |
|
| 238 | ->expects($this->once()) |
|
| 239 | ->method('locationHandler') |
|
| 240 | ->will($this->returnValue($innerHandlerMock)); |
|
| 241 | ||
| 242 | $innerHandlerMock |
|
| 243 | ->expects($this->once()) |
|
| 244 | ->method('loadParentLocationsForDraftContent') |
|
| 245 | ->with(44) |
|
| 246 | ->will($this->returnValue(array(new Location(array('id' => 33))))); |
|
| 247 | ||
| 248 | $cacheItemMock |
|
| 249 | ->expects($this->once()) |
|
| 250 | ->method('set') |
|
| 251 | ->with(array(33)) |
|
| 252 | ->will($this->returnValue($cacheItemMock)); |
|
| 253 | ||
| 254 | $cacheItemMock |
|
| 255 | ->expects($this->once()) |
|
| 256 | ->method('save') |
|
| 257 | ->with(); |
|
| 258 | ||
| 259 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 260 | $handler->loadParentLocationsForDraftContent(44); |
|
| 261 | } |
|
| 262 | ||
| 263 | /** |
|
| 264 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| @@ 324-369 (lines=46) @@ | ||
| 321 | /** |
|
| 322 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| 323 | */ |
|
| 324 | public function testLoadLocationsByContentWithRootIsMiss() |
|
| 325 | { |
|
| 326 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 327 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 328 | $this->cacheMock |
|
| 329 | ->expects($this->once()) |
|
| 330 | ->method('getItem') |
|
| 331 | ->with('content', 'locations', '44', 'root', '2') |
|
| 332 | ->will($this->returnValue($cacheItemMock)); |
|
| 333 | ||
| 334 | $cacheItemMock |
|
| 335 | ->expects($this->once()) |
|
| 336 | ->method('get') |
|
| 337 | ->will($this->returnValue(null)); |
|
| 338 | ||
| 339 | $cacheItemMock |
|
| 340 | ->expects($this->once()) |
|
| 341 | ->method('isMiss') |
|
| 342 | ->will($this->returnValue(true)); |
|
| 343 | ||
| 344 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler'); |
|
| 345 | $this->persistenceHandlerMock |
|
| 346 | ->expects($this->once()) |
|
| 347 | ->method('locationHandler') |
|
| 348 | ->will($this->returnValue($innerHandlerMock)); |
|
| 349 | ||
| 350 | $innerHandlerMock |
|
| 351 | ->expects($this->once()) |
|
| 352 | ->method('loadLocationsByContent') |
|
| 353 | ->with(44, 2) |
|
| 354 | ->will($this->returnValue(array(new Location(array('id' => 33))))); |
|
| 355 | ||
| 356 | $cacheItemMock |
|
| 357 | ->expects($this->once()) |
|
| 358 | ->method('set') |
|
| 359 | ->with(array(33)) |
|
| 360 | ->will($this->returnValue($cacheItemMock)); |
|
| 361 | ||
| 362 | $cacheItemMock |
|
| 363 | ->expects($this->once()) |
|
| 364 | ->method('save') |
|
| 365 | ->with(); |
|
| 366 | ||
| 367 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 368 | $handler->loadLocationsByContent(44, 2); |
|
| 369 | } |
|
| 370 | ||
| 371 | /** |
|
| 372 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| @@ 216-267 (lines=52) @@ | ||
| 213 | /** |
|
| 214 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|
| 215 | */ |
|
| 216 | public function testLoadCacheIsMiss() |
|
| 217 | { |
|
| 218 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 219 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 220 | $this->cacheMock |
|
| 221 | ->expects($this->once()) |
|
| 222 | ->method('getItem') |
|
| 223 | ->with('section', 33) |
|
| 224 | ->will($this->returnValue($cacheItemMock)); |
|
| 225 | ||
| 226 | $cacheItemMock |
|
| 227 | ->expects($this->once()) |
|
| 228 | ->method('isMiss') |
|
| 229 | ->will($this->returnValue(true)); |
|
| 230 | ||
| 231 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler'); |
|
| 232 | $this->persistenceHandlerMock |
|
| 233 | ->expects($this->once()) |
|
| 234 | ->method('sectionHandler') |
|
| 235 | ->will($this->returnValue($innerHandlerMock)); |
|
| 236 | ||
| 237 | $innerHandlerMock |
|
| 238 | ->expects($this->once()) |
|
| 239 | ->method('load') |
|
| 240 | ->with(33) |
|
| 241 | ->will( |
|
| 242 | $this->returnValue( |
|
| 243 | new SPISection( |
|
| 244 | array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet') |
|
| 245 | ) |
|
| 246 | ) |
|
| 247 | ); |
|
| 248 | ||
| 249 | $cacheItemMock |
|
| 250 | ->expects($this->once()) |
|
| 251 | ->method('set') |
|
| 252 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Section')) |
|
| 253 | ->will($this->returnValue($cacheItemMock)); |
|
| 254 | ||
| 255 | $cacheItemMock |
|
| 256 | ->expects($this->once()) |
|
| 257 | ->method('save') |
|
| 258 | ->with(); |
|
| 259 | ||
| 260 | $cacheItemMock |
|
| 261 | ->expects($this->once()) |
|
| 262 | ->method('get') |
|
| 263 | ->will($this->returnValue(null)); |
|
| 264 | ||
| 265 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 266 | $handler->load(33); |
|
| 267 | } |
|
| 268 | ||
| 269 | /** |
|
| 270 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|