protected function ContentEntityNormalizerTest::setUp in Acquia Content Hub 8
Overrides UnitTestCase::setUp
File
- tests/
src/ Unit/ Normalizer/ ContentEntityNormalizerTest.php, line 148
Class
- ContentEntityNormalizerTest
- PHPUnit test for the ContentEntityNormalizer class.
Namespace
Drupal\Tests\acquia_contenthub\Unit\NormalizerCode
protected function setUp() {
$this->container = $this
->createMock('Drupal\\Core\\DependencyInjection\\Container');
\Drupal::setContainer($this->container);
$this->configFactory = $this
->createMock('Drupal\\Core\\Config\\ConfigFactoryInterface');
$this->configFactory
->method('get')
->willReturnCallback(function ($argument) {
if ($argument == 'acquia_contenthub.admin_settings') {
return $this
->createMockForContentHubAdminConfig();
}
elseif ($argument == 'acquia_contenthub.entity_config') {
return $this
->createMockForContentHubEntityConfig();
}
return NULL;
});
$this->loggerFactory = $this
->getMockBuilder('Drupal\\Core\\Logger\\LoggerChannelFactoryInterface')
->disableOriginalConstructor()
->getMock();
$this->contentEntityViewModesExtractor = $this
->createMock('Drupal\\acquia_contenthub\\Normalizer\\ContentEntityViewModesExtractorInterface');
$this->moduleHandler = $this
->createMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
$this->entityRepository = $this
->createMock('Drupal\\Core\\Entity\\EntityRepositoryInterface');
$this->kernel = $this
->createMock('Symfony\\Component\\HttpKernel\\HttpKernelInterface');
$this->renderer = $this
->createMock('Drupal\\Core\\Render\\RendererInterface');
$this->entityManager = $this
->getMockBuilder('Drupal\\acquia_contenthub\\EntityManager')
->disableOriginalConstructor()
->getMock();
$this->entityTypeManager = $this
->createMock('Drupal\\Core\\Entity\\EntityTypeManagerInterface');
$entity_type = $this
->prophesize(EntityTypeInterface::class);
$entity_type
->getKey('bundle')
->willReturn('type');
$entity_type
->getKey('langcode')
->willReturn('langcode');
$this->entityTypeManager
->method('getDefinition')
->willReturn($entity_type
->reveal());
$this->languageManager = $this
->createMock('Drupal\\Core\\Language\\LanguageManagerInterface');
$this->userContext = new ContentHubUserSession(AccountInterface::ANONYMOUS_ROLE);
$this->contentEntityNormalizer = new ContentEntityCdfNormalizer($this->configFactory, $this->contentEntityViewModesExtractor, $this->moduleHandler, $this->entityRepository, $this->kernel, $this->renderer, $this->entityManager, $this->entityTypeManager, $this->loggerFactory, $this->languageManager);
}