protected function ContentEntityNormalizerTest::mockContainerResponseForNormalize in Acquia Content Hub 8
Mock container response for normalize().
13 calls to ContentEntityNormalizerTest::mockContainerResponseForNormalize()
- ContentEntityNormalizerTest::testNormalizeImageReferenceField in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method for image references.
- ContentEntityNormalizerTest::testNormalizeOneField in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeOneFieldMultiValued in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeReferenceField in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
- ContentEntityNormalizerTest::testNormalizeTypeReferenceField in tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php - Tests the normalize() method.
File
- tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php, line 1109
Class
- ContentEntityNormalizerTest
- PHPUnit test for the ContentEntityNormalizer class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\NormalizerCode
protected function mockContainerResponseForNormalize() {
$request_stack = $this
->createMock('Symfony\\Component\\HttpFoundation\\RequestStack');
$request = $this
->createMock('Symfony\\Component\\HttpFoundation\\Request');
$request
->method('getRequestUri')
->willReturn('http://localhost/node/1');
$request_stack
->method('getCurrentRequest')
->willReturn($request);
$url_generator = $this
->createMock('Drupal\\Core\\Routing\\UrlGeneratorInterface');
$url_generator
->method('generateFromRoute')
->with('entity.node.canonical', [
'node' => 1,
], [], FALSE)
->willReturn('http://localhost/node/1');
$entity_type = $this
->createMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$entity_type
->expects($this
->any())
->method('getKeys')
->willReturn([
'uid' => 'uid',
'id' => 'nid',
'revision' => 'vid',
'uuid' => 'uuid',
]);
$this->entityTypeManager = $this
->createMock('Drupal\\Core\\Entity\\EntityTypeManagerInterface');
$this->entityTypeManager
->method('getDefinition')
->with('node')
->willReturn($entity_type);
// Defining some services.
$this->container
->expects($this
->at(0))
->method('get')
->with('request_stack')
->willReturn($request_stack);
$this->container
->expects($this
->at(1))
->method('get')
->with('entity_type.manager')
->willReturn($this->entityTypeManager);
}