/**
  * @param bool $editable
  * @param bool $onlyEdit
  * @param string $expectedResult
  * @return void
  * @dataProvider renderDataProvider
  */
 public function testRender($editable, $onlyEdit, $expectedResult)
 {
     $value = 'some value';
     $keyValue = 'key';
     $this->columnMock->expects($this->once())->method('getEditable')->willReturn($editable);
     $this->columnMock->expects($this->any())->method('getEditOnly')->willReturn($onlyEdit);
     $this->columnMock->expects($this->any())->method('getIndex')->willReturn($keyValue);
     $this->columnMock->expects($this->any())->method('getId')->willReturn('test');
     $this->dataObjectMock->expects($this->any())->method('getData')->with($keyValue)->willReturn($value);
     $this->renderer->setColumn($this->columnMock);
     $this->assertEquals($expectedResult, $this->renderer->render($this->dataObjectMock));
 }
Esempio n. 2
0
 /**
  * Renders grid column
  *
  * @param   \Magento\Framework\DataObject $row
  * @return  string
  */
 public function render(\Magento\Framework\DataObject $row)
 {
     $encodedUrl = $this->_urlHelper->getEncodedUrl();
     if (!$row->getIsRead()) {
         return sprintf('<a href="%s">%s</a> | <a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $this->getUrl('*/*/markAsRead/', ['_current' => true, 'id' => $row->getId()]), __('Mark as Read'), $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
     } else {
         return sprintf('<a href="%s" onClick="deleteConfirm(\'%s\',this.href); return false;">%s</a>', $this->getUrl('*/*/remove/', ['_current' => true, 'id' => $row->getId(), \Magento\Framework\App\ActionInterface::PARAM_NAME_URL_ENCODED => $encodedUrl]), __('Are you sure?'), __('Remove'));
     }
     return parent::render($row);
 }