Commit f39ce716 authored by Tino Goratsch's avatar Tino Goratsch

- added unit tests for the Nl2pColumnRenderer

parent 31aa0738
......@@ -26,11 +26,9 @@ class Nl2pColumnRenderer extends AbstractColumnRenderer
/**
* @inheritdoc
*/
public function fetchDataAndRenderColumn(array $column, array $dbResultRow, $identifier, $primaryKey)
protected function getDbValueIfExists(array $dbResultRow, $field)
{
$value = $this->getValue($column, $dbResultRow);
return $this->render($column, $this->stringFormatter->nl2p($value));
return isset($dbResultRow[$field]) ? $this->stringFormatter->nl2p($dbResultRow[$field]) : null;
}
/**
......
<?php
class Nl2pColumnRendererTest extends AbstractColumnRendererTest
{
/**
* @var \ACP3\Core\Helpers\StringFormatter
*/
protected $stringFormatter;
protected function setUp()
{
$this->stringFormatter = new \ACP3\Core\Helpers\StringFormatter();
$this->columnRenderer = new \ACP3\Core\Helpers\DataGrid\ColumnRenderer\Nl2pColumnRenderer($this->stringFormatter);
parent::setUp();
}
public function testValidField()
{
$this->columnData = array_merge($this->columnData, [
'fields' => ['text']
]);
$this->dbData = [
'text' => 'Lorem Ipsum'
];
$expected = '<td><p>Lorem Ipsum</p></td>';
$this->compareResults($expected, $this->columnData, $this->dbData);
}
public function testValidFieldWithMultipleLines()
{
$this->columnData = array_merge($this->columnData, [
'fields' => ['text']
]);
$this->dbData = [
'text' => "Lorem Ipsum\n\nDolor"
];
$expected = "<td><p>Lorem Ipsum</p>\n<p>Dolor</p></td>";
$this->compareResults($expected, $this->columnData, $this->dbData);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment