public function EntityTypeFilterTest::testFilter in Replication 8.2
Same name and namespace in other branches
- 8 tests/src/Unit/Plugin/ReplicationFilter/EntityTypeFilterTest.php \Drupal\Tests\replication\Unit\Plugin\ReplicationFilter\EntityTypeFilterTest::testFilter()
Test filtering entity types.
@dataProvider filterTestProvider
Parameters
string $types: The types filter parameter.
string $expected: The expected return value from the filter method.
File
- tests/
src/ Unit/ Plugin/ ReplicationFilter/ EntityTypeFilterTest.php, line 26
Class
- EntityTypeFilterTest
- Tests that the entity type filter parses parameters correctly.
Namespace
Drupal\Tests\replication\Unit\Plugin\ReplicationFilterCode
public function testFilter($types, $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(EntityTypeFilter::class)
->disableOriginalConstructor()
->setMethods([
'getConfiguration',
])
->getMock();
$configuration = [
'types' => $types,
];
$filter
->method('getConfiguration')
->willReturn($configuration);
$entity = $this
->getMock(EntityInterface::class);
$entity
->method('getEntityTypeId')
->willReturn('node');
$entity
->method('bundle')
->willReturn('article');
$value = $filter
->filter($entity);
$this
->assertEquals($expected, $value);
}