You are here

protected function PbfBaseTest::createComplexArticle in Permissions by field 8

Create a Node with multiple Pbf fields filled.

All the arrays passed as parameters must be with the same size.

Parameters

string $title: The node title.

array $fields_name: An array of field_name to populate.

array $target_id: An array of target_id. target_id must be integer.

array $grant_public: An array of boolean.

array $grant_view: An array of boolean.

array $grant_update: An array of boolean.

array $grant_delete: An array of boolean.

Return value

\Drupal\node\NodeInterface The Node created.

File

tests/src/Functional/PbfBaseTest.php, line 698

Class

PbfBaseTest
General setup and helper function for testing pbf module.

Namespace

Drupal\Tests\pbf\Functional

Code

protected function createComplexArticle($title, $fields_name = [], $target_id = [], $grant_public = [], $grant_view = [], $grant_update = [], $grant_delete = []) {
  $values = array(
    'type' => 'article',
    'title' => $title,
    'body' => [
      'value' => 'Content body for ' . $title,
    ],
  );
  foreach ($fields_name as $key => $field_name) {
    $values[$field_name] = [
      'target_id' => $target_id[$key],
      'grant_public' => $grant_public[$key],
      'grant_view' => $grant_view[$key],
      'grant_update' => $grant_update[$key],
      'grant_delete' => $grant_delete[$key],
    ];
  }
  return $this
    ->drupalCreateNode($values);
}