Ejemplo n.º 1
0
 /**
  * Returns the content for the editable html code.
  * This method creates the tag given by $tag with the html code given
  * by $unit and $key. All links at html code will be fixed.
  * If the current renderings happens outside of the rukzuk cms edit mode,
  * all helper attributes will be removed.
  *
  * @param Unit   $unit       unit that holds the form value
  * @param mixed  $key        key of the requested form value
  * @param string $tag        tag name that will be created around the editable html code
  * @param string $attributes attributes for the created tag
  *
  * @return string
  */
 public function getEditableTag(Unit $unit, $key, $tag, $attributes = '')
 {
     $content = $this->getFormValue($unit, $key, '');
     if (is_null($this->editableHtmlTag)) {
         $this->editableHtmlTag = new EditableHtmlTag($this);
     }
     return $this->editableHtmlTag->getEditableTag($key, $tag, $attributes, $content);
 }
Ejemplo n.º 2
0
 /**
  * Checks if href replaced and data-cms attributes exists
  *
  * @test
  * @group rendering
  * @group small
  * @group dev
  *
  * @dataProvider provider_test_getEditableTag
  */
 public function test_getEditableTag($isEditMode, $key, $tag, $attributes, $rawHtml, $expectedHtml)
 {
     // ARRANGE
     $pageId1 = 'PAGE-00000000-0000-0000-0000-000000000001-PAGE';
     $pageId2 = 'PAGE-00000000-0000-0000-0000-000000000002-PAGE';
     $pageId3 = 'PAGE-00000000-0000-0000-0000-000000000003-PAGE';
     $navigationMock = $this->getNavigationMock(array('' => $this->createPageMock(''), $pageId1 => $this->createPageMock($pageId1), $pageId2 => $this->createPageMock($pageId2), $pageId3 => $this->createPageMock($pageId3)));
     $mediaId = 'MDB-00000000-0000-0000-0000-000000000001-MDB';
     $mediaItemMock = $this->createMediaItemMock($mediaId);
     $renderAPIMock = $this->createRenderAPIMock();
     $renderAPIMock->expects($this->any())->method('isEditMode')->will($this->returnValue($isEditMode));
     $renderAPIMock->expects($this->any())->method('getNavigation')->will($this->returnValue($navigationMock));
     $renderAPIMock->expects($this->any())->method('getMediaItem')->with($this->equalTo($mediaId))->will($this->returnValue($mediaItemMock));
     $editableHtmlTag = new EditableHtmlTag($renderAPIMock);
     // ACT
     $actualHtml = $editableHtmlTag->getEditableTag($key, $tag, $attributes, $rawHtml);
     // ASSERT
     $this->assertEquals($expectedHtml, $actualHtml);
 }