Issue #2273311 by donquixote, xjm: Fixed FieldDefinitionTestBase::getNamespacePath() breaks with PSR-4.
parent
59fee1922b
commit
7ae6f6b427
|
@ -41,8 +41,8 @@ class PathFieldDefinitionTest extends FieldDefinitionTestBase {
|
||||||
/**
|
/**
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
protected function getNamespacePath() {
|
protected function getModuleAndPath() {
|
||||||
return dirname(dirname(dirname(__DIR__))) . '/lib/Drupal/path';
|
return array('path', dirname(dirname(dirname(__DIR__))));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -28,15 +28,21 @@ abstract class FieldDefinitionTestBase extends UnitTestCase {
|
||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
*/
|
*/
|
||||||
public function setUp() {
|
public function setUp() {
|
||||||
$namespace_path = $this->getNamespacePath();
|
|
||||||
// Suppport both PSR-0 and PSR-4 directory layouts.
|
// getModuleAndPath() returns an array of the module name and directory.
|
||||||
$module_name = basename($namespace_path);
|
list($module_name, $module_dir) = $this->getModuleAndPath();
|
||||||
if ($module_name == 'src') {
|
|
||||||
$module_name = basename($module_name);
|
$namespaces = new \ArrayObject(
|
||||||
}
|
array(
|
||||||
$namespaces = new \ArrayObject(array(
|
"Drupal\\$module_name" => array(
|
||||||
'Drupal\\' . $module_name => $namespace_path,
|
// 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 = $this->getMock('Drupal\Core\Language\LanguageManagerInterface');
|
||||||
$language_manager->expects($this->once())
|
$language_manager->expects($this->once())
|
||||||
|
@ -72,15 +78,16 @@ abstract class FieldDefinitionTestBase extends UnitTestCase {
|
||||||
abstract protected function getPluginId();
|
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
|
* drupal_get_path() cannot be used here, because it is not available in
|
||||||
* this should be either /path/to/module/lib/Drupal/mymodule or
|
* Drupal PHPUnit tests.
|
||||||
* /path/to/module/src.
|
|
||||||
*
|
*
|
||||||
* @return string
|
* @return array
|
||||||
* The path to the module's classes.
|
* 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();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue