You are here

public function RelationshipNormalizerValueTest::testRasterizeValueFails in JSON:API 8

@covers ::rasterizeValue

File

tests/src/Unit/Normalizer/Value/RelationshipNormalizerValueTest.php, line 310

Class

RelationshipNormalizerValueTest
@coversDefaultClass \Drupal\jsonapi\Normalizer\Value\RelationshipNormalizerValue @group jsonapi

Namespace

Drupal\Tests\jsonapi\Unit\Normalizer\Value

Code

public function testRasterizeValueFails() {
  $uid1 = $this
    ->prophesize(FieldItemNormalizerValue::class);
  $uid1
    ->rasterizeValue()
    ->willReturn(1);
  $link_manager = $this
    ->prophesize(LinkManager::class);
  $link_manager
    ->getEntityLink(Argument::any(), Argument::any(), Argument::type('array'), Argument::type('string'))
    ->willReturn('dummy_entity_link');
  $this
    ->setExpectedException(\RuntimeException::class, 'Unexpected normalizer item value for this Drupal\\jsonapi\\Normalizer\\Value\\RelationshipNormalizerValue.');
  new RelationshipNormalizerValue(AccessResult::allowed(), [
    $uid1
      ->reveal(),
  ], 1, [
    'link_manager' => $link_manager
      ->reveal(),
    'host_entity_id' => 'lorem',
    'resource_type' => new ResourceType($this
      ->randomMachineName(), $this
      ->randomMachineName(), NULL),
    'field_name' => 'ipsum',
  ]);
}