You are here

class XMLExporterTest in Loft Data Grids 7.2

Hierarchy

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

Expanded class hierarchy of XMLExporterTest

File

vendor/aklump/loft_data_grids/tests/phpunit/XMLExporterTest.php, line 11
Tests for the XMLExporter class

Namespace

AKlump\LoftDataGrids
View source
class XMLExporterTest extends ExporterBase {
  public function testDateTimeObjectHandling() {
    $this
      ->assertDateHandlerWorks(function ($date) {
      return '<?xml version="1.0"?>
<data><page id="0"><record id="0"><date>' . $date . '</date></record></page></data>
';
    });
  }
  public function testCData() {
    $data = new ExportData();
    $data
      ->add('title', '<h1>Some</h1>');
    $this->exporter
      ->setData($data);
    $control = '<?xml version="1.0"?>
<data><page id="0"><record id="0"><title><![CDATA[&lt;h1&gt;Some&lt;/h1&gt;]]></title></record></page></data>
';
    $this
      ->assertSame($control, $this->exporter
      ->export());
  }
  public function testOutput0() {
    $control = '<?xml version="1.0"?>
<data><page id="0"><record id="0"><order_no_>1181</order_no_><customer_billing_country>US</customer_billing_country><california_taxed_purchase_amount>0</california_taxed_purchase_amount></record></page></data>
';
    $subject = $this->exporter
      ->export(0);
    $this
      ->assertSame($control, $subject);
  }
  public function testOutput1() {
    $control = '<?xml version="1.0"?>
<data><page id="1"><record id="0"><order_no_>1182</order_no_><transaction_date>11/7/13</transaction_date><customer_name>Hope, Roberta</customer_name></record></page></data>
';
    $subject = $this->exporter
      ->export(1);
    $this
      ->assertSame($control, $subject);
  }
  public function testOutput() {
    $control = '<?xml version="1.0"?>
<data><page id="0"><record id="0"><order_no_>1181</order_no_><customer_billing_country>US</customer_billing_country><california_taxed_purchase_amount>0</california_taxed_purchase_amount></record></page><page id="1"><record id="0"><order_no_>1182</order_no_><transaction_date>11/7/13</transaction_date><customer_name>Hope, Roberta</customer_name></record></page></data>
';
    $subject = $this->exporter
      ->export();
    $this
      ->assertSame($control, $subject);
    $this
      ->assertMethodSaveFile();
    $this
      ->assertSandboxFileContents($control);
  }
  public function testInfoValues() {
    $info = $this->exporter
      ->getInfo();
    $this
      ->assertSame('.xml', $info['extension']);
  }
  public function setUp() {
    parent::setUp();
    $this->exporter = new XMLExporter($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
XMLExporterTest::setUp public function Overrides ExporterBase::setUp
XMLExporterTest::testCData public function
XMLExporterTest::testDateTimeObjectHandling public function
XMLExporterTest::testInfoValues public function
XMLExporterTest::testOutput public function
XMLExporterTest::testOutput0 public function
XMLExporterTest::testOutput1 public function