You are here

class ArrayExporterTest in Loft Data Grids 7.2

Hierarchy

Expanded class hierarchy of ArrayExporterTest

File

vendor/aklump/loft_data_grids/tests/phpunit/ArrayExporterTest.php, line 11
Tests for the ArrayExporter class

Namespace

AKlump\LoftDataGrids
View source
class ArrayExporterTest extends ExporterBase {
  public function testDateTimeObjectHandling() {
    $this
      ->assertDateHandlerWorks(function ($date) {
      return array(
        'date' => $date,
      );
    });
  }
  public function testSaveFile() {
    $data = new ExportData();
    $data
      ->add('do', 're');
    $this->exporter
      ->setData($data);
    $this
      ->assertMethodSaveFile();
    $control = '<?php
array (
  0 =>
  array (
    0 =>
    array (
      \'do\' => \'re\',
    ),
  ),
);
';
    $this
      ->assertSandboxFileContents($control);
  }
  public function testPrunePage() {
    $obj = clone $this->exporter;
    $obj
      ->addSetting('prune', true);
    $data = new ExportData();
    $data
      ->add('name', 'Bob');
    $this
      ->assertSame(array(
      'name' => 'Bob',
    ), $obj
      ->setData($data)
      ->export());
  }
  public function testExportPage0() {
    $control = json_decode('[[{"Order No.":1181,"Customer Billing Country":"US","California Taxed Purchase Amount":0}]]', true);
    $subject = $this->exporter
      ->export(0);
    $this
      ->assertSame($control, $subject);
  }
  public function testExportPage1() {
    $control = json_decode('[[{"Order No.":"1182","Transaction Date":"11\\/7\\/13","Customer Name":"Hope, Roberta"}]]', true);
    $subject = $this->exporter
      ->export(1);
    $this
      ->assertSame($control, $subject);
  }
  public function testExportAllPages() {
    $control = json_decode('[[{"Order No.":1181,"Customer Billing Country":"US","California Taxed Purchase Amount":0}],[{"Order No.":"1182","Transaction Date":"11\\/7\\/13","Customer Name":"Hope, Roberta"}]]', true);
    $subject = $this->exporter
      ->export();
    $this
      ->assertSame($control, $subject);
  }
  public function testInfoValues() {
    $info = $this->exporter
      ->getInfo();
    $this
      ->assertSame('.php', $info['extension']);
  }
  public function setUp() {
    parent::setUp();
    $this->exporter = new ArrayExporter($this->data);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ArrayExporterTest::setUp public function Overrides ExporterBase::setUp
ArrayExporterTest::testDateTimeObjectHandling public function
ArrayExporterTest::testExportAllPages public function
ArrayExporterTest::testExportPage0 public function
ArrayExporterTest::testExportPage1 public function
ArrayExporterTest::testInfoValues public function
ArrayExporterTest::testPrunePage public function
ArrayExporterTest::testSaveFile public function
ExporterBase::assertDateHandlerWorks public function
ExporterBase::assertMethodSaveFile public function Make sure that saveFile creates a file and returns the path.
ExporterBase::assertSandboxFileContents public function
ExporterBase::assertSandboxFileEquals public function Compare the sandbox file against it's control file.
ExporterBase::tearDown public function
ExporterBase::testCompileReturnsSelf public function
ExporterBase::testInfo public function
ExporterBase::testSaveFileToUnwriteableDirThrows public function @expectedException RuntimeException