public function EntityFinderTest::testFindEntitiesWithBundleRestriction in Feeds 8.3
@covers ::findEntities @covers ::getBundleKey
File
- tests/
src/ Unit/ EntityFinderTest.php, line 116
Class
- EntityFinderTest
- @coversDefaultClass \Drupal\feeds\EntityFinder @group feeds
Namespace
Drupal\Tests\feeds\UnitCode
public function testFindEntitiesWithBundleRestriction() {
$entity_type = $this
->prophesize(EntityTypeInterface::class);
$entity_type
->getKey('bundle')
->willReturn('type')
->shouldBeCalled();
$this->entityTypeManager
->getDefinition('foo')
->willReturn($entity_type
->reveal())
->shouldBeCalled();
// Entity query.
$entity_query = $this
->prophesize(QueryInterface::class);
$entity_query
->condition('type', [
'qux',
], 'IN')
->willReturn($entity_query);
$entity_query
->range(0, 1)
->willReturn($entity_query);
$entity_query
->condition('field_ref', 1)
->willReturn($entity_query);
$entity_query
->execute()
->willReturn([
16,
]);
$this->entityStorage
->getQuery()
->willReturn($entity_query)
->shouldBeCalled();
$entity_ids = $this
->createEntityFinderInstance()
->findEntities('foo', 'field_ref', 1, [
'qux',
]);
$this
->assertEquals([
16,
], $entity_ids);
}