| @@ 148-184 (lines=37) @@ | ||
| 145 | /** |
|
| 146 | * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::load |
|
| 147 | */ |
|
| 148 | public function testLoadHasCache() |
|
| 149 | { |
|
| 150 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 151 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 152 | $this->cacheMock |
|
| 153 | ->expects($this->once()) |
|
| 154 | ->method('getItem') |
|
| 155 | ->with('language', 2) |
|
| 156 | ->will($this->returnValue($cacheItemMock)); |
|
| 157 | ||
| 158 | $cacheItemMock |
|
| 159 | ->expects($this->once()) |
|
| 160 | ->method('get') |
|
| 161 | ->will( |
|
| 162 | $this->returnValue( |
|
| 163 | new SPILanguage( |
|
| 164 | array('id' => 2, 'name' => 'English (UK)', 'languageCode' => 'eng-GB') |
|
| 165 | ) |
|
| 166 | ) |
|
| 167 | ); |
|
| 168 | ||
| 169 | $cacheItemMock |
|
| 170 | ->expects($this->once()) |
|
| 171 | ->method('isMiss') |
|
| 172 | ->will($this->returnValue(false)); |
|
| 173 | ||
| 174 | $this->persistenceHandlerMock |
|
| 175 | ->expects($this->never()) |
|
| 176 | ->method('contentLanguageHandler'); |
|
| 177 | ||
| 178 | $cacheItemMock |
|
| 179 | ->expects($this->never()) |
|
| 180 | ->method('set'); |
|
| 181 | ||
| 182 | $handler = $this->persistenceCacheHandler->contentLanguageHandler(); |
|
| 183 | $handler->load(2); |
|
| 184 | } |
|
| 185 | ||
| 186 | /** |
|
| 187 | * @covers eZ\Publish\Core\Persistence\Cache\ContentLanguageHandler::loadAll |
|
| @@ 376-412 (lines=37) @@ | ||
| 373 | /** |
|
| 374 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::load |
|
| 375 | */ |
|
| 376 | public function testLoadHasCache() |
|
| 377 | { |
|
| 378 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 379 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 380 | $this->cacheMock |
|
| 381 | ->expects($this->once()) |
|
| 382 | ->method('getItem') |
|
| 383 | ->with('contentType', 55) |
|
| 384 | ->will($this->returnValue($cacheItemMock)); |
|
| 385 | ||
| 386 | $cacheItemMock |
|
| 387 | ->expects($this->once()) |
|
| 388 | ->method('isMiss') |
|
| 389 | ->will($this->returnValue(false)); |
|
| 390 | ||
| 391 | $this->persistenceHandlerMock |
|
| 392 | ->expects($this->never()) |
|
| 393 | ->method('contentTypeHandler'); |
|
| 394 | ||
| 395 | $cacheItemMock |
|
| 396 | ->expects($this->once()) |
|
| 397 | ->method('get') |
|
| 398 | ->will( |
|
| 399 | $this->returnValue( |
|
| 400 | new SPIType( |
|
| 401 | array('id' => 55, 'name' => 'Forum', 'identifier' => 'forum') |
|
| 402 | ) |
|
| 403 | ) |
|
| 404 | ); |
|
| 405 | ||
| 406 | $cacheItemMock |
|
| 407 | ->expects($this->never()) |
|
| 408 | ->method('set'); |
|
| 409 | ||
| 410 | $handler = $this->persistenceCacheHandler->contentTypeHandler(); |
|
| 411 | $handler->load(55); |
|
| 412 | } |
|
| 413 | ||
| 414 | /** |
|
| 415 | * @covers eZ\Publish\Core\Persistence\Cache\ContentTypeHandler::loadByIdentifier |
|
| @@ 262-298 (lines=37) @@ | ||
| 259 | /** |
|
| 260 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::load |
|
| 261 | */ |
|
| 262 | public function testLoadHasCache() |
|
| 263 | { |
|
| 264 | $this->loggerMock->expects($this->never())->method($this->anything()); |
|
| 265 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 266 | $this->cacheMock |
|
| 267 | ->expects($this->once()) |
|
| 268 | ->method('getItem') |
|
| 269 | ->with('section', 33) |
|
| 270 | ->will($this->returnValue($cacheItemMock)); |
|
| 271 | ||
| 272 | $cacheItemMock |
|
| 273 | ->expects($this->once()) |
|
| 274 | ->method('isMiss') |
|
| 275 | ->will($this->returnValue(false)); |
|
| 276 | ||
| 277 | $this->persistenceHandlerMock |
|
| 278 | ->expects($this->never()) |
|
| 279 | ->method('sectionHandler'); |
|
| 280 | ||
| 281 | $cacheItemMock |
|
| 282 | ->expects($this->once()) |
|
| 283 | ->method('get') |
|
| 284 | ->will( |
|
| 285 | $this->returnValue( |
|
| 286 | new SPISection( |
|
| 287 | array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet') |
|
| 288 | ) |
|
| 289 | ) |
|
| 290 | ); |
|
| 291 | ||
| 292 | $cacheItemMock |
|
| 293 | ->expects($this->never()) |
|
| 294 | ->method('set'); |
|
| 295 | ||
| 296 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 297 | $handler->load(33); |
|
| 298 | } |
|
| 299 | ||
| 300 | /** |
|
| 301 | * @covers eZ\Publish\Core\Persistence\Cache\SectionHandler::loadAll |
|
| @@ 472-509 (lines=38) @@ | ||
| 469 | /** |
|
| 470 | * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRole |
|
| 471 | */ |
|
| 472 | public function testCreateRole() |
|
| 473 | { |
|
| 474 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 475 | ||
| 476 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\User\\Handler'); |
|
| 477 | $this->persistenceHandlerMock |
|
| 478 | ->expects($this->once()) |
|
| 479 | ->method('userHandler') |
|
| 480 | ->will($this->returnValue($innerHandlerMock)); |
|
| 481 | ||
| 482 | $innerHandlerMock |
|
| 483 | ->expects($this->once()) |
|
| 484 | ->method('createRole') |
|
| 485 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\User\\RoleCreateStruct')) |
|
| 486 | ->will( |
|
| 487 | $this->returnValue( |
|
| 488 | new Role( |
|
| 489 | ['id' => 33, 'name' => 'Editors', 'identifier' => 'intranet', 'status' => Role::STATUS_DEFINED] |
|
| 490 | ) |
|
| 491 | ) |
|
| 492 | ); |
|
| 493 | ||
| 494 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 495 | $this->cacheMock |
|
| 496 | ->expects($this->never()) |
|
| 497 | ->method('getItem'); |
|
| 498 | ||
| 499 | $cacheItemMock |
|
| 500 | ->expects($this->never()) |
|
| 501 | ->method('set'); |
|
| 502 | ||
| 503 | $cacheItemMock |
|
| 504 | ->expects($this->never()) |
|
| 505 | ->method('get'); |
|
| 506 | ||
| 507 | $handler = $this->persistenceCacheHandler->userHandler(); |
|
| 508 | $handler->createRole(new User\RoleCreateStruct()); |
|
| 509 | } |
|
| 510 | ||
| 511 | /** |
|
| 512 | * @covers eZ\Publish\Core\Persistence\Cache\UserHandler::createRoleDraft |
|