| @@ 160-196 (lines=37) @@ | ||
| 157 | /** |
|
| 158 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| 159 | */ |
|
| 160 | public function testLoadHasCache() |
|
| 161 | { |
|
| 162 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 163 | $cacheItemMock = $this->createMock(ItemInterface::class); |
|
| 164 | $this->cacheMock |
|
| 165 | ->expects($this->once()) |
|
| 166 | ->method('getItem') |
|
| 167 | ->with('language', 2) |
|
| 168 | ->will($this->returnValue($cacheItemMock)); |
|
| 169 | ||
| 170 | $cacheItemMock |
|
| 171 | ->expects($this->once()) |
|
| 172 | ->method('get') |
|
| 173 | ->will( |
|
| 174 | $this->returnValue( |
|
| 175 | new SPILanguage( |
|
| 176 | array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB') |
|
| 177 | ) |
|
| 178 | ) |
|
| 179 | ); |
|
| 180 | ||
| 181 | $cacheItemMock |
|
| 182 | ->expects($this->once()) |
|
| 183 | ->method('isMiss') |
|
| 184 | ->will($this->returnValue(false)); |
|
| 185 | ||
| 186 | $this->persistenceHandlerMock |
|
| 187 | ->expects($this->never()) |
|
| 188 | ->method('contentLanguageHandler'); |
|
| 189 | ||
| 190 | $cacheItemMock |
|
| 191 | ->expects($this->never()) |
|
| 192 | ->method('set'); |
|
| 193 | ||
| 194 | $handler = $this->persistenceCacheHandler->contentLanguageHandler(); |
|
| 195 | $handler->load(2); |
|
| 196 | } |
|
| 197 | ||
| 198 | /** |
|
| 199 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::loadAll |
|
| @@ 410-446 (lines=37) @@ | ||
| 407 | /** |
|
| 408 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| 409 | */ |
|
| 410 | public function testLoadHasCache() |
|
| 411 | { |
|
| 412 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 413 | $cacheItemMock = $this->getCacheItemMock(); |
|
| 414 | $this->cacheMock |
|
| 415 | ->expects($this->once()) |
|
| 416 | ->method('getItem') |
|
| 417 | ->with('contentType', 55) |
|
| 418 | ->will($this->returnValue($cacheItemMock)); |
|
| 419 | ||
| 420 | $cacheItemMock |
|
| 421 | ->expects($this->once()) |
|
| 422 | ->method('isMiss') |
|
| 423 | ->will($this->returnValue(false)); |
|
| 424 | ||
| 425 | $this->persistenceHandlerMock |
|
| 426 | ->expects($this->never()) |
|
| 427 | ->method('contentTypeHandler'); |
|
| 428 | ||
| 429 | $cacheItemMock |
|
| 430 | ->expects($this->once()) |
|
| 431 | ->method('get') |
|
| 432 | ->will( |
|
| 433 | $this->returnValue( |
|
| 434 | new SPIType( |
|
| 435 | array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum') |
|
| 436 | ) |
|
| 437 | ) |
|
| 438 | ); |
|
| 439 | ||
| 440 | $cacheItemMock |
|
| 441 | ->expects($this->never()) |
|
| 442 | ->method('set'); |
|
| 443 | ||
| 444 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 445 | $handler->load(55); |
|
| 446 | } |
|
| 447 | ||
| 448 | /** |
|
| 449 | * @covers \eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadByIdentifier |
|
| @@ 279-315 (lines=37) @@ | ||
| 276 | /** |
|
| 277 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|
| 278 | */ |
|
| 279 | public function testLoadHasCache() |
|
| 280 | { |
|
| 281 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 282 | $cacheItemMock = $this->createMock(ItemInterface::class); |
|
| 283 | $this->cacheMock |
|
| 284 | ->expects($this->once()) |
|
| 285 | ->method('getItem') |
|
| 286 | ->with('section', 33) |
|
| 287 | ->will($this->returnValue($cacheItemMock)); |
|
| 288 | ||
| 289 | $cacheItemMock |
|
| 290 | ->expects($this->once()) |
|
| 291 | ->method('isMiss') |
|
| 292 | ->will($this->returnValue(false)); |
|
| 293 | ||
| 294 | $this->persistenceHandlerMock |
|
| 295 | ->expects($this->never()) |
|
| 296 | ->method('sectionHandler'); |
|
| 297 | ||
| 298 | $cacheItemMock |
|
| 299 | ->expects($this->once()) |
|
| 300 | ->method('get') |
|
| 301 | ->will( |
|
| 302 | $this->returnValue( |
|
| 303 | new SPISection( |
|
| 304 | array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet') |
|
| 305 | ) |
|
| 306 | ) |
|
| 307 | ); |
|
| 308 | ||
| 309 | $cacheItemMock |
|
| 310 | ->expects($this->never()) |
|
| 311 | ->method('set'); |
|
| 312 | ||
| 313 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 314 | $handler->load(33); |
|
| 315 | } |
|
| 316 | ||
| 317 | /** |
|
| 318 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::loadAll |
|
| @@ 501-538 (lines=38) @@ | ||
| 498 | /** |
|
| 499 | * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::createRole |
|
| 500 | */ |
|
| 501 | public function testCreateRole() |
|
| 502 | { |
|
| 503 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 504 | ||
| 505 | $innerHandlerMock = $this->getSPIUserHandlerMock(); |
|
| 506 | $this->persistenceHandlerMock |
|
| 507 | ->expects($this->once()) |
|
| 508 | ->method('userHandler') |
|
| 509 | ->will($this->returnValue($innerHandlerMock)); |
|
| 510 | ||
| 511 | $innerHandlerMock |
|
| 512 | ->expects($this->once()) |
|
| 513 | ->method('createRole') |
|
| 514 | ->with($this->isInstanceOf(RoleCreateStruct::class)) |
|
| 515 | ->will( |
|
| 516 | $this->returnValue( |
|
| 517 | new Role( |
|
| 518 | ['id' => 33, 'name' => 'Editors', 'identifier' => 'intranet', 'status' => Role::STATUS_DEFINED] |
|
| 519 | ) |
|
| 520 | ) |
|
| 521 | ); |
|
| 522 | ||
| 523 | $cacheItemMock = $this->getCacheItemMock(); |
|
| 524 | $this->cacheMock |
|
| 525 | ->expects($this->never()) |
|
| 526 | ->method('getItem'); |
|
| 527 | ||
| 528 | $cacheItemMock |
|
| 529 | ->expects($this->never()) |
|
| 530 | ->method('set'); |
|
| 531 | ||
| 532 | $cacheItemMock |
|
| 533 | ->expects($this->never()) |
|
| 534 | ->method('get'); |
|
| 535 | ||
| 536 | $handler = $this->persistenceCacheHandler->userHandler(); |
|
| 537 | $handler->createRole(new User\RoleCreateStruct()); |
|
| 538 | } |
|
| 539 | ||
| 540 | /** |
|
| 541 | * @covers \eZ\Publish\Core\Persistence\Cache\UserHandler::createRoleDraft |
|