You are here

function BiblioWebTestCase::createNode in Bibliography Module 6.2

Same name and namespace in other branches
  1. 7 tests/BiblioWebTestCase.test \BiblioWebTestCase::createNode()
  2. 7.2 tests/biblio.test \BiblioWebTestCase::createNode()
6 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::testBiblioTaggedFileImport in tests/import.export.test
BiblioImportExportUnitTest::testBiblioXMLFileImport in tests/import.export.test

... See full list

File

tests/biblio.test, line 34

Class

BiblioWebTestCase

Code

function createNode($type = 100, $fields = null) {
  $biblio_fields = array();
  if (!$fields) {
    $schema = drupal_get_schema('biblio', TRUE);
    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;
    }
  }
  else {
    foreach ($fields as $name) {
      $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(
      1 => array(
        0 => array(
          'name' => 'Ron J. Jeromezzzzzz',
          'auth_type' => 1,
        ),
        1 => array(
          'name' => 'John Smithzzzzzz',
          'auth_type' => 1,
        ),
        2 => array(
          'name' => 'George W. Bushzzzzzz',
          'auth_type' => 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[1] as $author) {
    $this->cids[] = $author['cid'];
  }
  $this->nids[] = $node->nid;
  return $node;
}