You are here

public function EntityReferenceTest::testPrepareValueReferenceNotFound in Feeds 8.3

@covers ::prepareValue @covers ::findEntities

Tests prepareValue() method without match.

File

tests/src/Unit/Feeds/Target/EntityReferenceTest.php, line 114

Class

EntityReferenceTest
@coversDefaultClass \Drupal\feeds\Feeds\Target\EntityReference @group feeds

Namespace

Drupal\Tests\feeds\Unit\Feeds\Target

Code

public function testPrepareValueReferenceNotFound() {
  $this->entityFinder
    ->findEntities('referenceable_entity_type', 'referenceable_entity_type label', 1, [])
    ->willReturn([])
    ->shouldBeCalled();
  $method = $this
    ->getProtectedClosure($this
    ->createTargetPluginInstance(), 'prepareValue');
  $values = [
    'target_id' => 1,
  ];
  $this
    ->expectException(ReferenceNotFoundException::class, "Referenced entity not found for field <em class=\"placeholder\">referenceable_entity_type label</em> with value <em class=\"placeholder\">1</em>.");
  $method(0, $values);
}