You are here

public function ReplicationFilterTest::testUuidsFilter in Replication 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/ReplicationFilterTest.php \Drupal\Tests\replication\Functional\ReplicationFilterTest::testUuidsFilter()

Test filtering the changeset by UUIDs.

File

tests/src/Functional/ReplicationFilterTest.php, line 51

Class

ReplicationFilterTest
Tests replication filters.

Namespace

Drupal\Tests\replication\Functional

Code

public function testUuidsFilter() {
  $container = \Drupal::getContainer();
  $changes_factory = $container
    ->get('replication.changes_factory');
  $workspace = Workspace::create([
    'machine_name' => 'default',
    'type' => 'basic',
  ]);
  $workspace
    ->save();
  $entity1 = Node::create([
    'type' => 'article',
    'title' => 'Test Entity 1',
    'uid' => $this->user
      ->id(),
  ]);
  $entity1->workspace = $workspace;
  $entity1
    ->save();
  $entity2 = Node::create([
    'type' => 'article',
    'title' => 'Test Entity 2',
    'uid' => $this->user
      ->id(),
  ]);
  $entity2->workspace = $workspace;
  $entity2
    ->save();
  $parameters = [
    'uuids' => [
      $entity1
        ->uuid(),
    ],
  ];
  $changes = $changes_factory
    ->get($workspace)
    ->filter('uuid')
    ->parameters($parameters)
    ->getNormal();
  $this
    ->assertCount(1, $changes, 'Expect there is 1 entity in the changeset for UUIDs filter.');
}