public function ReplicationFilterTest::testEntityTypeFilter in Replication 8
Same name and namespace in other branches
- 8.2 tests/src/Functional/ReplicationFilterTest.php \Drupal\Tests\replication\Functional\ReplicationFilterTest::testEntityTypeFilter()
Test filtering the changeset with the entity type filter.
File
- tests/
src/ Functional/ ReplicationFilterTest.php, line 114
Class
- ReplicationFilterTest
- Tests replication filters.
Namespace
Drupal\Tests\replication\FunctionalCode
public function testEntityTypeFilter() {
$container = \Drupal::getContainer();
$changes_factory = $container
->get('replication.changes_factory');
$this
->drupalCreateContentType([
'type' => 'article2',
'name' => 'Article2',
]);
$workspace = Workspace::create([
'machine_name' => 'default',
'type' => 'basic',
]);
$workspace
->save();
$entity1 = Node::create([
'type' => 'article',
'title' => 'Test Entity 1',
'uid' => $this->user
->id(),
'status' => TRUE,
]);
$entity1->workspace = $workspace;
$entity1
->save();
$entity2 = Node::create([
'type' => 'article2',
'title' => 'Test Entity 2',
'uid' => $this->user
->id(),
'status' => FALSE,
]);
$entity2->workspace = $workspace;
$entity2
->save();
$parameters = [
'types' => [
'node.article',
],
];
$changes = $changes_factory
->get($workspace)
->filter('entity_type')
->parameters($parameters)
->getNormal();
$this
->assertCount(1, $changes, 'Expect there is 1 entity in the changeset for entity type filter.');
}