| @@ 141-187 (lines=47) @@ | ||
| 138 | /** |
|
| 139 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::create |
|
| 140 | */ |
|
| 141 | public function testCreate() |
|
| 142 | { |
|
| 143 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 144 | ||
| 145 | $innerHandlerMock = $this->getSPISectionHandlerMock(); |
|
| 146 | $this->persistenceHandlerMock |
|
| 147 | ->expects($this->once()) |
|
| 148 | ->method('sectionHandler') |
|
| 149 | ->will($this->returnValue($innerHandlerMock)); |
|
| 150 | ||
| 151 | $innerHandlerMock |
|
| 152 | ->expects($this->once()) |
|
| 153 | ->method('create') |
|
| 154 | ->with('Intranet', 'intranet') |
|
| 155 | ->will( |
|
| 156 | $this->returnValue( |
|
| 157 | new SPISection( |
|
| 158 | array('id' => 33, 'name' => 'Intranet', 'identifier' => 'intranet') |
|
| 159 | ) |
|
| 160 | ) |
|
| 161 | ); |
|
| 162 | ||
| 163 | $cacheItemMock = $this->createMock(ItemInterface::class); |
|
| 164 | $this->cacheMock |
|
| 165 | ->expects($this->once()) |
|
| 166 | ->method('getItem') |
|
| 167 | ->with('section', 33) |
|
| 168 | ->will($this->returnValue($cacheItemMock)); |
|
| 169 | ||
| 170 | $cacheItemMock |
|
| 171 | ->expects($this->once()) |
|
| 172 | ->method('set') |
|
| 173 | ->with($this->isInstanceOf(SPISection::class)) |
|
| 174 | ->will($this->returnValue($cacheItemMock)); |
|
| 175 | ||
| 176 | $cacheItemMock |
|
| 177 | ->expects($this->once()) |
|
| 178 | ->method('save') |
|
| 179 | ->with(); |
|
| 180 | ||
| 181 | $cacheItemMock |
|
| 182 | ->expects($this->never()) |
|
| 183 | ->method('get'); |
|
| 184 | ||
| 185 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 186 | $handler->create('Intranet', 'intranet'); |
|
| 187 | } |
|
| 188 | ||
| 189 | /** |
|
| 190 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::delete |
|
| @@ 377-423 (lines=47) @@ | ||
| 374 | /** |
|
| 375 | * @covers \eZ\Publish\Core\Persistence\Cache\SectionHandler::update |
|
| 376 | */ |
|
| 377 | public function testUpdate() |
|
| 378 | { |
|
| 379 | $this->loggerMock->expects($this->once())->method('logCall'); |
|
| 380 | ||
| 381 | $innerHandler = $this->getSPISectionHandlerMock(); |
|
| 382 | $this->persistenceHandlerMock |
|
| 383 | ->expects($this->once()) |
|
| 384 | ->method('sectionHandler') |
|
| 385 | ->will($this->returnValue($innerHandler)); |
|
| 386 | ||
| 387 | $innerHandler |
|
| 388 | ->expects($this->once()) |
|
| 389 | ->method('update') |
|
| 390 | ->with(33, 'Old Intranet', 'old_intranet') |
|
| 391 | ->will( |
|
| 392 | $this->returnValue( |
|
| 393 | new SPISection( |
|
| 394 | array('id' => 33, 'name' => 'Old Intranet', 'identifier' => 'old_intranet') |
|
| 395 | ) |
|
| 396 | ) |
|
| 397 | ); |
|
| 398 | ||
| 399 | $cacheItemMock = $this->createMock(ItemInterface::class); |
|
| 400 | $this->cacheMock |
|
| 401 | ->expects($this->once()) |
|
| 402 | ->method('getItem') |
|
| 403 | ->with('section', 33) |
|
| 404 | ->will($this->returnValue($cacheItemMock)); |
|
| 405 | ||
| 406 | $cacheItemMock |
|
| 407 | ->expects($this->once()) |
|
| 408 | ->method('set') |
|
| 409 | ->with($this->isInstanceOf(SPISection::class)) |
|
| 410 | ->will($this->returnValue($cacheItemMock)); |
|
| 411 | ||
| 412 | $cacheItemMock |
|
| 413 | ->expects($this->once()) |
|
| 414 | ->method('save') |
|
| 415 | ->with(); |
|
| 416 | ||
| 417 | $cacheItemMock |
|
| 418 | ->expects($this->never()) |
|
| 419 | ->method('get'); |
|
| 420 | ||
| 421 | $handler = $this->persistenceCacheHandler->sectionHandler(); |
|
| 422 | $handler->update(33, 'Old Intranet', 'old_intranet'); |
|
| 423 | } |
|
| 424 | } |
|
| 425 | ||