You are here

function CSVExporterTest::__construct in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/aklump/loft_data_grids/tests/CSVExporterTest.php \AKlump\LoftDataGrids\CSVExporterTest::__construct()

File

vendor/aklump/loft_data_grids/tests/phpunit/CSVExporterTest.php, line 15
Tests for the CSVExporter class

Class

CSVExporterTest

Namespace

AKlump\LoftDataGrids

Code

function __construct() {
  $this->data = new ExportData();
  $this->records[0] = array(
    'Order No.' => '1181',
    'Transaction Date' => '11/6/13',
    'Customer Name' => 'Hope, Bob',
    'Customer Billing Address' => '22255 King Street Apt. 1Z',
    'Customer Billing City' => 'Honolulu',
    'Customer Billing State' => 'HI',
    'Customer Billing Zip' => '96813',
    'Customer Billing Country' => 'US',
    'California Taxed Purchase Amount' => 0,
    'Domestic Purchase Amount' => 20,
    'International Purchase Amount' => 0,
    'Order Status' => 'Completed',
  );
  $this->records[1] = array(
    'Order No.' => '1182',
    'Transaction Date' => '11/7/13',
    'Customer Name' => 'Hope, Roberta',
    'Customer Billing Address' => '22255 King Street Apt. 1Z',
    'Customer Billing City' => 'Honolulu',
    'Customer Billing State' => 'HI',
    'Customer Billing Zip' => '96813',
    'Customer Billing Country' => 'US',
    'California Taxed Purchase Amount' => 6,
    'Domestic Purchase Amount' => 15,
    'International Purchase Amount' => 0,
    'Order Status' => 'Completed',
  );

  // Page 1
  foreach ($this->records[0] as $key => $value) {
    $this->data
      ->add($key, $value);
  }
  $this->data
    ->next();

  // Page 2
  $this->data
    ->setPage(1);
  foreach ($this->records[1] as $key => $value) {
    $this->data
      ->add($key, $value);
  }
  $this->data
    ->next();

  // Move pointers back to 0 on all pages; return to page 0
  $this->data
    ->setPage(1);
  $this->data
    ->setPointer(0);
  $this->data
    ->setPage(0);
  $this->data
    ->setPointer(0);
  $this->exporter = new CSVExporter($this->data);
}