function UuidResolverTest::testResolveNoEntity

Same name in other branches
  1. 9 core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest::testResolveNoEntity()
  2. 10 core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest::testResolveNoEntity()
  3. 11.x core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest::testResolveNoEntity()

Test resolve() with correct interface but no matching entity for the UUID.

File

core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php, line 67

Class

UuidResolverTest
@coversDefaultClass \Drupal\serialization\EntityResolver\UuidResolver @group serialization

Namespace

Drupal\Tests\serialization\Unit\EntityResolver

Code

public function testResolveNoEntity() {
    $uuid = '392eab92-35c2-4625-872d-a9dab4da008e';
    $this->entityRepository
        ->expects($this->once())
        ->method('loadEntityByUuid')
        ->with('test_type')
        ->will($this->returnValue(NULL));
    $normalizer = $this->createMock('Drupal\\serialization\\EntityResolver\\UuidReferenceInterface');
    $normalizer->expects($this->once())
        ->method('getUuid')
        ->with([])
        ->will($this->returnValue($uuid));
    $this->assertNull($this->resolver
        ->resolve($normalizer, [], 'test_type'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.