FrxSVGGraphTest.php in Forena Reports 8
File
tests/src/Unit/Renderer/FrxSVGGraphTest.php
View source
<?php
namespace Drupal\Tests\forena\Unit\Renderer;
use Drupal\forena\Report;
use Drupal\Tests\forena\Unit\FrxTestCase;
class FrxSVGGraphTest extends FrxRendererTestCase {
private $doc = '<?xml version="1.0"?>
<!DOCTYPE root [
<!ENTITY nbsp " ">
]>
<html xmlns:frx="urn:FrxReports">
<head>
<title>Report Title</title>
<frx:category>Category</frx:category>
<frx:fields>
</frx:fields>
</head>
<body>
<svg frx:renderer="FrxSVGGraph" frx:type="PieGraph"
frx:series="{users}" frx:label="{state} - {gender}">
</svg>
</body>
</html>';
public function arrayData(array $array) {
$new_array = [];
foreach ($array as $r => $row) {
$new_row = [];
foreach ($row as $key => $value) {
$new_row[$key] = $value['data'];
}
$new_array[] = $new_row;
}
return $new_array;
}
public function testFrxSvgGraph() {
$data = $this
->dataManager()
->data('test/crosstab_data');
$this
->pushData($data);
$elements = $this
->render('\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxSVGGraph', $this->doc, 'svg');
$this
->popData();
$r = $this->renderer;
$this
->assertEquals(5, count($r->graphData));
$this
->assertEquals('8081', $r->graphData[0]['users']);
}
}