class DevelGenerateManagerTest in Devel 8
@coversDefaultClass \Drupal\devel_generate\DevelGeneratePluginManager @group devel_generate
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\devel_generate\DevelGenerateManagerTest
Expanded class hierarchy of DevelGenerateManagerTest
File
- devel_generate/
tests/ src/ DevelGenerateManagerTest.php, line 23
Namespace
Drupal\Tests\devel_generateView source
class DevelGenerateManagerTest extends UnitTestCase {
/**
* The plugin discovery.
*
* @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $discovery;
/**
* A list of devel generate plugin definitions.
*
* @var array
*/
protected $definitions = array(
'devel_generate_example' => array(
'id' => 'devel_generate_example',
'class' => 'Drupal\\devel_generate_example\\Plugin\\DevelGenerate\\ExampleDevelGenerate',
'url' => 'devel_generate_example',
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
// Mock a Discovery object to replace AnnotationClassDiscovery.
$this->discovery = $this
->getMock('Drupal\\Component\\Plugin\\Discovery\\DiscoveryInterface');
$this->discovery
->expects($this
->any())
->method('getDefinitions')
->will($this
->returnValue($this->definitions));
}
/**
* Test creating an instance of the DevelGenerateManager.
*/
public function testCreateInstance() {
$namespaces = new \ArrayObject(array(
'Drupal\\devel_generate_example' => realpath(dirname(__FILE__) . '/../../../modules/devel_generate_example/lib'),
));
$cache_backend = $this
->getMock('Drupal\\Core\\Cache\\CacheBackendInterface');
$module_handler = $this
->getMock('Drupal\\Core\\Extension\\ModuleHandlerInterface');
$manager = new TestDevelGeneratePluginManager($namespaces, $cache_backend, $module_handler);
$manager
->setDiscovery($this->discovery);
$example_instance = $manager
->createInstance('devel_generate_example');
$plugin_def = $example_instance
->getPluginDefinition();
$this
->assertInstanceOf('Drupal\\devel_generate_example\\Plugin\\DevelGenerate\\ExampleDevelGenerate', $example_instance);
$this
->assertArrayHasKey('url', $plugin_def);
$this
->assertTrue($plugin_def['url'] == 'devel_generate_example');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DevelGenerateManagerTest:: |
protected | property | A list of devel generate plugin definitions. | |
DevelGenerateManagerTest:: |
protected | property | The plugin discovery. | |
DevelGenerateManagerTest:: |
protected | function |
Overrides UnitTestCase:: |
|
DevelGenerateManagerTest:: |
public | function | Test creating an instance of the DevelGenerateManager. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed 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. |