1 dbtng_example.test public DBTNGExampleUnitTestCase::testUI()

Test the UI.

File

modules/examples/dbtng_example/dbtng_example.test, line 37
SimpleTests for dbtng_example module.

Class

DBTNGExampleUnitTestCase
Default test case for the dbtng_example module.

Code

public function testUI() {
  // Test the basic list.
  $this->backdropGet('examples/dbtng');
  $this->assertPattern("/John[td\/<>\w]+Doe/", "Text 'John Doe' found in table");

  // Test the add tab.
  // Add the new entry.
  $this->backdropPost('examples/dbtng/add', 
  array(
    'name' => 'Some',
    'surname' => 'Anonymous',
    'age' => 33,
  ), 
  t('Add')
  );
  cache('page')->flush();
  // Now find the new entry.
  $this->backdropGet('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->backdropGet("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->backdropPost('examples/dbtng/update', (array) $entry, t('Update'));
  cache('page')->flush();
  // Now find the new entry.
  $this->backdropGet('examples/dbtng');
  $this->assertPattern("/NewFirstName[td\/<>\w]+Anonymous/", "Text 'NewFirstName Anonymous' found in table");

  // Try the advanced tab.
  $this->backdropGet('examples/dbtng/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");
}