public function BiblioNodeCreationTestCase::testBiblioNodeCreation in Bibliography Module 7
Same name and namespace in other branches
- 7.2 tests/biblio.test \BiblioNodeCreationTestCase::testBiblioNodeCreation()
Create a biblio node and verify its consistency in the database.
File
- tests/
BiblioNodeCreationTestCase.test, line 31
Class
- BiblioNodeCreationTestCase
- Test biblio node creation.
Code
public function testBiblioNodeCreation() {
// Create a node.
$edit = array();
$edit["biblio_type"] = '101';
$this
->drupalPost('node/add/biblio', $edit, t('Next'));
// Check that the next step of the form appears.
$this
->assertOptionSelected('edit-biblio-type', '101');
$this
->assertFieldById('edit-title');
$this
->assertFieldById('edit-biblio-year');
$this
->assertRaw('Year of Publication ' . theme('form_required_marker'), t('Form required marker appears for "Year of Publication".'));
$edit = array(
'title' => $this
->randomString(32),
);
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertRaw('
Year of Publication field is required (on the <em class="placeholder">Publication</em> tab).', t('Custom "field is required" validation message appears.'));
$edit = array(
'title' => $this
->randomString(32),
'biblio_year' => '2009',
'biblio_contributors[0][name]' => 'Kevin Brown',
'biblio_contributors[1][name]' => 'Martin Clark',
'biblio_contributors[2][name]' => 'George Wei',
'biblio_keywords' => 'architecture, building, wood',
);
$this
->drupalPost(NULL, $edit, t('Save'));
// Check that the Basic page has been created.
$this
->assertRaw(t('!post %title has been created.', array(
'!post' => 'Biblio',
'%title' => $edit["title"],
)), t('Biblio entry created.'));
// Check that the node exists in the database.
$node = $this
->drupalGetNodeByTitle($edit['title']);
$keywordstring = implode(', ', $node->biblio_keywords);
$this
->assertIdentical($keywordstring, 'architecture, building, wood', t('Keywords are present on the biblio node.'));
$this
->assertTrue($node, t('Node found in database.'));
}