You are here

protected function TaxonomyPermissionsTestBase::createSimpleArticle in Taxonomy Permissions 8

Create an article with value for field field_term.

Parameters

string $title: The content title.

string $field_name: The Pbf field name to populate.

int|string $target_id: The target id of taxonomy term.

Return value

\Drupal\node\NodeInterface The node created.

1 call to TaxonomyPermissionsTestBase::createSimpleArticle()
TaxonomyPermissionsTestBase::setUp in src/Tests/TaxonomyPermissionsTestBase.php
Setup.

File

src/Tests/TaxonomyPermissionsTestBase.php, line 366

Class

TaxonomyPermissionsTestBase
General setup and helper function for testing taxonomy permissions module.

Namespace

Drupal\taxonomy_permissions\Tests

Code

protected function createSimpleArticle($title, $field_name = '', $target_id = NULL) {
  $values = [
    'type' => 'article',
    'title' => $title,
    'body' => [
      'value' => 'Content body for ' . $title,
    ],
  ];
  if ($field_name) {
    $values[$field_name] = [
      'target_id' => $target_id,
    ];
  }
  return $this
    ->drupalCreateNode($values);
}