protected function InstantArticleContentEntityNormalizerTest::getContentEntityNormalizer in Facebook Instant Articles 3.x
Same name and namespace in other branches
- 8.2 tests/src/Unit/InstantArticleContentEntityNormalizerTest.php \Drupal\Tests\fb_instant_articles\Unit\InstantArticleContentEntityNormalizerTest::getContentEntityNormalizer()
Helper function to create a new ContentEntityNormalizer for testing.
Parameters
array $settings: Global config settings.
array $components: Entity view display components.
string $language_direction: Language direction.
Return value
\Drupal\fb_instant_articles\Normalizer\InstantArticleContentEntityNormalizer Content entity normalizer object to test against.
3 calls to InstantArticleContentEntityNormalizerTest::getContentEntityNormalizer()
- InstantArticleContentEntityNormalizerTest::testNormalize in tests/
src/ Unit/ InstantArticleContentEntityNormalizerTest.php - Tests the normalize() method.
- InstantArticleContentEntityNormalizerTest::testNormalizeRtl in tests/
src/ Unit/ InstantArticleContentEntityNormalizerTest.php - Tests the normalize method on an RTL site.
- InstantArticleContentEntityNormalizerTest::testSupportsNormalization in tests/
src/ Unit/ InstantArticleContentEntityNormalizerTest.php - Tests the supportsNormalization() method.
File
- tests/
src/ Unit/ InstantArticleContentEntityNormalizerTest.php, line 195
Class
- InstantArticleContentEntityNormalizerTest
- Tests the fbia content entity normalizer class.
Namespace
Drupal\Tests\fb_instant_articles\UnitCode
protected function getContentEntityNormalizer(array $settings = [], array $components = [], $language_direction = LanguageInterface::DIRECTION_LTR) {
$config_factory = $this
->getConfigFactoryStub([
'fb_instant_articles.settings' => $settings,
]);
$entity_field_manager = $this
->getMockBuilder(EntityFieldManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$entity_storage = $this
->createMock(EntityStorageInterface::class);
$entity_type_manager = $this
->getMockBuilder(EntityTypeManagerInterface::class)
->disableOriginalConstructor()
->getMock();
$entity_type_manager
->method('getStorage')
->willReturn($entity_storage);
$info_parser = $this
->createMock(InfoParserInterface::class);
$module_handler = $this
->createMock(ModuleHandlerInterface::class);
$this->currentLanguage = $this
->getMockBuilder(Language::class)
->disableOriginalConstructor()
->onlyMethods([
'getDirection',
])
->getMock();
$this->currentLanguage
->expects($this
->any())
->method('getDirection')
->willReturn($language_direction);
$language_manager = $this
->getMockBuilder(LanguageManager::class)
->disableOriginalConstructor()
->onlyMethods([
'getCurrentLanguage',
])
->getMock();
$language_manager
->expects($this
->once())
->method('getCurrentLanguage')
->willReturn($this->currentLanguage);
$content_entity_normalizer = $this
->getMockBuilder(InstantArticleContentEntityNormalizer::class)
->setConstructorArgs([
$config_factory,
$entity_field_manager,
$entity_type_manager,
$info_parser,
$module_handler,
$language_manager,
])
->onlyMethods([
'getApplicableComponents',
'getApplicationVersion',
])
->getMock();
$content_entity_normalizer
->method('getApplicableComponents')
->willReturn($components);
$content_entity_normalizer
->method('getApplicationVersion')
->willReturn('8.x-2.x');
return $content_entity_normalizer;
}