class ServiceContainerCToolsIntegrationTest in Service Container 7
Same name and namespace in other branches
- 7.2 lib/Drupal/service_container/Tests/ServiceContainerCToolsIntegrationTest.php \Drupal\service_container\Tests\ServiceContainerCToolsIntegrationTest
Hierarchy
- class \Drupal\service_container\Tests\ServiceContainerIntegrationTestBase extends \Drupal\service_container\Tests\DrupalWebTestCase
- class \Drupal\service_container\Tests\ServiceContainerCToolsIntegrationTest
Expanded class hierarchy of ServiceContainerCToolsIntegrationTest
File
- lib/
Drupal/ service_container/ Tests/ ServiceContainerCToolsIntegrationTest.php, line 12 - Contains \Drupal\service_container\Tests\ServiceContainerCToolsIntegrationTest.
Namespace
Drupal\service_container\TestsView source
class ServiceContainerCToolsIntegrationTest extends ServiceContainerIntegrationTestBase {
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp('service_container_test_ctools');
$this->container = \Drupal::getContainer();
}
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'ServiceContainerCToolsIntegration',
'description' => 'Tests the \\ServiceContainer class (CTools integration)',
'group' => 'service_container',
);
}
/**
* Tests if CTools plugin types are available as services.
*/
public function testCToolsPluginTypes() {
foreach (ctools_plugin_get_plugin_type_info() as $module_name => $plugins) {
if ($module_name != 'service_container_test_ctools') {
continue;
}
foreach ($plugins as $plugin_type => $plugin_data) {
$services = array();
$services[$module_name . '.' . $plugin_type] = TRUE;
$services[$module_name . '.' . Container::underscore($plugin_type)] = TRUE;
foreach ($services as $service => $value) {
$this
->assertTrue($this->container
->has($service), "Container has plugin manager {$service} for {$module_name} / {$plugin_type}.");
}
}
}
}
/**
* Tests if a particular CTools plugin is available.
*/
public function testCToolsPlugin() {
$service = \Drupal::service('service_container_test_ctools.ServiceContainerTestCtoolsPlugin')
->createInstance('ServiceContainerTestCtoolsPluginTest1');
$this
->assertEqual($service
->beep(), 'beep!');
try {
$service = \Drupal::service('service_container_test_ctools.yolo')
->createInstance('yolo1');
} catch (\Exception $e) {
$this
->pass('Non-existant plugin does not exist in the container.');
}
// @todo Test and fix instantiating non-class plugins.
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ServiceContainerCToolsIntegrationTest:: |
public static | function | ||
ServiceContainerCToolsIntegrationTest:: |
protected | function |
Overrides ServiceContainerIntegrationTestBase:: |
|
ServiceContainerCToolsIntegrationTest:: |
public | function | Tests if a particular CTools plugin is available. | |
ServiceContainerCToolsIntegrationTest:: |
public | function | Tests if CTools plugin types are available as services. | |
ServiceContainerIntegrationTestBase:: |
protected | property | The dependency injection container usable in the test. | |
ServiceContainerIntegrationTestBase:: |
protected | property | The profile to install as a basis for testing. | 1 |