function BiblioWebTestCase::createNode in Bibliography Module 7.2
Same name and namespace in other branches
- 6.2 tests/biblio.test \BiblioWebTestCase::createNode()
- 7 tests/BiblioWebTestCase.test \BiblioWebTestCase::createNode()
8 calls to BiblioWebTestCase::createNode()
- BiblioContributorUnitTest::testBiblioUpdateContributors in tests/
contributor.test - BiblioImportExportUnitTest::testBiblioBibtexFileImport in tests/
import.export.test - BiblioImportExportUnitTest::testBiblioNodeExport in tests/
import.export.test - BiblioImportExportUnitTest::testBiblioRISFileImport in tests/
import.export.test - BiblioImportExportUnitTest::testBiblioTaggedFileImport in tests/
import.export.test
File
- tests/
biblio.test, line 42
Class
Code
function createNode($type = 100) {
$schema = drupal_get_schema('biblio');
foreach ($schema['fields'] as $name => $values) {
if ($values['type'] == 'int') {
continue;
}
switch ($values['type']) {
case 'varchar':
$length = $values['length'];
break;
case 'text':
$length = 1000;
break;
}
$biblio_fields["{$name}"] = $name;
}
$settings = array(
'title' => 'Biblio Title',
'type' => 'biblio',
// This replaces the default type
'biblio_type' => $type,
// This appends a new field.
'biblio_year' => 2009,
'biblio_contributors' => array(
0 => array(
'name' => 'Ron J. Jeromezzzzzz',
'auth_type' => 1,
'auth_category' => 1,
),
1 => array(
'name' => 'John Smithzzzzzz',
'auth_type' => 1,
'auth_category' => 1,
),
2 => array(
'name' => 'George W. Bushzzzzzz',
'auth_type' => 1,
'auth_category' => 1,
),
),
'biblio_keywords' => array(
'biblio_keywords',
),
);
$settings = array_merge($biblio_fields, $settings);
$node = $this
->drupalCreateNode($settings);
$node = node_load($node->nid, NULL, TRUE);
foreach ($node->biblio_contributors as $author) {
$this->cids[] = $author['cid'];
}
$this->nids[] = $node->nid;
return $node;
}