Skip to content
Snippets Groups Projects
Commit 7ae6f6b4 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2273311 by donquixote, xjm: Fixed...

Issue #2273311 by donquixote, xjm: Fixed FieldDefinitionTestBase::getNamespacePath() breaks with PSR-4.
parent 59fee192
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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__))));
}
/**
......
......@@ -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();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment