diff --git a/core/lib/Drupal/Core/Entity/EntityManager.php b/core/lib/Drupal/Core/Entity/EntityManager.php index b8c38ce..823bd60 100644 --- a/core/lib/Drupal/Core/Entity/EntityManager.php +++ b/core/lib/Drupal/Core/Entity/EntityManager.php @@ -235,9 +235,7 @@ public function getDefinitions() { return $cache->data; } else { - // @todo Remove array_filter() once http://drupal.org/node/1780396 is - // resolved. - $definitions = array_filter(parent::getDefinitions()); + $definitions = parent::getDefinitions(); cache($this->cacheBin)->set($this->cacheKey, $definitions, $this->cacheExpire, $this->cacheTags); return $definitions; } @@ -249,12 +247,6 @@ public function getDefinitions() { protected function processDefinition(&$definition, $plugin_id) { parent::processDefinition($definition, $plugin_id); - // @todo Remove this check once http://drupal.org/node/1780396 is resolved. - if (!module_exists($definition['module'])) { - $definition = NULL; - return; - } - foreach ($definition['view_modes'] as $view_mode => $view_mode_info) { $definition['view_modes'][$view_mode] += array( 'custom_settings' => FALSE, diff --git a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php index a21d496..ec5b0f3 100644 --- a/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php +++ b/core/modules/simpletest/lib/Drupal/simpletest/DrupalUnitTestBase.php @@ -151,6 +151,11 @@ protected function enableModules(array $modules, $install = TRUE) { // Call module_enable() to enable (install) the new modules. if ($install) { module_enable($modules); + // Register the PSR-0 namespace of the enabled modules. + foreach ($modules as $module) { + // Register the PSR-0 namespace of the enabled modules. + drupal_classloader_register($module, dirname($this->moduleList[$module]['filename'])); + } } // Otherwise, only ensure that the new modules are loaded. else { diff --git a/core/modules/simpletest/simpletest.module b/core/modules/simpletest/simpletest.module index 2c47954..7d228cd 100644 --- a/core/modules/simpletest/simpletest.module +++ b/core/modules/simpletest/simpletest.module @@ -389,7 +389,7 @@ function simpletest_classloader_register() { $all_data += system_rebuild_theme_data(); $loader = drupal_classloader(); foreach ($all_data as $name => $data) { - $loader->registerNamespace('Drupal\\' . $name . '\Tests', DRUPAL_ROOT . '/' . $data->filename . '/lib'); + $loader->registerNamespace('Drupal\\' . $name . '\Tests', DRUPAL_ROOT . '/' . dirname($data->filename) . '/lib'); } } diff --git a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php index 41070c3..8a30531 100644 --- a/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/DrupalKernel/DrupalKernelTest.php @@ -92,6 +92,7 @@ function testCompileDIC() { 'bundle_test' => 'bundle_test', ); $cache->flush(); + drupal_classloader_register('bundle_test', dirname(drupal_get_filename('module', 'bundle_test'))); $kernel = new DrupalKernel('testing', FALSE, $module_enabled, $cache); $kernel->boot(); // Instantiate it a second time and we should still get a ContainerBuilder diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php index ae9deb1..bb039bc 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/AnnotatedClassDiscoveryTest.php @@ -24,6 +24,9 @@ public static function getInfo() { public function setUp() { parent::setUp(); + + $this->enableModules(array('plugin_test')); + $this->expectedDefinitions = array( 'apple' => array( 'id' => 'apple', diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/DiscoveryTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/DiscoveryTestBase.php index e95d238..9c41bee 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/DiscoveryTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/Discovery/DiscoveryTestBase.php @@ -7,12 +7,12 @@ namespace Drupal\system\Tests\Plugin\Discovery; -use Drupal\simpletest\UnitTestBase; +use Drupal\simpletest\DrupalUnitTestBase; /** * Tests that plugins are correctly discovered. */ -class DiscoveryTestBase extends UnitTestBase { +class DiscoveryTestBase extends DrupalUnitTestBase { /** * The discovery component to test. diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php index 5db9322..a4538e7 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/PluginTestBase.php @@ -7,7 +7,7 @@ namespace Drupal\system\Tests\Plugin; -use Drupal\simpletest\UnitTestBase; +use Drupal\simpletest\DrupalUnitTestBase; use Drupal\plugin_test\Plugin\TestPluginManager; use Drupal\plugin_test\Plugin\MockBlockManager; use Drupal\plugin_test\Plugin\DefaultsTestPluginManager; @@ -15,7 +15,7 @@ /** * Base class for Plugin API unit tests. */ -abstract class PluginTestBase extends UnitTestBase { +abstract class PluginTestBase extends DrupalUnitTestBase { protected $testPluginManager; protected $testPluginExpectedDefinitions; protected $mockBlockManager; @@ -26,6 +26,8 @@ public function setUp() { parent::setUp(); + $this->enableModules(array('plugin_test')); + // Real modules implementing plugin types may expose a module-specific API // for retrieving each type's plugin manager, or make them available in // Drupal's dependency injection container, but for unit testing, we get diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/ChainMatcherTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/ChainMatcherTest.php index c6b28cc..9ca0b13 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/ChainMatcherTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/ChainMatcherTest.php @@ -22,7 +22,7 @@ * Basic tests for the ChainMatcher. */ class ChainMatcherTest extends UnitTestBase { - + public static function getInfo() { return array( 'name' => 'Chain matcher tests', @@ -31,6 +31,12 @@ public static function getInfo() { ); } + public function setUp() { + parent::setUp(); + // Make sure the system.module classes can be found. + drupal_classloader_register('system', dirname(drupal_get_filename('module', 'system'))); + } + /** * Confirms that the expected exception is thrown. */ diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php index 46ed2a3..d27b95b 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php @@ -33,6 +33,9 @@ function testContainerAware() { $container = new Container(); $resolver = new ControllerResolver($container); + // Make sure the system.module classes can be found. + drupal_classloader_register('system', dirname(drupal_get_filename('module', 'system'))); + $request = Request::create('/some/path'); $request->attributes->set('_controller', '\Drupal\system\Tests\Routing\MockController::run'); diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php index c98da2e..e8221cb 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/HttpMethodMatcherTest.php @@ -39,12 +39,15 @@ public static function getInfo() { ); } - function __construct($test_id = NULL) { - parent::__construct($test_id); + function setUp() { + parent::setUp(); + + // Make sure the system.module classes can be found. + drupal_classloader_register('system', dirname(drupal_get_filename('module', 'system'))); $this->fixtures = new RoutingFixtures(); } - + /** * Confirms that the HttpMethod matcher matches properly. */ diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/NestedMatcherTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/NestedMatcherTest.php index 444785c..f993d2a 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/NestedMatcherTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/NestedMatcherTest.php @@ -39,8 +39,11 @@ public static function getInfo() { ); } - function __construct($test_id = NULL) { - parent::__construct($test_id); + function setUp() { + parent::setUp(); + + // Make sure the system.module classes can be found. + drupal_classloader_register('system', dirname(drupal_get_filename('module', 'system'))); $this->fixtures = new RoutingFixtures(); } diff --git a/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php b/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php index 5fb54e3..06fd7f8 100644 --- a/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/TempStoreDatabaseTest.php @@ -64,6 +64,8 @@ protected function setUp() { $schema = system_schema(); db_create_table('semaphore', $schema['semaphore']); db_create_table('key_value_expire', $schema['key_value_expire']); + // Register the namespace of user.module. + drupal_classloader_register('user', dirname(drupal_get_filename('module', 'user'))); // Create several objects for testing. for ($i = 0; $i <= 3; $i++) {