You are here

class FrxSVGGraphTest in Forena Reports 8

Graph test. @group Forena @require module forena @coversDefaultClass \Drupal\forena\FrxPlugin\Renderer\FrxSVGGraph

Hierarchy

Expanded class hierarchy of FrxSVGGraphTest

File

tests/src/Unit/Renderer/FrxSVGGraphTest.php, line 20

Namespace

Drupal\Tests\forena\Unit\Renderer
View source
class FrxSVGGraphTest extends FrxRendererTestCase {

  // Test report.
  private $doc = '<?xml version="1.0"?>
      <!DOCTYPE root [
      <!ENTITY nbsp "&#160;">
      ]>
      <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>';

  /**
   * @param array $array
   * @return array
   * Helper function
   */
  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;
  }

  /**
   * SVGGraph
   */
  public function testFrxSvgGraph() {

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

    /** @var \Drupal\forena\FrxPlugin\Renderer\FrxSVGGraph $r */
    $r = $this->renderer;

    // Assertions
    $this
      ->assertEquals(5, count($r->graphData));
    $this
      ->assertEquals('8081', $r->graphData[0]['users']);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FrxAPI::app public function Returns containing application service
FrxAPI::currentDataContext public function Get the current data context.
FrxAPI::currentDataContextArray public function
FrxAPI::dataManager public function Returns the data manager service
FrxAPI::dataService public function Return Data Service
FrxAPI::documentManager public function Returns the fornea document manager
FrxAPI::error public function Report an error
FrxAPI::getDataContext public function Get the context of a specific id.
FrxAPI::getDocument public function Get the current document
FrxAPI::getReportFileContents public function Load the contents of a file in the report file system.
FrxAPI::innerXML function Enter description here... 1
FrxAPI::popData public function Pop data off of the stack.
FrxAPI::pushData public function Push data onto the Stack
FrxAPI::report public function Run a report with a particular format. 1
FrxAPI::reportFileSystem public function Get the current report file system.
FrxAPI::setDataContext public function Set Data context by id.
FrxAPI::setDocument public function Change to a specific document type.
FrxAPI::skins public function Get list of skins.
FrxRendererTestCase::$renderer protected property @var \Drupal\forena\FrxPlugin\Renderer\RendererInterface
FrxRendererTestCase::$report protected property @var \Drupal\forena\Report
FrxRendererTestCase::render public function
FrxSVGGraphTest::$doc private property
FrxSVGGraphTest::arrayData public function
FrxSVGGraphTest::testFrxSvgGraph public function SVGGraph
FrxTestCase::initParametersForm public function
FrxTestCase::setUp public function Mock object instantiation. Overrides UnitTestCase::setUp 2
PhpunitCompatibilityTrait::getMock Deprecated public function Returns a mock object for the specified class using the available method.
PhpunitCompatibilityTrait::setExpectedException Deprecated public function Compatibility layer for PHPUnit 6 to support PHPUnit 4 code.
UnitTestCase::$randomGenerator protected property The random generator.
UnitTestCase::$root protected property The app root. 1
UnitTestCase::assertArrayEquals protected function Asserts if two arrays are equal by sorting them first.
UnitTestCase::getBlockMockWithMachineName Deprecated protected function Mocks a block with a block plugin. 1
UnitTestCase::getClassResolverStub protected function Returns a stub class resolver.
UnitTestCase::getConfigFactoryStub public function Returns a stub config factory that behaves according to the passed array.
UnitTestCase::getConfigStorageStub public function Returns a stub config storage that returns the supplied configuration.
UnitTestCase::getContainerWithCacheTagsInvalidator protected function Sets up a container with a cache tags invalidator.
UnitTestCase::getRandomGenerator protected function Gets the random generator for the utility methods.
UnitTestCase::getStringTranslationStub public function Returns a stub translation manager that just returns the passed string.
UnitTestCase::randomMachineName public function Generates a unique random string containing letters and numbers.