public function PageContextTest::testGetAllWithSetPageContextTitle in Acquia Lift Connector 8
Tests the getAll() method, with setPageContextTitle().
@covers ::getAll @covers ::setPageContextTitle
File
- tests/
src/ Unit/ Service/ Context/ PageContextTest.php, line 145 - Contains \Drupal\Tests\acquia_lift\Service\Context\PageContextTest.
Class
- PageContextTest
- PageContextTest Test.
Namespace
Drupal\Tests\acquia_lift\Service\ContextCode
public function testGetAllWithSetPageContextTitle() {
$page_context = new PageContext($this->configFactory, $this->entityTypeManager);
// Test set markup title.
$title = [
'#markup' => '<div><a>My Page Title</a></div>',
'#allowed_tags' => [
'a',
],
];
$page_context
->setPageContextTitle($title);
$all_page_context = $page_context
->getAll();
$expected_page_context = [
'content_title' => '<a>My Page Title</a>',
'content_type' => 'page',
'page_type' => 'content page',
'content_section' => '',
'content_keywords' => '',
'post_id' => '',
'published_date' => '',
'thumbnail_url' => '',
'persona' => '',
'engagement_score' => 1,
'author' => '',
'evalSegments' => TRUE,
'trackingId' => '',
];
$this
->assertEquals($expected_page_context, $all_page_context);
// Test set string title.
$title = 'My Page Title';
$page_context
->setPageContextTitle($title);
$all_page_context = $page_context
->getAll();
$expected_page_context = [
'content_title' => 'My Page Title',
'content_type' => 'page',
'page_type' => 'content page',
'content_section' => '',
'content_keywords' => '',
'post_id' => '',
'published_date' => '',
'thumbnail_url' => '',
'persona' => '',
'engagement_score' => 1,
'author' => '',
'evalSegments' => TRUE,
'trackingId' => '',
];
$this
->assertEquals($expected_page_context, $all_page_context);
// Test set NULL title.
$page_context
->setPageContextTitle(NULL);
$all_page_context = $page_context
->getAll();
$expected_page_context = [
'content_title' => '',
'content_type' => 'page',
'page_type' => 'content page',
'content_section' => '',
'content_keywords' => '',
'post_id' => '',
'published_date' => '',
'thumbnail_url' => '',
'persona' => '',
'engagement_score' => 1,
'author' => '',
'evalSegments' => TRUE,
'trackingId' => '',
];
$this
->assertEquals($expected_page_context, $all_page_context);
}