You are here

public function BiblioWebTestCase::createNode in Bibliography Module 7

Same name and namespace in other branches
  1. 6.2 tests/biblio.test \BiblioWebTestCase::createNode()
  2. 7.2 tests/biblio.test \BiblioWebTestCase::createNode()

Create a test node.

8 calls to BiblioWebTestCase::createNode()
BiblioContributorWebTestCase::testBiblioUpdateContributors in tests/BiblioContributorWebTestCase.test
BiblioImportExportWebTestCase::testBiblioBibtexFileImport in tests/BiblioImportExportWebTestCase.test
BiblioImportExportWebTestCase::testBiblioNodeExport in tests/BiblioImportExportWebTestCase.test
BiblioImportExportWebTestCase::testBiblioRISFileImport in tests/BiblioImportExportWebTestCase.test
BiblioImportExportWebTestCase::testBiblioTaggedFileImport in tests/BiblioImportExportWebTestCase.test

... See full list

File

tests/BiblioWebTestCase.test, line 89

Class

BiblioWebTestCase
Base class used by other tests.

Code

public 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',
    // This replaces the default type.
    'type' => 'biblio',
    // This appends a new field.
    'biblio_type' => $type,
    '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;
}