public function PageContextTest::testPopulateHtmlHeadWithNode in Acquia Lift Connector 8.3
Same name and namespace in other branches
- 8.4 tests/src/Unit/Service/Context/PageContextTest.php \Drupal\Tests\acquia_lift\Unit\Service\Context\PageContextTest::testPopulateHtmlHeadWithNode()
Tests the populate method, populateHtmlHead() sub method, with a Node.
@covers ::populate
File
- tests/
src/ Unit/ Service/ Context/ PageContextTest.php, line 257
Class
- PageContextTest
- PageContextTest Test.
Namespace
Drupal\Tests\acquia_lift\Unit\Service\ContextCode
public function testPopulateHtmlHeadWithNode() {
$this->requestParameterBag
->expects($this
->once())
->method('has')
->with('node')
->willReturn(TRUE);
$this->requestParameterBag
->expects($this
->once())
->method('get')
->with('node')
->willReturn($this
->getNode());
// Language mock
$this->language
->expects($this
->any())
->method('getCurrentLanguage')
->willReturn($this->languageInterface);
$page_context = new PageContext($this->configFactory, $this->entityTypeManager, $this->requestStack, $this->routeMatch, $this->titleResolver, $this->language);
$page = [];
$page_context
->populate($page);
$expected_head = $this
->toRenderArray([
'content_title' => 'My Title',
'content_type' => 'article',
'page_type' => 'node page',
'context_language' => 'fr',
'content_section' => '',
'content_keywords' => '',
'post_id' => '90210',
'content_uuid' => 'ecf826eb-3ef0-4aa6-aae2-9f6e5886bbb6',
'published_date' => 'a_published_time',
'persona' => '',
'engagement_score' => PageContext::ENGAGEMENT_SCORE_DEFAULT,
'account_id' => 'AccountId1',
'site_id' => 'SiteId1',
'contentOrigin' => '08c93130-2e45-45f6-af6d-7c02de8cd90c',
'userAccess' => 'user_access_1',
'liftAssetsURL' => 'AssetsUrl1',
'liftDecisionAPIURL' => 'decision_api_url_1',
'authEndpoint' => 'oauth_url_1',
'bootstrapMode' => 'manual',
'contentReplacementMode' => 'customized',
], 'AssetsUrl1');
$this
->assertEquals($expected_head, $page['#attached']['html_head']);
}