diff --git a/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php b/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php index fb99b8299790cf8c33f891b76d84405bb4c98fd4..99d8f1e1a82694cc066000dea09e583ed458d52e 100644 --- a/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php +++ b/core/modules/path/tests/src/Field/PathFieldDefinitionTest.php @@ -41,8 +41,8 @@ protected function getPluginId() { /** * {@inheritdoc} */ - protected function getNamespacePath() { - return dirname(dirname(dirname(__DIR__))) . '/lib/Drupal/path'; + protected function getModuleAndPath() { + return array('path', dirname(dirname(dirname(__DIR__)))); } /** diff --git a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionTestBase.php b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionTestBase.php index 49a39229ceb02a3d5935fd12c69dbc98779fc305..5b033f9ffdc84ddd369a9a50db7e66550535c6d2 100644 --- a/core/tests/Drupal/Tests/Core/Field/FieldDefinitionTestBase.php +++ b/core/tests/Drupal/Tests/Core/Field/FieldDefinitionTestBase.php @@ -28,15 +28,21 @@ abstract class FieldDefinitionTestBase extends UnitTestCase { * {@inheritdoc} */ public function setUp() { - $namespace_path = $this->getNamespacePath(); - // Suppport both PSR-0 and PSR-4 directory layouts. - $module_name = basename($namespace_path); - if ($module_name == 'src') { - $module_name = basename($module_name); - } - $namespaces = new \ArrayObject(array( - 'Drupal\\' . $module_name => $namespace_path, - )); + + // getModuleAndPath() returns an array of the module name and directory. + list($module_name, $module_dir) = $this->getModuleAndPath(); + + $namespaces = new \ArrayObject( + array( + "Drupal\\$module_name" => array( + // Suppport both PSR-0 and PSR-4 directory layouts. + $module_dir . '/src', + // @todo Remove this when PSR-0 support ends. + // @see https://drupal.org/node/2247287 + $module_dir . '/lib/Drupal/' . $module_name, + ), + ) + ); $language_manager = $this->getMock('Drupal\Core\Language\LanguageManagerInterface'); $language_manager->expects($this->once()) @@ -72,15 +78,16 @@ public function setUp() { abstract protected function getPluginId(); /** - * Returns the path to the module's classes. + * Returns the module name and the module directory for the plugin. * - * Depending on whether the module follows the PSR-0 or PSR-4 directory layout - * this should be either /path/to/module/lib/Drupal/mymodule or - * /path/to/module/src. + * drupal_get_path() cannot be used here, because it is not available in + * Drupal PHPUnit tests. * - * @return string - * The path to the module's classes. + * @return array + * A one-dimensional array containing the following strings: + * - The module name. + * - The module directory, e.g. DRUPAL_CORE . 'core/modules/path'. */ - abstract protected function getNamespacePath(); + abstract protected function getModuleAndPath(); }