function DBTNGExampleUnitTestCase::testUI
Test the UI.
File
-
dbtng_example/
dbtng_example.test, line 48
Class
- DBTNGExampleUnitTestCase
- Default test case for the dbtng_example module.
Code
public function testUI() {
// Test the basic list.
$this->drupalGet('examples/dbtng');
$this->assertPattern("/John[td\\/<>\\w]+Doe/", "Text 'John Doe' found in table");
// Test the add tab.
// Add the new entry.
$this->drupalPost('examples/dbtng/add', array(
'name' => 'Some',
'surname' => 'Anonymous',
'age' => 33,
), t('Add'));
// Now find the new entry.
$this->drupalGet('examples/dbtng');
$this->assertPattern("/Some[td\\/<>\\w]+Anonymous/", "Text 'Some Anonymous' found in table");
// Try the update tab.
// Find out the pid of our "anonymous" guy.
$result = dbtng_example_entry_load(array(
'surname' => 'Anonymous',
));
$this->drupalGet("examples/dbtng");
$this->assertEqual(count($result), 1, 'Found one entry in the table with surname = "Anonymous".');
$entry = $result[0];
unset($entry->uid);
$entry->name = 'NewFirstName';
$this->drupalPost('examples/dbtng/update', (array) $entry, t('Update'));
// Now find the new entry.
$this->drupalGet('examples/dbtng');
$this->assertPattern("/NewFirstName[td\\/<>\\w]+Anonymous/", "Text 'NewFirstName Anonymous' found in table");
// Try the advanced tab.
$this->drupalGet('examples/dbtng/advanced');
$rows = $this->xpath("//*[@id='block-system-main']/div/table[1]/tbody/tr");
$this->assertEqual(count($rows), 1, "One row found in advanced view");
$this->assertFieldByXPath("//*[@id='block-system-main']/div/table[1]/tbody/tr/td[4]", "Roe", "Name 'Roe' Exists in advanced list");
//Test the grouping tab
$this->drupalGet('examples/dbtng/grouping_list');
$this->assertPattern("/John[td\\/<>\\w]+2/", "Text 'John' found in table with 2 count");
//Now add new entry
$this->drupalPost('examples/dbtng/add', array(
'name' => 'Some',
'surname' => 'Anonymous',
'age' => 31,
), t('Add'));
$this->drupalGet('examples/dbtng/grouping_list');
$this->assertPattern("/Some[td\\/<>\\w]+1/", "Text 'Some' found in table with 1 count");
}