/** * 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}."); } } } }
/** * Un-camelizes a string. * * @covers ::underscore * @dataProvider underscoreCamelizeDataProvider */ public function test_underscore($string_underscore, $string_camelize) { $result = $this->container->underscore($string_camelize); $this->assertEquals($string_underscore, $result); }
/** * Register aliases for the service. * * @param array $container_definition * The container definition to process. * @param string $owner * The owner, here, the name of the module * @param string $plugin_type * The type of plugin */ public function registerAliasServices(&$container_definition, $owner, $plugin_type) { // Register service with original string. $name = $owner . '.' . $plugin_type; $container_definition['services'][$name] = array(); // Check candidates for needed aliases. $candidates = array(); $candidates[$owner . '.' . Container::underscore($plugin_type)] = TRUE; $candidates[$name] = FALSE; foreach ($candidates as $candidate => $value) { if ($value) { $container_definition['services'][$candidate] = array('alias' => $name); } } }