You are here

protected function ContentHubEntityEmbedHandlerTest::setUp in Acquia Content Hub 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/ContentHubEntityEmbedHandlerTest.php, line 48

Class

ContentHubEntityEmbedHandlerTest
PHPUnit for the ContentHubEntityEmbedHandler class.

Namespace

Drupal\Tests\acquia_contenthub\Unit

Code

protected function setUp() {
  parent::setUp();

  // Setting up the Module Handler.
  $this->field = $this
    ->createMock('\\Drupal\\Core\\Field\\FieldItemListInterface');
  $this->entityTypeManager = $this
    ->createMock('\\Drupal\\Core\\Entity\\EntityTypeManagerInterface');

  // Setting up the Container.
  $this->container = $this
    ->createMock('Drupal\\Core\\DependencyInjection\\Container');
  $this->container
    ->method('get')
    ->willReturnCallback(function ($name) {
    switch ($name) {
      case 'entity_type.manager':
        return $this->entityTypeManager;
    }
    return NULL;
  });
  \Drupal::setContainer($this->container);

  // Initializing Entity Embed Handler.
  $this->entityEmbedHandler = new ContentHubEntityEmbedHandler($this->field);
}