public function UuidResolverTest::testResolveWithEntity in Drupal 9
Same name and namespace in other branches
- 8 core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest::testResolveWithEntity()
- 10 core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest::testResolveWithEntity()
Tests resolve() when a UUID corresponds to an entity.
File
- core/
modules/ serialization/ tests/ src/ Unit/ EntityResolver/ UuidResolverTest.php, line 87
Class
- UuidResolverTest
- @coversDefaultClass \Drupal\serialization\EntityResolver\UuidResolver @group serialization
Namespace
Drupal\Tests\serialization\Unit\EntityResolverCode
public function testResolveWithEntity() {
$uuid = '392eab92-35c2-4625-872d-a9dab4da008e';
$entity = $this
->createMock('Drupal\\Core\\Entity\\EntityInterface');
$entity
->expects($this
->once())
->method('id')
->will($this
->returnValue(1));
$this->entityRepository
->expects($this
->once())
->method('loadEntityByUuid')
->with('test_type', $uuid)
->will($this
->returnValue($entity));
$normalizer = $this
->createMock('Drupal\\serialization\\EntityResolver\\UuidReferenceInterface');
$normalizer
->expects($this
->once())
->method('getUuid')
->with([])
->will($this
->returnValue($uuid));
$this
->assertSame(1, $this->resolver
->resolve($normalizer, [], 'test_type'));
}