function EditorConfigEntityUnitTest::testCalculateDependencies

Same name in other branches
  1. 9 core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest::testCalculateDependencies()
  2. 8.9.x core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest::testCalculateDependencies()
  3. 11.x 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

Class

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

Namespace

Drupal\Tests\editor\Unit

Code

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.