You are here

function TaxonomyAccessTestCase::createArticle in Taxonomy Access Control 7

Creates an article with the specified terms.

Parameters

array $autocreate: (optional) An array of term names to autocreate. Defaults to array().

array $existing: (optional) An array of existing term IDs to add.

Return value

object The node object.

1 call to TaxonomyAccessTestCase::createArticle()
TaxonomyAccessConfigTest::setUp in ./taxonomy_access.test
Sets up a Drupal site for running functional and integration tests.

File

./taxonomy_access.test, line 191
Automated tests for the Taxonomy Access Control module.

Class

TaxonomyAccessTestCase
Provides a base test class and helper methods for automated tests.

Code

function createArticle($autocreate = array(), $existing = array()) {
  $values = array();
  foreach ($autocreate as $name) {
    $values[] = array(
      'tid' => 'autocreate',
      'vid' => 1,
      'name' => $name,
      'vocabulary_machine_name' => 'tags',
    );
  }
  foreach ($existing as $tid) {
    $values[] = array(
      'tid' => $tid,
      'vid' => 1,
      'vocabulary_machine_name' => 'tags',
    );
  }

  // Bloody $langcodes.
  $values = array(
    LANGUAGE_NONE => $values,
  );
  $settings = array(
    'type' => 'article',
    'field_tags' => $values,
  );
  return $this
    ->drupalCreateNode($settings);
}