class EditorConfigEntityUnitTest in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/editor/tests/src/Unit/EditorConfigEntityUnitTest.php \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest
@coversDefaultClass \Drupal\editor\Entity\Editor @group editor
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \Drupal\Tests\PHPUnit_Framework_TestCase
- class \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest
Expanded class hierarchy of EditorConfigEntityUnitTest
File
- core/
modules/ editor/ tests/ src/ Unit/ EditorConfigEntityUnitTest.php, line 18 - Contains \Drupal\Tests\editor\Unit\EditorConfigEntityUnitTest.
Namespace
Drupal\Tests\editor\UnitView source
class EditorConfigEntityUnitTest extends UnitTestCase {
/**
* The entity type used for testing.
*
* @var \Drupal\Core\Entity\EntityTypeInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityType;
/**
* The entity manager used for testing.
*
* @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $entityManager;
/**
* The ID of the type of the entity under test.
*
* @var string
*/
protected $entityTypeId;
/**
* The UUID generator used for testing.
*
* @var \Drupal\Component\Uuid\UuidInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $uuid;
/**
* The editor plugin manager used for testing.
*
* @var \Drupal\editor\Plugin\EditorManager|\PHPUnit_Framework_MockObject_MockObject
*/
protected $editorPluginManager;
/**
* Editor plugin ID.
*
* @var string
*/
protected $editorId;
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->editorId = $this
->randomMachineName();
$this->entityTypeId = $this
->randomMachineName();
$this->entityType = $this
->getMock('\\Drupal\\Core\\Entity\\EntityTypeInterface');
$this->entityType
->expects($this
->any())
->method('getProvider')
->will($this
->returnValue('editor'));
$this->entityManager = $this
->getMock('\\Drupal\\Core\\Entity\\EntityManagerInterface');
$this->entityManager
->expects($this
->any())
->method('getDefinition')
->with($this->entityTypeId)
->will($this
->returnValue($this->entityType));
$this->uuid = $this
->getMock('\\Drupal\\Component\\Uuid\\UuidInterface');
$this->editorPluginManager = $this
->getMockBuilder('Drupal\\editor\\Plugin\\EditorManager')
->disableOriginalConstructor()
->getMock();
$container = new ContainerBuilder();
$container
->set('entity.manager', $this->entityManager);
$container
->set('uuid', $this->uuid);
$container
->set('plugin.manager.editor', $this->editorPluginManager);
\Drupal::setContainer($container);
}
/**
* @covers ::calculateDependencies
*/
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']);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
EditorConfigEntityUnitTest:: |
protected | property | Editor plugin ID. | |
EditorConfigEntityUnitTest:: |
protected | property | The editor plugin manager used for testing. | |
EditorConfigEntityUnitTest:: |
protected | property | The entity manager used for testing. | |
EditorConfigEntityUnitTest:: |
protected | property | The entity type used for testing. | |
EditorConfigEntityUnitTest:: |
protected | property | The ID of the type of the entity under test. | |
EditorConfigEntityUnitTest:: |
protected | property | The UUID generator used for testing. | |
EditorConfigEntityUnitTest:: |
protected | function |
Overrides UnitTestCase:: |
|
EditorConfigEntityUnitTest:: |
public | function | @covers ::calculateDependencies | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. |