| @@ 98-143 (lines=46) @@ | ||
| 95 | /** |
|
| 96 | * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| 97 | */ |
|
| 98 | public function testLoadCacheIsMiss() |
|
| 99 | { |
|
| 100 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 101 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 102 | $this->cacheMock |
|
| 103 | ->expects($this->once()) |
|
| 104 | ->method('getItem') |
|
| 105 | ->with('language', 2) |
|
| 106 | ->will($this->returnValue($cacheItemMock)); |
|
| 107 | ||
| 108 | $cacheItemMock |
|
| 109 | ->expects($this->once()) |
|
| 110 | ->method('get') |
|
| 111 | ->will($this->returnValue(null)); |
|
| 112 | ||
| 113 | $cacheItemMock |
|
| 114 | ->expects($this->once()) |
|
| 115 | ->method('isMiss') |
|
| 116 | ->will($this->returnValue(true)); |
|
| 117 | ||
| 118 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Language\\Handler'); |
|
| 119 | $this->persistenceHandlerMock |
|
| 120 | ->expects($this->once()) |
|
| 121 | ->method('contentLanguageHandler') |
|
| 122 | ->will($this->returnValue($innerHandlerMock)); |
|
| 123 | ||
| 124 | $innerHandlerMock |
|
| 125 | ->expects($this->once()) |
|
| 126 | ->method('load') |
|
| 127 | ->with(2) |
|
| 128 | ->will( |
|
| 129 | $this->returnValue( |
|
| 130 | new SPILanguage( |
|
| 131 | array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB') |
|
| 132 | ) |
|
| 133 | ) |
|
| 134 | ); |
|
| 135 | ||
| 136 | $cacheItemMock |
|
| 137 | ->expects($this->once()) |
|
| 138 | ->method('set') |
|
| 139 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Language')); |
|
| 140 | ||
| 141 | $handler = $this->persistenceCacheHandler->contentLanguageHandler(); |
|
| 142 | $handler->load(2); |
|
| 143 | } |
|
| 144 | ||
| 145 | /** |
|
| 146 | * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| @@ 326-371 (lines=46) @@ | ||
| 323 | /** |
|
| 324 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| 325 | */ |
|
| 326 | public function testLoadCacheIsMiss() |
|
| 327 | { |
|
| 328 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 329 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 330 | $this->cacheMock |
|
| 331 | ->expects($this->once()) |
|
| 332 | ->method('getItem') |
|
| 333 | ->with('contentType', 55) |
|
| 334 | ->will($this->returnValue($cacheItemMock)); |
|
| 335 | ||
| 336 | $cacheItemMock |
|
| 337 | ->expects($this->once()) |
|
| 338 | ->method('get') |
|
| 339 | ->will($this->returnValue(null)); |
|
| 340 | ||
| 341 | $cacheItemMock |
|
| 342 | ->expects($this->once()) |
|
| 343 | ->method('isMiss') |
|
| 344 | ->will($this->returnValue(true)); |
|
| 345 | ||
| 346 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Type\\Handler'); |
|
| 347 | $this->persistenceHandlerMock |
|
| 348 | ->expects($this->once()) |
|
| 349 | ->method('contentTypeHandler') |
|
| 350 | ->will($this->returnValue($innerHandlerMock)); |
|
| 351 | ||
| 352 | $innerHandlerMock |
|
| 353 | ->expects($this->once()) |
|
| 354 | ->method('load') |
|
| 355 | ->with(55) |
|
| 356 | ->will( |
|
| 357 | $this->returnValue( |
|
| 358 | new SPIType( |
|
| 359 | array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum') |
|
| 360 | ) |
|
| 361 | ) |
|
| 362 | ); |
|
| 363 | ||
| 364 | $cacheItemMock |
|
| 365 | ->expects($this->once()) |
|
| 366 | ->method('set') |
|
| 367 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Type')); |
|
| 368 | ||
| 369 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 370 | $handler->load(55); |
|
| 371 | } |
|
| 372 | ||
| 373 | /** |
|
| 374 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| @@ 206-245 (lines=40) @@ | ||
| 203 | /** |
|
| 204 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| 205 | */ |
|
| 206 | public function testLoadParentLocationsForDraftContentIsMiss() |
|
| 207 | { |
|
| 208 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 209 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 210 | $this->cacheMock |
|
| 211 | ->expects($this->once()) |
|
| 212 | ->method('getItem') |
|
| 213 | ->with('content', 'locations', '44', 'parentLocationsForDraftContent') |
|
| 214 | ->will($this->returnValue($cacheItemMock)); |
|
| 215 | ||
| 216 | $cacheItemMock |
|
| 217 | ->expects($this->once()) |
|
| 218 | ->method('get') |
|
| 219 | ->will($this->returnValue(null)); |
|
| 220 | ||
| 221 | $cacheItemMock |
|
| 222 | ->expects($this->once()) |
|
| 223 | ->method('isMiss') |
|
| 224 | ->will($this->returnValue(true)); |
|
| 225 | ||
| 226 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler'); |
|
| 227 | $this->persistenceHandlerMock |
|
| 228 | ->expects($this->once()) |
|
| 229 | ->method('locationHandler') |
|
| 230 | ->will($this->returnValue($innerHandlerMock)); |
|
| 231 | ||
| 232 | $innerHandlerMock |
|
| 233 | ->expects($this->once()) |
|
| 234 | ->method('loadParentLocationsForDraftContent') |
|
| 235 | ->with(44) |
|
| 236 | ->will($this->returnValue(array(new Location(array('id' => 33))))); |
|
| 237 | ||
| 238 | $cacheItemMock |
|
| 239 | ->expects($this->once()) |
|
| 240 | ->method('set') |
|
| 241 | ->with(array(33)); |
|
| 242 | ||
| 243 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 244 | $handler->loadParentLocationsForDraftContent(44); |
|
| 245 | } |
|
| 246 | ||
| 247 | /** |
|
| 248 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadParentLocationsForDraftContent |
|
| @@ 308-347 (lines=40) @@ | ||
| 305 | /** |
|
| 306 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| 307 | */ |
|
| 308 | public function testLoadLocationsByContentWithRootIsMiss() |
|
| 309 | { |
|
| 310 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 311 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 312 | $this->cacheMock |
|
| 313 | ->expects($this->once()) |
|
| 314 | ->method('getItem') |
|
| 315 | ->with('content', 'locations', '44', 'root', '2') |
|
| 316 | ->will($this->returnValue($cacheItemMock)); |
|
| 317 | ||
| 318 | $cacheItemMock |
|
| 319 | ->expects($this->once()) |
|
| 320 | ->method('get') |
|
| 321 | ->will($this->returnValue(null)); |
|
| 322 | ||
| 323 | $cacheItemMock |
|
| 324 | ->expects($this->once()) |
|
| 325 | ->method('isMiss') |
|
| 326 | ->will($this->returnValue(true)); |
|
| 327 | ||
| 328 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Location\\Handler'); |
|
| 329 | $this->persistenceHandlerMock |
|
| 330 | ->expects($this->once()) |
|
| 331 | ->method('locationHandler') |
|
| 332 | ->will($this->returnValue($innerHandlerMock)); |
|
| 333 | ||
| 334 | $innerHandlerMock |
|
| 335 | ->expects($this->once()) |
|
| 336 | ->method('loadLocationsByContent') |
|
| 337 | ->with(44, 2) |
|
| 338 | ->will($this->returnValue(array(new Location(array('id' => 33))))); |
|
| 339 | ||
| 340 | $cacheItemMock |
|
| 341 | ->expects($this->once()) |
|
| 342 | ->method('set') |
|
| 343 | ->with(array(33)); |
|
| 344 | ||
| 345 | $handler = $this->persistenceCacheHandler->locationHandler(); |
|
| 346 | $handler->loadLocationsByContent(44, 2); |
|
| 347 | } |
|
| 348 | ||
| 349 | /** |
|
| 350 | * @covers eZ\Publish\Core\Persistence\Cache\LocationHandler::loadLocationsByContent |
|
| @@ 212-257 (lines=46) @@ | ||
| 209 | /** |
|
| 210 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|
| 211 | */ |
|
| 212 | public function testLoadCacheIsMiss() |
|
| 213 | { |
|
| 214 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 215 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 216 | $this->cacheMock |
|
| 217 | ->expects($this->once()) |
|
| 218 | ->method('getItem') |
|
| 219 | ->with('section', 33) |
|
| 220 | ->will($this->returnValue($cacheItemMock)); |
|
| 221 | ||
| 222 | $cacheItemMock |
|
| 223 | ->expects($this->once()) |
|
| 224 | ->method('isMiss') |
|
| 225 | ->will($this->returnValue(true)); |
|
| 226 | ||
| 227 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\Section\\Handler'); |
|
| 228 | $this->persistenceHandlerMock |
|
| 229 | ->expects($this->once()) |
|
| 230 | ->method('sectionHandler') |
|
| 231 | ->will($this->returnValue($innerHandlerMock)); |
|
| 232 | ||
| 233 | $innerHandlerMock |
|
| 234 | ->expects($this->once()) |
|
| 235 | ->method('load') |
|
| 236 | ->with(33) |
|
| 237 | ->will( |
|
| 238 | $this->returnValue( |
|
| 239 | new SPISection( |
|
| 240 | array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet') |
|
| 241 | ) |
|
| 242 | ) |
|
| 243 | ); |
|
| 244 | ||
| 245 | $cacheItemMock |
|
| 246 | ->expects($this->once()) |
|
| 247 | ->method('set') |
|
| 248 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\Section')); |
|
| 249 | ||
| 250 | $cacheItemMock |
|
| 251 | ->expects($this->once()) |
|
| 252 | ->method('get') |
|
| 253 | ->will($this->returnValue(null)); |
|
| 254 | ||
| 255 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 256 | $handler->load(33); |
|
| 257 | } |
|
| 258 | ||
| 259 | /** |
|
| 260 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|