| @@ 158-194 (lines=37) @@ | ||
| 155 | /** |
|
| 156 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| 157 | */ |
|
| 158 | public function testLoadHasCache() |
|
| 159 | { |
|
| 160 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 161 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 162 | $this->cacheMock |
|
| 163 | ->expects($this->once()) |
|
| 164 | ->method('getItem') |
|
| 165 | ->with('language', 2) |
|
| 166 | ->will($this->returnValue($cacheItemMock)); |
|
| 167 | ||
| 168 | $cacheItemMock |
|
| 169 | ->expects($this->once()) |
|
| 170 | ->method('get') |
|
| 171 | ->will( |
|
| 172 | $this->returnValue( |
|
| 173 | new SPILanguage( |
|
| 174 | array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB') |
|
| 175 | ) |
|
| 176 | ) |
|
| 177 | ); |
|
| 178 | ||
| 179 | $cacheItemMock |
|
| 180 | ->expects($this->once()) |
|
| 181 | ->method('isMiss') |
|
| 182 | ->will($this->returnValue(false)); |
|
| 183 | ||
| 184 | $this->persistenceHandlerMock |
|
| 185 | ->expects($this->never()) |
|
| 186 | ->method('contentLanguageHandler'); |
|
| 187 | ||
| 188 | $cacheItemMock |
|
| 189 | ->expects($this->never()) |
|
| 190 | ->method('set'); |
|
| 191 | ||
| 192 | $handler = $this->persistenceCacheHandler->contentLanguageHandler(); |
|
| 193 | $handler->load(2); |
|
| 194 | } |
|
| 195 | ||
| 196 | /** |
|
| 197 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::loadAll |
|
| @@ 398-434 (lines=37) @@ | ||
| 395 | /** |
|
| 396 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| 397 | */ |
|
| 398 | public function testLoadHasCache() |
|
| 399 | { |
|
| 400 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 401 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 402 | $this->cacheMock |
|
| 403 | ->expects($this->once()) |
|
| 404 | ->method('getItem') |
|
| 405 | ->with('contentType', 55) |
|
| 406 | ->will($this->returnValue($cacheItemMock)); |
|
| 407 | ||
| 408 | $cacheItemMock |
|
| 409 | ->expects($this->once()) |
|
| 410 | ->method('isMiss') |
|
| 411 | ->will($this->returnValue(false)); |
|
| 412 | ||
| 413 | $this->persistenceHandlerMock |
|
| 414 | ->expects($this->never()) |
|
| 415 | ->method('contentTypeHandler'); |
|
| 416 | ||
| 417 | $cacheItemMock |
|
| 418 | ->expects($this->once()) |
|
| 419 | ->method('get') |
|
| 420 | ->will( |
|
| 421 | $this->returnValue( |
|
| 422 | new SPIType( |
|
| 423 | array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum') |
|
| 424 | ) |
|
| 425 | ) |
|
| 426 | ); |
|
| 427 | ||
| 428 | $cacheItemMock |
|
| 429 | ->expects($this->never()) |
|
| 430 | ->method('set'); |
|
| 431 | ||
| 432 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 433 | $handler->load(55); |
|
| 434 | } |
|
| 435 | ||
| 436 | /** |
|
| 437 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadByIdentifier |
|
| @@ 272-308 (lines=37) @@ | ||
| 269 | /** |
|
| 270 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|
| 271 | */ |
|
| 272 | public function testLoadHasCache() |
|
| 273 | { |
|
| 274 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 275 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 276 | $this->cacheMock |
|
| 277 | ->expects($this->once()) |
|
| 278 | ->method('getItem') |
|
| 279 | ->with('section', 33) |
|
| 280 | ->will($this->returnValue($cacheItemMock)); |
|
| 281 | ||
| 282 | $cacheItemMock |
|
| 283 | ->expects($this->once()) |
|
| 284 | ->method('isMiss') |
|
| 285 | ->will($this->returnValue(false)); |
|
| 286 | ||
| 287 | $this->persistenceHandlerMock |
|
| 288 | ->expects($this->never()) |
|
| 289 | ->method('sectionHandler'); |
|
| 290 | ||
| 291 | $cacheItemMock |
|
| 292 | ->expects($this->once()) |
|
| 293 | ->method('get') |
|
| 294 | ->will( |
|
| 295 | $this->returnValue( |
|
| 296 | new SPISection( |
|
| 297 | array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet') |
|
| 298 | ) |
|
| 299 | ) |
|
| 300 | ); |
|
| 301 | ||
| 302 | $cacheItemMock |
|
| 303 | ->expects($this->never()) |
|
| 304 | ->method('set'); |
|
| 305 | ||
| 306 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 307 | $handler->load(33); |
|
| 308 | } |
|
| 309 | ||
| 310 | /** |
|
| 311 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::loadAll |
|
| @@ 488-525 (lines=38) @@ | ||
| 485 | /** |
|
| 486 | * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::createRole |
|
| 487 | */ |
|
| 488 | public function testCreateRole() |
|
| 489 | { |
|
| 490 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 491 | ||
| 492 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
|
| 493 | $this->persistenceHandlerMock |
|
| 494 | ->expects($this->once()) |
|
| 495 | ->method('userHandler') |
|
| 496 | ->will($this->returnValue($innerHandlerMock)); |
|
| 497 | ||
| 498 | $innerHandlerMock |
|
| 499 | ->expects($this->once()) |
|
| 500 | ->method('createRole') |
|
| 501 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\RoleCreateStruct')) |
|
| 502 | ->will( |
|
| 503 | $this->returnValue( |
|
| 504 | new Role( |
|
| 505 | ['id' => 33, 'name' => 'Editors', 'identifier' => 'intranet', 'status' => Role::STATUS_DEFINED] |
|
| 506 | ) |
|
| 507 | ) |
|
| 508 | ); |
|
| 509 | ||
| 510 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 511 | $this->cacheMock |
|
| 512 | ->expects($this->never()) |
|
| 513 | ->method('getItem'); |
|
| 514 | ||
| 515 | $cacheItemMock |
|
| 516 | ->expects($this->never()) |
|
| 517 | ->method('set'); |
|
| 518 | ||
| 519 | $cacheItemMock |
|
| 520 | ->expects($this->never()) |
|
| 521 | ->method('get'); |
|
| 522 | ||
| 523 | $handler = $this->persistenceCacheHandler->userHandler(); |
|
| 524 | $handler->createRole(new User\RoleCreateStruct()); |
|
| 525 | } |
|
| 526 | ||
| 527 | /** |
|
| 528 | * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::createRoleDraft |
|
| @@ 355-389 (lines=35) @@ | ||
| 352 | /** |
|
| 353 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentHandler::loadVersionInfo |
|
| 354 | */ |
|
| 355 | public function testLoadVersionInfoHasCache() |
|
| 356 | { |
|
| 357 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 358 | $cacheItemMock = $this->getMock(ItemInterface::class); |
|
| 359 | $this->cacheMock |
|
| 360 | ->expects($this->once()) |
|
| 361 | ->method('getItem') |
|
| 362 | ->with('content', 'info', 2, 'versioninfo', 1) |
|
| 363 | ->will($this->returnValue($cacheItemMock)); |
|
| 364 | ||
| 365 | $cacheItemMock |
|
| 366 | ->expects($this->once()) |
|
| 367 | ->method('isMiss') |
|
| 368 | ->will($this->returnValue(false)); |
|
| 369 | ||
| 370 | $this->persistenceHandlerMock |
|
| 371 | ->expects($this->never()) |
|
| 372 | ->method('contentHandler'); |
|
| 373 | ||
| 374 | $cacheItemMock |
|
| 375 | ->expects($this->once()) |
|
| 376 | ->method('get') |
|
| 377 | ->will( |
|
| 378 | $this->returnValue( |
|
| 379 | new VersionInfo(['contentInfo' => new ContentInfo(['id' => 2]), 'versionNo' => 1]) |
|
| 380 | ) |
|
| 381 | ); |
|
| 382 | ||
| 383 | $cacheItemMock |
|
| 384 | ->expects($this->never()) |
|
| 385 | ->method('set'); |
|
| 386 | ||
| 387 | $handler = $this->persistenceCacheHandler->contentHandler(); |
|
| 388 | $handler->loadVersionInfo(2, 1); |
|
| 389 | } |
|
| 390 | ||
| 391 | /** |
|
| 392 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentHandler::setStatus |
|