You are here

class JSONExporterTest in Loft Data Grids 7.2

Hierarchy

  • class \AKlump\LoftDataGrids\ExporterBase extends \AKlump\LoftDataGrids\PHPUnit_Framework_TestCase

Expanded class hierarchy of JSONExporterTest

File

vendor/aklump/loft_data_grids/tests/phpunit/JSONExporterTest.php, line 11
Tests for the JSONExporter class

Namespace

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

}

Members

Namesort descending Modifiers Type Description Overrides
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
JSONExporterTest::setUp public function Overrides ExporterBase::setUp
JSONExporterTest::testDateTimeObjectHandling public function
JSONExporterTest::testExportAllPages public function
JSONExporterTest::testExportPage0 public function
JSONExporterTest::testExportPage1 public function
JSONExporterTest::testInfoValues public function
JSONExporterTest::testPrunePage public function