You are here

private function PageContextTest::getNode in Acquia Lift Connector 8

Get Node.

Parameters

integer $id:

Return value

Drupal\node\NodeInterface|\PHPUnit_Framework_MockObject_MockObject

1 call to PageContextTest::getNode()
PageContextTest::testGetAllWithSetByNode in tests/src/Unit/Service/Context/PageContextTest.php
Tests the getAll() method, with setByNode().

File

tests/src/Unit/Service/Context/PageContextTest.php, line 318
Contains \Drupal\Tests\acquia_lift\Service\Context\PageContextTest.

Class

PageContextTest
PageContextTest Test.

Namespace

Drupal\Tests\acquia_lift\Service\Context

Code

private function getNode($id = 90210) {
  $user = $this
    ->getUser();
  $field_country = $this
    ->getMock('Drupal\\Core\\Field\\BaseFieldDefinition');
  $field_tags = $this
    ->getMock('Drupal\\Core\\Field\\BaseFieldDefinition');
  $node = $this
    ->getMock('Drupal\\node\\NodeInterface');
  $field_country_handler_settings = [
    'target_bundles' => [
      'tracked_content_vocabulary',
    ],
  ];
  $field_tags_handler_settings = [
    'target_bundles' => [
      'tracked_keyword_vocabulary',
    ],
  ];
  $node
    ->expects($this
    ->exactly(2))
    ->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('getOwner')
    ->willReturn($user);
  $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;
}