| @@ 83-134 (lines=52) @@ | ||
| 80 | /** |
|
| 81 | * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| 82 | */ |
|
| 83 | public function testLoadGroup() |
|
| 84 | { |
|
| 85 | $expectedGroup = new SPIObjectStateGroup( |
|
| 86 | array( |
|
| 87 | 'id' => 1, |
|
| 88 | 'identifier' => 'test_state_group', |
|
| 89 | 'name' => 'Test State Group', |
|
| 90 | ) |
|
| 91 | ); |
|
| 92 | ||
| 93 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 94 | $this->cacheMock |
|
| 95 | ->expects($this->once()) |
|
| 96 | ->method('getItem') |
|
| 97 | ->with('objectstategroup', 1) |
|
| 98 | ->will($this->returnValue($cacheItemMock)); |
|
| 99 | $cacheItemMock |
|
| 100 | ->expects($this->once()) |
|
| 101 | ->method('get') |
|
| 102 | ->will($this->returnValue(null)); |
|
| 103 | $cacheItemMock |
|
| 104 | ->expects($this->once()) |
|
| 105 | ->method('isMiss') |
|
| 106 | ->will($this->returnValue(true)); |
|
| 107 | $cacheItemMock |
|
| 108 | ->expects($this->once()) |
|
| 109 | ->method('set') |
|
| 110 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Group')) |
|
| 111 | ->will($this->returnValue($cacheItemMock)); |
|
| 112 | $cacheItemMock |
|
| 113 | ->expects($this->once()) |
|
| 114 | ->method('save') |
|
| 115 | ->with(); |
|
| 116 | ||
| 117 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 118 | ||
| 119 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler'); |
|
| 120 | $this->persistenceHandlerMock |
|
| 121 | ->expects($this->once()) |
|
| 122 | ->method('objectStateHandler') |
|
| 123 | ->will($this->returnValue($innerHandlerMock)); |
|
| 124 | ||
| 125 | $innerHandlerMock |
|
| 126 | ->expects($this->once()) |
|
| 127 | ->method('loadGroup') |
|
| 128 | ->with(1) |
|
| 129 | ->will($this->returnValue($expectedGroup)); |
|
| 130 | ||
| 131 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 132 | $group = $handler->loadGroup(1); |
|
| 133 | $this->assertEquals($group, $expectedGroup); |
|
| 134 | } |
|
| 135 | ||
| 136 | /** |
|
| 137 | * @covers \eZ\Publish\Core\Persistence\Cache\ObjectStateHandler::loadGroup |
|
| @@ 558-610 (lines=53) @@ | ||
| 555 | /** |
|
| 556 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|
| 557 | */ |
|
| 558 | public function testLoad() |
|
| 559 | { |
|
| 560 | $expectedState = new SPIObjectState( |
|
| 561 | array( |
|
| 562 | 'id' => 1, |
|
| 563 | 'identifier' => 'test_state', |
|
| 564 | 'name' => 'Test State', |
|
| 565 | 'groupId' => 1, |
|
| 566 | ) |
|
| 567 | ); |
|
| 568 | ||
| 569 | $cacheItemMock = $this->getMock('Stash\Interfaces\ItemInterface'); |
|
| 570 | $this->cacheMock |
|
| 571 | ->expects($this->once()) |
|
| 572 | ->method('getItem') |
|
| 573 | ->with('objectstate', 1) |
|
| 574 | ->will($this->returnValue($cacheItemMock)); |
|
| 575 | $cacheItemMock |
|
| 576 | ->expects($this->once()) |
|
| 577 | ->method('get') |
|
| 578 | ->will($this->returnValue(null)); |
|
| 579 | $cacheItemMock |
|
| 580 | ->expects($this->once()) |
|
| 581 | ->method('isMiss') |
|
| 582 | ->will($this->returnValue(true)); |
|
| 583 | $cacheItemMock |
|
| 584 | ->expects($this->once()) |
|
| 585 | ->method('set') |
|
| 586 | ->with($this->isInstanceOf('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState')) |
|
| 587 | ->will($this->returnValue($cacheItemMock)); |
|
| 588 | $cacheItemMock |
|
| 589 | ->expects($this->once()) |
|
| 590 | ->method('save') |
|
| 591 | ->with(); |
|
| 592 | ||
| 593 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 594 | ||
| 595 | $innerHandlerMock = $this->getMock('eZ\\Publish\\SPI\\Persistence\\Content\\ObjectState\\Handler'); |
|
| 596 | $this->persistenceHandlerMock |
|
| 597 | ->expects($this->once()) |
|
| 598 | ->method('objectStateHandler') |
|
| 599 | ->will($this->returnValue($innerHandlerMock)); |
|
| 600 | ||
| 601 | $innerHandlerMock |
|
| 602 | ->expects($this->once()) |
|
| 603 | ->method('load') |
|
| 604 | ->with(1) |
|
| 605 | ->will($this->returnValue($expectedState)); |
|
| 606 | ||
| 607 | $handler = $this->persistenceCacheHandler->objectStateHandler(); |
|
| 608 | $state = $handler->load(1); |
|
| 609 | $this->assertEquals($state, $expectedState); |
|
| 610 | } |
|
| 611 | ||
| 612 | /** |
|
| 613 | * @covers \eZ\Publish\SPI\Persistence\Content\ObjectState\Handler::load |
|