You are here

public function ExportDataTests::testKeys in Loft Data Grids 6.2

Same name and namespace in other branches
  1. 7.2 vendor/aklump/loft_data_grids/tests/simpletest/export_data_test.php \AKlump\LoftDataGrids\ExportDataTests::testKeys()

File

vendor/aklump/loft_data_grids/tests_simpletest/export_data_test.php, line 275
Tests for the ExportData object

Class

ExportDataTests

Namespace

AKlump\LoftDataGrids

Code

public function testKeys() {

  /**
   * Assert setting the keys as an array populates the first row
   */
  $_control_group = 'ExportData::setKeys';

  // Desired test result
  $control = array(
    'do',
    're',
    'mi',
    'fa',
  );

  // The test and result
  $object = new ExportData();
  $return = $object
    ->setKeys($control);
  $object
    ->add('do', 'C');
  $return = $object
    ->getCurrent();
  $result = array_keys($return);
  $this
    ->assertIdentical($control, $result, "Assert setting the keys populates the first row", $_control_group);

  // END ASSERT

  /**
   * Assert setting the keys as arguments populates the first row
   */
  $_control_group = 'ExportData::setKeys';

  // Desired test result
  $control = array(
    'do',
    're',
    'mi',
    'fa',
  );

  // The test and result
  $object = new ExportData();
  $return = $object
    ->setKeys('do', 're', 'mi', 'fa');
  $object
    ->add('mi', 'E');
  $return = $object
    ->getCurrent();
  $result = array_keys($return);
  $this
    ->assertIdentical($control, $result, "Assert setting the keys populates the first row", $_control_group);

  // Assert setting the keys after data exists modifies the order of data returned by get
  $control = array(
    'fa',
    'mi',
    're',
    'do',
  );
  $object
    ->setKeys($control);
  $return = $object
    ->getCurrent();
  $result = array_keys($return);
  $this
    ->assertIdentical($control, $result, "Assert setting the keys after data exists modifies the order of data returned by get", $_control_group);

  // Assert getCurrentPageId
  $control = 0;
  $result = $object
    ->getCurrentPageId();
  $this
    ->assertIdentical($control, $result, "Assert getCurrentPageId", $_control_group);

  // Assert get current page id returns after switching pages
  $control = 'my_next_page';
  $object
    ->setPage($control);
  $result = $object
    ->getCurrentPageId();
  $this
    ->assertIdentical($control, $result, "Assert get current page id returns after switching pages", $_control_group);

  // END ASSERT
}