You are here

public function UuidFilterTest::testFilter in Replication 8.2

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

Test filtering UUIDs.

@dataProvider filterTestProvider

File

tests/src/Unit/Plugin/ReplicationFilter/UuidFilterTest.php, line 21

Class

UuidFilterTest
Tests that the uuid filter parses parameters correctly.

Namespace

Drupal\Tests\replication\Unit\Plugin\ReplicationFilter

Code

public function testFilter($uuid, $parameter_value, $expected) {

  // Use a mock builder for the class under test to eliminate the need to
  // mock all the dependencies. The method under test uses the $configuration
  // set by the constructor, but is retrieved via a get method we can stub.
  $filter = $this
    ->getMockBuilder(UuidFilter::class)
    ->disableOriginalConstructor()
    ->setMethods([
    'getConfiguration',
  ])
    ->getMock();
  $configuration = [
    'uuids' => $parameter_value,
  ];
  $filter
    ->method('getConfiguration')
    ->willReturn($configuration);
  $entity = $this
    ->getMock(EntityInterface::class);
  $entity
    ->method('uuid')
    ->willReturn($uuid);
  $value = $filter
    ->filter($entity);
  $this
    ->assertEquals($expected, $value);
}