function UuidResolverTest::testResolveWithEntity
Same name in other branches
- 9 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()
- 11.x core/modules/serialization/tests/src/Unit/EntityResolver/UuidResolverTest.php \Drupal\Tests\serialization\Unit\EntityResolver\UuidResolverTest::testResolveWithEntity()
Test 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'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.