1 database_example.test | public DatabaseExampleUnitTestCase::testUI() |
Tests the UI.
File
- modules/
examples/ database_example/ tests/ database_example.test, line 33 - SimpleTests for the Database Example module.
Class
- DatabaseExampleUnitTestCase
- Default test case for the Database Example module.
Code
public function testUI() {
// Test the basic list.
$this->backdropGet('examples/database_example');
$this->assertPattern("/John[td\/<>\w]+Doe/", "Text 'John Doe' found in table");
// Test the add tab.
// Add the new entry.
$this->backdropPost('examples/database_example/add',
array(
'name' => 'Some',
'surname' => 'Anonymous',
'age' => 33,
),
t('Add')
);
cache('page')->flush();
// Now find the new entry.
$this->backdropGet('examples/database_example');
$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 = database_example_entry_load(array('surname' => 'Anonymous'));
$this->backdropGet("examples/database_example");
$this->assertEqual(count($result), 1, 'Found one entry in the table with surname = "Anonymous".');
$entry = $result[0];
unset($entry->uid);
$entry->name = 'NewFirstName';
$this->backdropPost('examples/database_example/update', (array) $entry, t('Update'));
cache('page')->flush();
// Now find the new entry.
$this->backdropGet('examples/database_example');
$this->assertPattern("/NewFirstName[td\/<>\w]+Anonymous/", "Text 'NewFirstName Anonymous' found in table");
// Try the advanced tab.
$this->backdropGet('examples/database_example/advanced');
$rows = $this->xpath("//*[contains(@class, 'l-content')]/table[1]/tbody/tr");
$this->assertEqual(count($rows), 1, "One row found in advanced view");
$this->assertFieldByXPath("//*[contains(@class, 'l-content')]/table[1]/tbody/tr/td[4]", "Roe", "Name 'Roe' Exists in advanced list");
}