You are here

public function FrxCrosstabTest::testFrxCrosstab in Forena Reports 8

Test Crosstab Renderer

File

tests/src/Unit/Renderer/FrxCrosstabTest.php, line 65

Class

FrxCrosstabTest
@group Forena @require module forena @coversDefaultClass \Drupal\forena\FrxPlugin\Renderer\FrxXML

Namespace

Drupal\Tests\forena\Unit\Renderer

Code

public function testFrxCrosstab() {

  // Generate the crosstab
  $data = $this
    ->dataManager()
    ->data('test/crosstab_data');
  $this
    ->pushData($data);
  $elements = $this
    ->render('\\Drupal\\forena\\FrxPlugin\\Renderer\\FrxCrosstab', $this->doc, 'table');
  $this
    ->popData();

  // Assertions
  $this
    ->assertGreaterThan(0, count($elements), $elements);
  $element = $elements[0];
  $this
    ->assertEquals('table', $element['#type']);
  $rows = $element['#rows'];
  $this
    ->assertEquals(2, count($rows), "Correct row grouping count returned");
  $data_rows = $this
    ->arrayData($rows);
  $AL = $data_rows[0];
  $CA = $data_rows[1];
  $header_data[] = $element['#header'];
  $headers = $this
    ->arrayData($header_data);
  $h = $headers[0];
  $this
    ->assertEquals(4, count($h));
  $this
    ->assertEquals(4, count($AL), "Correct Number of columns AL");
  $this
    ->assertEquals(4, count($CA), "Correct number of columns CA");
  $this
    ->assertEquals('State', $h[0]);
  $this
    ->assertEquals('Male', $h[1]);
  $this
    ->assertEquals('Female', $h[2]);
  $this
    ->assertEquals('Unknown', $h[3]);
}