public function ExportDataTests::testConstruct in Loft Data Grids 6.2
Same name and namespace in other branches
- 7.2 vendor/aklump/loft_data_grids/tests/simpletest/export_data_test.php \AKlump\LoftDataGrids\ExportDataTests::testConstruct()
File
- vendor/
aklump/ loft_data_grids/ tests_simpletest/ export_data_test.php, line 15 - Tests for the ExportData object
Class
Namespace
AKlump\LoftDataGridsCode
public function testConstruct() {
/**
* Assert constructing with a page sets it correctly
*/
$_control_group = 'ExportData::__construct';
$subject = 'default';
// Desired test result
$control = array(
$subject,
);
// The test and result
$object = new ExportData($subject);
$return = $object
->getAllPageIds();
$result = $return;
$this
->assertIdentical($control, $result, "Assert constructing with a page sets it correctly", $_control_group);
// Assert setting a new page before any data is written to the first page replaces the first page in the pageIds array()
$control = array(
'second',
);
$object
->setPage('second');
$result = $object
->getAllPageIds();
$this
->assertIdentical($control, $result, "Assert setting a new page appends to the page_ids array", $_control_group);
// Assert adding data and then changing page creates two page ids in the array
$control = array(
'second',
'default',
);
$object
->add('food', 'pizza');
$object
->next();
$object
->next();
$object
->setPage('default');
$result = array_values($object
->getAllPageIds());
$this
->assertIdentical($control, $result, "Assert adding data and then changing page creates two page ids in the array", $_control_group);
// Assert starting a new page returns a pointer of 0
$control = 0;
$object
->next();
$object
->setPage('third');
$result = $object
->getPointer();
$this
->assertIdentical($control, $result, "Assert starting a new page returns a pointer of 0", $_control_group);
// Assert switching back to former page returns the pointer where we left off
$control = 2;
$object
->setPage('second');
$result = $object
->getPointer();
$this
->assertIdentical($control, $result, "Assert switching back to former page returns the pointer where we left off", $_control_group);
// END ASSERT
/**
* Assert constructing with no arguments set page to 0
*/
$_control_group = 'ExportData::__construct';
// Desired test result
$control = array(
0,
);
// The test and result
$object = new ExportData();
$return = $object
->getAllPageIds();
$result = $return;
$this
->assertIdentical($control, $result, "Assert constructing with a page sets it correctly", $_control_group);
// END ASSERT
/**
* Assert the current pointer starts as 0
*/
$_control_group = 'ExportData::getPointer';
// Desired test result
$control = 0;
// The test and result
$object = new ExportData();
$return = $object
->getPointer();
$result = $return;
$this
->assertIdentical($control, $result, "Assert the current pointer starts as 0", $_control_group);
// END ASSERT
/**
* Assert the add method returns the object
*/
$_control_group = 'ExportData::add';
// Desired test result
// The test and result
$object = new ExportData();
$return = $object
->add('eyes', 'blue');
$result = is_object($return) && is_a($return, 'AKlump\\LoftDataGrids\\ExportData');
$this
->assertTrue($result, "Assert the add method returns the object", $_control_group);
// Assert the pointer did not advance after adding on value
$control = 0;
$result = $object
->getPointer();
$this
->assertIdentical($control, $result, "Assert the pointer did not advance after adding on value", $_control_group);
// Assert the next method advances the pointer
$control = 1;
$object
->next();
$result = $object
->getPointer();
$this
->assertIdentical($control, $result, "Assert the next method advances the pointer", $_control_group);
// Assert setPointer works correctly
$control = 0;
$object
->setPointer(0);
$result = $object
->getPointer();
$this
->assertIdentical($control, $result, "Assert setPointer works correctly", $_control_group);
// Assert adding a second column works
$control = array(
'eyes' => 'blue',
'hair' => 'blond',
);
$object
->add('hair', 'blond');
$result = $object
->getCurrent();
$this
->assertIdentical($control, $result, "Assert adding a second column works", $_control_group);
// END ASSERT
}