You are here

public function EditorConfigEntityUnitTest::testCalculateDependencies in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest::testCalculateDependencies()

@covers ::calculateDependencies

File

core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php, line 96
Contains \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest.

Class

EditorConfigEntityUnitTest
@coversDefaultClass \Drupal\editor\Entity\Editor @group editor

Namespace

Drupal\Tests\editor\Unit

Code

public function testCalculateDependencies() {
  $format_id = 'filter.format.test';
  $values = array(
    'editor' => $this->editorId,
    'format' => $format_id,
  );
  $plugin = $this
    ->getMockBuilder('Drupal\\editor\\Plugin\\EditorPluginInterface')
    ->disableOriginalConstructor()
    ->getMock();
  $plugin
    ->expects($this
    ->once())
    ->method('getPluginDefinition')
    ->will($this
    ->returnValue(array(
    'provider' => 'test_module',
  )));
  $plugin
    ->expects($this
    ->once())
    ->method('getDefaultSettings')
    ->will($this
    ->returnValue(array()));
  $this->editorPluginManager
    ->expects($this
    ->any())
    ->method('createInstance')
    ->with($this->editorId)
    ->will($this
    ->returnValue($plugin));
  $entity = new Editor($values, $this->entityTypeId);
  $filter_format = $this
    ->getMock('Drupal\\Core\\Config\\Entity\\ConfigEntityInterface');
  $filter_format
    ->expects($this
    ->once())
    ->method('getConfigDependencyName')
    ->will($this
    ->returnValue('filter.format.test'));
  $storage = $this
    ->getMock('Drupal\\Core\\Entity\\EntityStorageInterface');
  $storage
    ->expects($this
    ->once())
    ->method('load')
    ->with($format_id)
    ->will($this
    ->returnValue($filter_format));
  $this->entityManager
    ->expects($this
    ->once())
    ->method('getStorage')
    ->with('filter_format')
    ->will($this
    ->returnValue($storage));
  $dependencies = $entity
    ->calculateDependencies()
    ->getDependencies();
  $this
    ->assertContains('test_module', $dependencies['module']);
  $this
    ->assertContains('filter.format.test', $dependencies['config']);
}