You are here

public function PublishedFilterTest::testFilter in Replication 8.2

Same name and namespace in other branches
  1. 8 tests/src/Kernel/Plugin/ReplicationFilter/PublishedFilterTest.php \Drupal\Tests\replication\Kernel\Plugin\ReplicationFilter\PublishedFilterTest::testFilter()

Test filtering published entities.

@dataProvider filterTestProvider

Parameters

bool $include_unpublishable_entities: The plugin configuration value for including unpublishable entities.

string $entity_type_id: The entity type id of the entity to create for testing.

array $entity_values: The values with which to create the entity.

bool $expected: The expected return value from the filter function.

File

tests/src/Kernel/Plugin/ReplicationFilter/PublishedFilterTest.php, line 69

Class

PublishedFilterTest
Tests that the published filter parses parameters correctly.

Namespace

Drupal\Tests\replication\Kernel\Plugin\ReplicationFilter

Code

public function testFilter($include_unpublishable_entities, $entity_type_id, $entity_values, $expected) {

  /** @var \Drupal\replication\Plugin\ReplicationFilterManagerInterface $filter_manager */
  $filter_manager = $this->container
    ->get('plugin.manager.replication_filter');
  $configuration = [
    'include_unpublishable_entities' => $include_unpublishable_entities,
  ];
  $filter = $filter_manager
    ->createInstance('published', $configuration);
  $entity = $this->container
    ->get('entity_type.manager')
    ->getStorage($entity_type_id)
    ->create($entity_values);
  $value = $filter
    ->filter($entity);
  $this
    ->assertSame($expected, $value);
}