You are here

public function PbfAccessWithSynchronizationTest::setUp in Permissions by field 8

Setup and create content with Pbf field.

Overrides PbfBaseTest::setUp

File

tests/src/Functional/PbfAccessWithSynchronizationTest.php, line 39

Class

PbfAccessWithSynchronizationTest
Test access permissions with a Pbf field synchronized.

Namespace

Drupal\Tests\pbf\Functional

Code

public function setUp() {
  parent::setUp();
  $this->fieldname = 'field_pbf_group';
  $this->group_fieldname = 'field_group_user';
  $this
    ->attachPbfSynchronizedFields($this->fieldname, $this->group_fieldname);
  $this->article1 = $this
    ->createSimpleArticle('Article 1', $this->fieldname, $this->group1
    ->id(), 0, 1, 0, 0);
  $this->article2 = $this
    ->createSimpleArticle('Article 2', $this->fieldname, $this->group1
    ->id(), 0, 1, 0, 0);

  // Clear field definitions cache in order to avoid stale cache values.
  \Drupal::service('entity_field.manager')
    ->clearCachedFieldDefinitions();
  drupal_flush_all_caches();
  $node_search_plugin = $this->container
    ->get('plugin.manager.search')
    ->createInstance('node_search');

  // Update the search index.
  $node_search_plugin
    ->updateIndex();
}