You are here

protected function FreelinkingPrepopulateTest::setUp in Freelinking 4.0.x

Same name in this branch
  1. 4.0.x modules/freelinking_prepopulate/tests/src/Functional/FreelinkingPrepopulateTest.php \Drupal\Tests\freelinking_prepopulate\Functional\FreelinkingPrepopulateTest::setUp()
  2. 4.0.x modules/freelinking_prepopulate/tests/src/Unit/Plugin/freelinking/FreelinkingPrepopulateTest.php \Drupal\Tests\freelinking_prepopulate\Unit\Plugin\freelinking\FreelinkingPrepopulateTest::setUp()
Same name and namespace in other branches
  1. 8.3 modules/freelinking_prepopulate/tests/src/Unit/Plugin/freelinking/FreelinkingPrepopulateTest.php \Drupal\Tests\freelinking_prepopulate\Unit\Plugin\freelinking\FreelinkingPrepopulateTest::setUp()

Overrides UnitTestCase::setUp

File

modules/freelinking_prepopulate/tests/src/Unit/Plugin/freelinking/FreelinkingPrepopulateTest.php, line 22

Class

FreelinkingPrepopulateTest
Tests FreelinkingPrepopulate freelinking plugin.

Namespace

Drupal\Tests\freelinking_prepopulate\Unit\Plugin\freelinking

Code

protected function setUp() : void {

  // Mocks returning content types.
  $nodeTypeProphet = $this
    ->prophesize('\\Drupal\\Core\\Entity\\EntityInterface');
  $nodeTypeProphet
    ->id()
    ->willReturn('page');
  $nodeTypeStorageProphet = $this
    ->prophesize('\\Drupal\\Core\\Config\\Entity\\ConfigEntityStorageInterface');
  $nodeTypeStorageProphet
    ->loadMultiple()
    ->willReturn([
    'page' => $nodeTypeProphet
      ->reveal(),
  ]);

  // Mocks the entity type manager.
  $entityTypeManagerProphet = $this
    ->prophesize('\\Drupal\\Core\\Entity\\EntityTypeManagerInterface');
  $entityTypeManagerProphet
    ->getStorage('node_type')
    ->willReturn($nodeTypeStorageProphet
    ->reveal());
  $entityTypeManager = $entityTypeManagerProphet
    ->reveal();

  // Mocks the entity field manager.
  $entityFieldManagerProphet = $this
    ->prophesize('\\Drupal\\Core\\Entity\\EntityFieldManagerInterface');
  $entityFieldManagerProphet
    ->getFieldDefinitions('node', 'page');

  // Mocks the module handler interface.
  $moduleHandlerProphet = $this
    ->prophesize('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $container = new ContainerBuilder();
  $container
    ->set('entity_type.manager', $entityTypeManager);
  $container
    ->set('entity_field.manager', $entityFieldManagerProphet
    ->reveal());
  $container
    ->set('module_handler', $moduleHandlerProphet
    ->reveal());
  \Drupal::setContainer($container);
}