You are here

private function PageContextTest::getNode in Acquia Lift Connector 8.4

Same name and namespace in other branches
  1. 8.3 tests/src/Unit/Service/Context/PageContextTest.php \Drupal\Tests\acquia_lift\Unit\Service\Context\PageContextTest::getNode()

Get Node.

Parameters

integer $id:

Return value

Drupal\node\NodeInterface|\PHPUnit\Framework\MockObject\MockObject

4 calls to PageContextTest::getNode()
PageContextTest::testPopulateHtmlHeadWithNode in tests/src/Unit/Service/Context/PageContextTest.php
Tests the populate method, populateHtmlHead() sub method, with a Node.
PageContextTest::testPopulateHtmlHeadWithNodeAndArrayTitle in tests/src/Unit/Service/Context/PageContextTest.php
Tests the populate() method, populateHtmlHead() sub method, with a Node and array title.
PageContextTest::testPopulateHtmlHeadWithNodeAndFields in tests/src/Unit/Service/Context/PageContextTest.php
Tests the populate() method, populateHtmlHead() sub method, with a Node and fields.
PageContextTest::testPopulateHtmlHeadWithNodeAndSimpleTitle in tests/src/Unit/Service/Context/PageContextTest.php
Tests the populate() method, populateHtmlHead() sub method, with a Node and simple title.

File

tests/src/Unit/Service/Context/PageContextTest.php, line 489

Class

PageContextTest
PageContextTest Test.

Namespace

Drupal\Tests\acquia_lift\Unit\Service\Context

Code

private function getNode($id = 90210) {
  $field_country = $this
    ->createMock('Drupal\\Core\\Field\\BaseFieldDefinition');
  $field_tags = $this
    ->createMock('Drupal\\Core\\Field\\BaseFieldDefinition');
  $node = $this
    ->createMock('Drupal\\node\\NodeInterface');
  $field_country_handler_settings = [
    'target_bundles' => [
      'tracked_content_vocabulary',
    ],
  ];
  $field_tags_handler_settings = [
    'target_bundles' => [
      'tracked_keyword_vocabulary',
    ],
  ];
  $node
    ->expects($this
    ->once())
    ->method('getType')
    ->willReturn('article');
  $node
    ->expects($this
    ->once())
    ->method('getTitle')
    ->willReturn('My Title');
  $node
    ->expects($this
    ->once())
    ->method('getCreatedTime')
    ->willReturn('a_published_time');
  $node
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn($id);
  $node
    ->expects($this
    ->once())
    ->method('uuid')
    ->willReturn('ecf826eb-3ef0-4aa6-aae2-9f6e5886bbb6');
  $field_country
    ->expects($this
    ->once())
    ->method('getSetting')
    ->with('handler_settings')
    ->willReturn($field_country_handler_settings);
  $field_tags
    ->expects($this
    ->once())
    ->method('getSetting')
    ->with('handler_settings')
    ->willReturn($field_tags_handler_settings);
  $node->field_country = $field_country;
  $node->field_tags = $field_tags;
  return $node;
}