eZ\Publish\Core\FieldType\Tests\Page\PageServiceTest::testLoadBlock PHP Method

testLoadBlock() public method

public testLoadBlock ( )
    public function testLoadBlock()
    {
        $contentId = 12;
        $blockId = 'abc0123';
        $block = new Block(array('id' => $blockId));
        $zone = new Zone(array('blocks' => array($block)));
        $page = new Page(array('zones' => array($zone)));
        $value = new Value($page);
        $field = new Field(array('value' => $value));
        $content = new Content(array('internalFields' => array($field)));
        $this->pageService->setStorageGateway($this->storageGateway);
        $this->storageGateway->expects($this->once())->method('getContentIdByBlockId')->with($blockId)->will($this->returnValue($contentId));
        $this->contentService->expects($this->once())->method('loadContent')->with($contentId)->will($this->returnValue($content));
        // Calling assertion twice to test cache (comes along with storage gateway's
        // getLocationIdByBlockId() that should be called only once. See above)
        $this->assertSame($block, $this->pageService->loadBlock($blockId));
        $this->assertSame($block, $this->pageService->loadBlock($blockId));
    }