updated contrib modules

This commit is contained in:
Bachir Soussi Chiadmi
2017-11-14 16:12:58 +01:00
parent c2b4e25be4
commit b32fe9ef14
317 changed files with 4672 additions and 13347 deletions
@@ -7,8 +7,8 @@ configure: devel.admin_settings
tags:
- developer
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -6,8 +6,8 @@ package: Development
tags:
- developer
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -141,6 +141,7 @@ class DevelGenerateCommands extends DrushCommands {
* @param $max_width Max width of first level of links.
* @option kill Delete all content before generating new content.
* @aliases genm
* @validate-module-enabled menu_link_content
*/
public function menus($number_menus = 2, $number_links = 50, $max_depth = 3, $max_width = 8, $options = ['kill' => FALSE]) {
$this->generate();
@@ -179,7 +180,7 @@ class DevelGenerateCommands extends DrushCommands {
/** @var DevelGenerateBaseInterface $instance */
$instance = $manager->createInstance($commandData->annotationData()->get('pluginId'), array());
$this->setPluginInstance($instance);
$parameters = $instance->validateDrushParams($args);
$parameters = $instance->validateDrushParams($args, $commandData->input()->getOptions());
$this->setParameters($parameters);
}
@@ -165,4 +165,8 @@ abstract class DevelGenerateBase extends PluginBase implements DevelGenerateBase
}
return $this->random;
}
protected function isDrush8() {
return function_exists('drush_drupal_load_autoloader');
}
}
@@ -316,7 +316,7 @@ class ContentDevelGenerate extends DevelGenerateBase implements ContainerFactory
$start = time();
for ($i = 1; $i <= $values['num']; $i++) {
$this->develGenerateContentAddNode($values);
if (function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) {
if ($this->isDrush8() && function_exists('drush_log') && $i % drush_get_option('feedback', 1000) == 0) {
$now = time();
drush_log(dt('Completed @feedback nodes (@rate nodes/min)', array('@feedback' => drush_get_option('feedback', 1000), '@rate' => (drush_get_option('feedback', 1000) * 60) / ($now - $start))), 'ok');
$start = $now;
@@ -372,8 +372,8 @@ class ContentDevelGenerate extends DevelGenerateBase implements ContainerFactory
/**
* {@inheritdoc}
*/
public function validateDrushParams($args) {
$add_language = drush_get_option('languages');
public function validateDrushParams($args, $options = []) {
$add_language = $this->isDrush8() ? drush_get_option('languages') : $options['languages'];
if (!empty($add_language)) {
$add_language = explode(',', str_replace(' ', '', $add_language));
// Intersect with the enabled languages to make sure the language args
@@ -381,17 +381,17 @@ class ContentDevelGenerate extends DevelGenerateBase implements ContainerFactory
$values['values']['add_language'] = array_intersect($add_language, array_keys($this->languageManager->getLanguages(LanguageInterface::STATE_ALL)));
}
$values['kill'] = drush_get_option('kill');
$values['kill'] = $this->isDrush8() ? drush_get_option('kill') : $options['kill'];
$values['title_length'] = 6;
$values['num'] = array_shift($args);
$values['max_comments'] = array_shift($args);
$all_types = array_keys(node_type_get_names());
$default_types = array_intersect(array('page', 'article'), $all_types);
$selected_types = StringUtils::csvToArray(drush_get_option('types', $default_types));
// Validates the input format for content types option.
if (drush_get_option('types', $default_types) === TRUE) {
throw new \Exception(dt('Wrong syntax or no content type selected. The correct syntax uses "=", eg.: --types=page,article'));
if ($this->isDrush8()) {
$selected_types = _convert_csv_to_array(drush_get_option('types', $default_types));
}
else {
$selected_types = StringUtils::csvToArray($options['types'] ?: $default_types);
}
if (empty($selected_types)) {
@@ -221,14 +221,14 @@ class MenuDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
/**
* {@inheritdoc}
*/
public function validateDrushParams($args) {
public function validateDrushParams($args, $options = []) {
$link_types = array('node', 'front', 'external');
$values = array(
'num_menus' => array_shift($args),
'num_links' => array_shift($args),
'kill' => drush_get_option('kill'),
'pipe' => drush_get_option('pipe'),
'kill' => $this->isDrush8() ? drush_get_option('kill') : $options['kill'],
'pipe' => $this->isDrush8() ? drush_get_option('pipe') : $options['pipe'],
'link_types' => array_combine($link_types, $link_types),
);
@@ -240,16 +240,16 @@ class MenuDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
$values['existing_menus']['__new-menu__'] = TRUE;
if ($this->isNumber($values['num_menus']) == FALSE) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of menus'));
throw new \Exception(dt('Invalid number of menus'));
}
if ($this->isNumber($values['num_links']) == FALSE) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of links'));
throw new \Exception(dt('Invalid number of links'));
}
if ($this->isNumber($values['max_depth']) == FALSE || $values['max_depth'] > 9 || $values['max_depth'] < 1) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid maximum link depth. Use a value between 1 and 9'));
throw new \Exception(dt('Invalid maximum link depth. Use a value between 1 and 9'));
}
if ($this->isNumber($values['max_width']) == FALSE || $values['max_width'] < 1) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid maximum menu width. Use a positive numeric value.'));
throw new \Exception(dt('Invalid maximum menu width. Use a positive numeric value.'));
}
return $values;
@@ -300,19 +300,17 @@ class MenuDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
protected function generateMenus($num_menus, $title_length = 12) {
$menus = array();
if ($this->moduleHandler->moduleExists('menu_ui')) {
for ($i = 1; $i <= $num_menus; $i++) {
$name = $this->getRandom()->word(mt_rand(2, max(2, $title_length)));
for ($i = 1; $i <= $num_menus; $i++) {
$name = $this->getRandom()->word(mt_rand(2, max(2, $title_length)));
$menu = $this->menuStorage->create(array(
'label' => $name,
'id' => 'devel-' . Unicode::strtolower($name),
'description' => $this->t('Description of @name', array('@name' => $name)),
));
$menu = $this->menuStorage->create(array(
'label' => $name,
'id' => 'devel-' . Unicode::strtolower($name),
'description' => $this->t('Description of @name', array('@name' => $name)),
));
$menu->save();
$menus[$menu->id()] = $menu->label();
}
$menu->save();
$menus[$menu->id()] = $menu->label();
}
return $menus;
@@ -210,15 +210,6 @@ class TermDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
$max++;
if (function_exists('drush_log')) {
$feedback = drush_get_option('feedback', 1000);
if ($i % $feedback == 0) {
$now = time();
drush_log(dt('Completed @feedback terms (@rate terms/min)', array('@feedback' => $feedback, '@rate' => $feedback * 60 / ($now - $start))), 'ok');
$start = $now;
}
}
// Limit memory usage. Only report first 20 created terms.
if ($i < 20) {
$terms[] = $term->label();
@@ -233,7 +224,7 @@ class TermDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
/**
* {@inheritdoc}
*/
public function validateDrushParams($args) {
public function validateDrushParams($args, $options = []) {
$vocabulary_name = array_shift($args);
$number = array_shift($args);
@@ -242,21 +233,21 @@ class TermDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
}
if (!$vocabulary_name) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Please provide a vocabulary machine name.'));
throw new \Exception(dt('Please provide a vocabulary machine name.'));
}
if (!$this->isNumber($number)) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of terms: @num', array('@num' => $number)));
throw new \Exception(dt('Invalid number of terms: @num', array('@num' => $number)));
}
// Try to convert machine name to a vocabulary id.
if (!$vocabulary = $this->vocabularyStorage->load($vocabulary_name)) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid vocabulary name: @name', array('@name' => $vocabulary_name)));
throw new \Exception(dt('Invalid vocabulary name: @name', array('@name' => $vocabulary_name)));
}
$values = [
'num' => $number,
'kill' => drush_get_option('kill'),
'kill' => $this->isDrush8() ? drush_get_option('kill') : $options['kill'],
'title_length' => 12,
'vids' => [$vocabulary->id()],
];
@@ -7,6 +7,7 @@ use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Drupal\devel_generate\DevelGenerateBase;
use Drush\Utils\StringUtils;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@@ -177,14 +178,26 @@ class UserDevelGenerate extends DevelGenerateBase implements ContainerFactoryPlu
/**
* {@inheritdoc}
*/
public function validateDrushParams($args) {
public function validateDrushParams($args, $options = []) {
$values = array(
'num' => array_shift($args),
'roles' => drush_get_option('roles') ? explode(',', drush_get_option('roles')) : array(),
'kill' => drush_get_option('kill'),
'pass' => drush_get_option('pass', NULL),
'time_range' => 0,
);
if ($this->isDrush8()) {
$values += [
'roles' => explode(',', drush_get_option('roles', '')),
'kill' => drush_get_option('kill'),
'pass' => drush_get_option('pass', NULL),
];
}
else {
$values += [
'roles' => StringUtils::csvToArray($options['roles']),
'kill' => $options['kill'],
'pass' => $options['pass'],
];
}
return $values;
}
@@ -158,15 +158,15 @@ class VocabularyDevelGenerate extends DevelGenerateBase implements ContainerFact
/**
* {@inheritdoc}
*/
public function validateDrushParams($args) {
public function validateDrushParams($args, $options = []) {
$values = array(
'num' => array_shift($args),
'kill' => drush_get_option('kill'),
'kill' => $this->isDrush8() ? drush_get_option('kill') : $options['kill'],
'title_length' => 12,
);
if ($this->isNumber($values['num']) == FALSE) {
return drush_set_error('DEVEL_GENERATE_INVALID_INPUT', dt('Invalid number of vocabularies: @num.', array('@num' => $values['num'])));
throw new \Exception(dt('Invalid number of vocabularies: @num.', array('@num' => $values['num'])));
}
return $values;
@@ -7,8 +7,8 @@ configure: admin/config/development/generate
tags:
- developer
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -1,6 +1,6 @@
services:
devel.command:
class: Drupal\devel\Commands\DevelCommands
arguments: ['@token', '@service_container', '@event_dispatcher']
arguments: ['@token', '@service_container', '@event_dispatcher', '@module_handler']
tags:
- { name: drush.command }
@@ -6,8 +6,8 @@ package: Development
tags:
- developer
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -5,6 +5,9 @@ use Drupal\Component\Uuid\Php;
use Drupal\Core\Utility\Token;
use Drush\Commands\DrushCommands;
use Drush\Exceptions\UserAbortException;
use Drush\Utils\StringUtils;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Output\Output;
/**
* For commands that are parts of modules, Drush expects to find commandfiles in
@@ -21,11 +24,21 @@ class DevelCommands extends DrushCommands {
protected $eventDispatcher;
public function __construct(Token $token, $container, $eventDispatcher) {
protected $moduleHandler;
public function __construct(Token $token, $container, $eventDispatcher, $moduleHandler) {
parent::__construct();
$this->token = $token;
$this->container = $container;
$this->eventDispatcher = $eventDispatcher;
$this->moduleHandler = $moduleHandler;
}
/**
* @return \Drupal\Core\Extension\ModuleHandlerInterface
*/
public function getModuleHandler() {
return $this->moduleHandler;
}
/**
@@ -50,93 +63,110 @@ class DevelCommands extends DrushCommands {
}
/**
* Uninstall, and Install a list of modules.
* Uninstall, and Install modules.
* @command devel-reinstall
* @command devel:reinstall
* @param $modules A comma-separated list of module names.
* @aliases dre
* @aliases dre,devel-reinstall
* @allow-additional-options pm-uninstall,pm-enable
*/
public function reinstall($projects) {
$projects = _convert_csv_to_array($projects);
public function reinstall($modules) {
$modules = StringUtils::csvToArray($modules);
// This is faster than 3 separate bootstraps.
$args = array_merge(array('pm-uninstall'), $projects);
// @todo. Use $application dispatch instead of drush_invoke().
call_user_func_array('drush_invoke', $args);
$args = array_merge(array('pm-enable'), $projects);
call_user_func_array('drush_invoke', $args);
$modules_str = implode(',', $modules);
drush_invoke_process('@self', 'pm:uninstall', [$modules_str], []);
drush_invoke_process('@self', 'pm:enable', [$modules_str], []);
}
/**
* List implementations of a given hook and optionally edit one.
*
* @command devel-hook
* @command devel:hook
* @param $hook The name of the hook to explore.
* @param $implementation The name of the implementation to edit. Usually omitted.
* @usage devel-hook cron
* List implementations of hook_cron().
* @aliases fnh,fn-hook,hook
* @aliases fnh,fn-hook,hook,devel-hook
* @optionset_get_editor
*/
function hook($hook) {
function hook($hook, $implementation) {
// Get implementations in the .install files as well.
include_once './core/includes/install.inc';
drupal_load_updates();
$info = $this->codeLocate($implementation . "_$hook");
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $info['file']);
}
if ($hook_implementations = \Drupal::moduleHandler()->getImplementations($hook)) {
if ($choice = drush_choice(array_combine($hook_implementations, $hook_implementations), 'Enter the number of the hook implementation you wish to view.')) {
$info= $this->codeLocate($choice . "_$hook");
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $info['file']);
/**
* @hook interact hook
*/
public function hookInteract(Input $input, Output $output) {
if (!$input->getArgument('implementation')) {
if ($hook_implementations = $this->getModuleHandler()->getImplementations($input->getArgument('hook'))) {
if (!$choice = $this->io()->choice('Enter the number of the hook implementation you wish to view.', array_combine($hook_implementations, $hook_implementations))) {
throw new UserAbortException();
}
$input->setArgument('implementation', $choice);
}
else {
throw new \Exception(dt('No implementations'));
}
}
else {
$this->logger()->success(dt('No implementations.'));
}
}
/**
* List implementations of a given event and optionally edit one.
*
* @command devel-event
* @command devel:event
* @param $event The name of the event to explore. If omitted, a list of events is shown.
* @param $implementation The name of the implementation to show. Usually omitted.
* @usage devel-event
* Pick a Kernel event, then pick an implementation, and then view its source code.
* @usage devel-event kernel.terminate
* Pick a terminate subscribers and view its source code.
* Pick a terminate subscribers implementation and view its source code.
* @aliases fne,fn-event,event
*/
function event($event) {
function event($event, $implementation) {
$info= $this->codeLocate($implementation);
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $info['file']);
}
/**
* @hook interact devel:event
*/
public function interactEvent(Input $input, Output $output) {
$dispatcher = $this->getEventDispatcher();
if (empty($event)) {
// @todo Expand this list and move to interact().
if (!$input->getArgument('event')) {
// @todo Expand this list.
$events = array('kernel.controller', 'kernel.exception', 'kernel.request', 'kernel.response', 'kernel.terminate', 'kernel.view');
$events = array_combine($events, $events);
if (!$event = drush_choice($events, 'Enter the event you wish to explore.')) {
if (!$event = $this->io()->choice('Enter the event you wish to explore.', $events)) {
throw new UserAbortException();
}
$input->setArgument('event', $event);
}
if ($implementations = $dispatcher->getListeners($event)) {
foreach ($implementations as $implementation) {
$callable = get_class($implementation[0]) . '::' . $implementation[1];
$choices[$callable] = $callable;
}
if ($choice = drush_choice($choices, 'Enter the number of the implementation you wish to view.')) {
$info= $this->codeLocate($choice);
$exec = drush_get_editor();
drush_shell_exec_interactive($exec, $info['file']);
if (!$choice = $this->io()->choice('Enter the number of the implementation you wish to view.', $choices)) {
throw new UserAbortException();
}
$input->setArgument('implementation', $choice);
}
else {
$this->logger()->success(dt('No implementations.'));
throw new \Exception(dt('No implementations.'));
}
}
/**
* List available tokens.
*
* @command devel-token
* @aliases token
* @command devel:token
* @aliases token,devel-token
* @field-labels
* group: Group
* token: Token
@@ -162,8 +192,8 @@ class DevelCommands extends DrushCommands {
/**
* Generate a UUID.
*
* @command devel-uuid
* @aliases uuid
* @command devel:uuid
* @aliases uuid,devel-uuid
* @usage drush devel-uuid
* Outputs a Universally Unique Identifier.
*
@@ -203,9 +233,9 @@ class DevelCommands extends DrushCommands {
/**
* Get a list of available container services.
*
* @command devel-services
* @command devel:services
* @param $prefix A prefix to filter the service list by.
* @aliases devel-container-services,dcs
* @aliases devel-container-services,dcs,devel-services
* @usage drush devel-services
* Gets a list of all available container services
* @usage drush dcs plugin.manager
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -9,8 +9,8 @@ dependencies:
- text
- entity_test
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -5,8 +5,8 @@ package: Testing
# version: VERSION
# core: 8.x
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848
@@ -1,22 +1,22 @@
<?php
namespace Drupal\devel\Tests;
namespace Drupal\Tests\devel\Functional;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests Devel controller.
*
* @group devel
*/
class DevelControllerTest extends WebTestBase {
class DevelControllerTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('devel', 'node', 'entity_test', 'devel_entity_test', 'block');
public static $modules = ['devel', 'node', 'entity_test', 'devel_entity_test', 'block'];
/**
* {@inheritdoc}
@@ -26,35 +26,35 @@ class DevelControllerTest extends WebTestBase {
// Create a test entity.
$random_label = $this->randomMachineName();
$data = array('type' => 'entity_test', 'name' => $random_label);
$data = ['type' => 'entity_test', 'name' => $random_label];
$this->entity = entity_create('entity_test', $data);
$this->entity->save();
// Create a test entity with only canonical route.
$random_label = $this->randomMachineName();
$data = array('type' => 'devel_entity_test_canonical', 'name' => $random_label);
$data = ['type' => 'devel_entity_test_canonical', 'name' => $random_label];
$this->entity_canonical = entity_create('devel_entity_test_canonical', $data);
$this->entity_canonical->save();
// Create a test entity with only edit route.
$random_label = $this->randomMachineName();
$data = array('type' => 'devel_entity_test_edit', 'name' => $random_label);
$data = ['type' => 'devel_entity_test_edit', 'name' => $random_label];
$this->entity_edit = entity_create('devel_entity_test_edit', $data);
$this->entity_edit->save();
// Create a test entity with no routes.
$random_label = $this->randomMachineName();
$data = array('type' => 'devel_entity_test_no_links', 'name' => $random_label);
$data = ['type' => 'devel_entity_test_no_links', 'name' => $random_label];
$this->entity_no_links = entity_create('devel_entity_test_no_links', $data);
$this->entity_no_links->save();
$this->drupalPlaceBlock('local_tasks_block');
$web_user = $this->drupalCreateUser(array(
$web_user = $this->drupalCreateUser([
'view test entity',
'administer entity_test content',
'access devel information',
));
]);
$this->drupalLogin($web_user);
}
@@ -1,16 +1,16 @@
<?php
namespace Drupal\devel\Tests;
namespace Drupal\Tests\devel\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests pluggable dumper feature.
*
* @group devel
*/
class DevelDumperTest extends WebTestBase {
class DevelDumperTest extends BrowserTestBase {
/**
* Modules to enable.
@@ -36,36 +36,42 @@ class DevelDumperTest extends WebTestBase {
$this->drupalGet('admin/config/development/devel');
// Ensures that the dumper input is present on the config page.
$this->assertFieldByName('dumper');
$this->assertSession()->fieldExists('dumper');
// Ensures that the 'default' dumper is enabled by default.
$this->assertFieldChecked('edit-dumper-default');
$this->assertSession()->checkboxChecked('edit-dumper-default');
// Ensures that all dumpers declared by devel are present on the config page
// and that only the available dumpers are selectable.
$dumpers = ['default', 'drupal_variable', 'firephp', 'chromephp', 'var_dumper'];
$dumpers = [
'default',
'drupal_variable',
'firephp',
'chromephp',
'var_dumper',
];
$available_dumpers = ['default', 'drupal_variable'];
foreach ($dumpers as $dumper) {
$this->assertFieldByXPath('//input[@type="radio" and @name="dumper"]', $dumper, new FormattableMarkup('Radio button for @dumper found.', ['@dumper' => $dumper]));
$this->assertFieldByXPath('//input[@type="radio" and @name="dumper"]', $dumper);
if (in_array($dumper, $available_dumpers)) {
$this->assertFieldByXPath('//input[@name="dumper" and not(@disabled="disabled")]', $dumper, new FormattableMarkup('Dumper @dumper is available.', ['@dumper' => $dumper]));
$this->assertFieldByXPath('//input[@name="dumper" and not(@disabled="disabled")]', $dumper);
}
else {
$this->assertFieldByXPath('//input[@name="dumper" and @disabled="disabled"]', $dumper, new FormattableMarkup('Dumper @dumper is disabled.', ['@dumper' => $dumper]));
$this->assertFieldByXPath('//input[@name="dumper" and @disabled="disabled"]', $dumper);
}
}
// Ensures that dumper plugins declared by other modules are present on the
// config page and that only the available dumpers are selectable.
$this->assertFieldByName('dumper', 'available_test_dumper');
$this->assertText('Available test dumper.', 'Available dumper label is present');
$this->assertText('Drupal dumper for testing purposes (available).', 'Available dumper description is present');
$this->assertFieldByXPath('//input[@name="dumper"]', 'available_test_dumper');
$this->assertSession()->pageTextContains('Available test dumper.');
$this->assertSession()->pageTextContains('Drupal dumper for testing purposes (available).');
$this->assertFieldByXPath('//input[@name="dumper" and not(@disabled="disabled")]', 'available_test_dumper', 'Available dumper input not is disabled.');
$this->assertFieldByName('dumper', 'not_available_test_dumper');
$this->assertText('Not available test dumper.', 'Non available dumper label is present');
$this->assertText('Drupal dumper for testing purposes (not available).Not available. You may need to install external dependencies for use this plugin.', 'Non available dumper description is present');
$this->assertFieldByXPath('//input[@name="dumper"]', 'not_available_test_dumper');
$this->assertSession()->pageTextContains('Not available test dumper.');
$this->assertSession()->pageTextContains('Drupal dumper for testing purposes (not available).Not available. You may need to install external dependencies for use this plugin.');
$this->assertFieldByXPath('//input[@name="dumper" and @disabled="disabled"]', 'not_available_test_dumper', 'Non available dumper input is disabled.');
// Ensures that saving of the dumpers configuration works as expected.
@@ -73,10 +79,10 @@ class DevelDumperTest extends WebTestBase {
'dumper' => 'drupal_variable',
];
$this->drupalPostForm('admin/config/development/devel', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->assertSession()->pageTextContains(t('The configuration options have been saved.'));
$config = \Drupal::config('devel.settings')->get('devel_dumper');
$this->assertEqual('drupal_variable', $config, 'The configuration options have been properly saved');
$this->assertEquals('drupal_variable', $config, 'The configuration options have been properly saved');
// Ensure that if the chosen dumper is not available (e.g. the module that
// provide it is uninstalled) the 'default' dumper appears selected in the
@@ -84,22 +90,22 @@ class DevelDumperTest extends WebTestBase {
\Drupal::service('module_installer')->install(['kint']);
$this->drupalGet('admin/config/development/devel');
$this->assertFieldByName('dumper', 'kint');
$this->assertFieldByXPath('//input[@name="dumper"]', 'kint');
$edit = [
'dumper' => 'kint',
];
$this->drupalPostForm('admin/config/development/devel', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->assertSession()->pageTextContains(t('The configuration options have been saved.'));
$config = \Drupal::config('devel.settings')->get('devel_dumper');
$this->assertEqual('kint', $config, 'The configuration options have been properly saved');
$this->assertEquals('kint', $config, 'The configuration options have been properly saved');
\Drupal::service('module_installer')->uninstall(['kint']);
$this->drupalGet('admin/config/development/devel');
$this->assertNoFieldByName('dumper', 'kint');
$this->assertFieldChecked('edit-dumper-default');
$this->assertNoFieldByXPath('//input[@name="dumper"]', 'kint');
$this->assertSession()->checkboxChecked('edit-dumper-default');
}
/**
@@ -110,7 +116,7 @@ class DevelDumperTest extends WebTestBase {
'dumper' => 'available_test_dumper',
];
$this->drupalPostForm('admin/config/development/devel', $edit, t('Save configuration'));
$this->assertText(t('The configuration options have been saved.'));
$this->assertSession()->pageTextContains(t('The configuration options have been saved.'));
$this->drupalGet('devel_dumper_test/dump');
$elements = $this->xpath('//body/pre[contains(text(), :message)]', [':message' => 'AvailableTestDumper::dump() Test output']);
@@ -129,8 +135,8 @@ class DevelDumperTest extends WebTestBase {
$this->assertTrue(!empty($elements), 'Dumped message is present.');
// Ensures that plugins can add libraries to the page when the
// ::exportAsRenderable() method is used.
$this->assertRaw('devel_dumper_test/css/devel_dumper_test.css');
$this->assertRaw('devel_dumper_test/js/devel_dumper_test.js');
$this->assertSession()->responseContains('devel_dumper_test/css/devel_dumper_test.css');
$this->assertSession()->responseContains('devel_dumper_test/js/devel_dumper_test.js');
$debug_filename = file_directory_temp() . '/drupal_debug.txt';
@@ -140,7 +146,7 @@ class DevelDumperTest extends WebTestBase {
<pre>AvailableTestDumper::export() Test output</pre>
EOF;
$this->assertEqual($file_content, $expected, 'Dumped message is present.');
$this->assertEquals($file_content, $expected, 'Dumped message is present.');
// Ensures that the DevelDumperManager::debug() is not access checked and
// that the dump is written in the debug file even if the user has not the
@@ -153,7 +159,7 @@ EOF;
<pre>AvailableTestDumper::export() Test output</pre>
EOF;
$this->assertEqual($file_content, $expected, 'Dumped message is present.');
$this->assertEquals($file_content, $expected, 'Dumped message is present.');
}
}
@@ -1,16 +1,16 @@
<?php
namespace Drupal\devel\Tests;
namespace Drupal\Tests\devel\Functional;
use Drupal\Core\Url;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests devel menu links.
*
* @group devel
*/
class DevelMenuLinksTest extends WebTestBase {
class DevelMenuLinksTest extends BrowserTestBase {
/**
* Modules to enable.
@@ -1,22 +1,22 @@
<?php
namespace Drupal\devel\Tests;
namespace Drupal\Tests\devel\Functional;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests reinstall modules.
*
* @group devel
*/
class DevelReinstallTest extends WebTestBase {
class DevelModulesReinstallTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('devel');
public static $modules = ['devel'];
/**
* The profile to install as a basis for testing.
@@ -31,7 +31,7 @@ class DevelReinstallTest extends WebTestBase {
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(array('administer site configuration'));
$web_user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($web_user);
}
@@ -40,7 +40,7 @@ class DevelReinstallTest extends WebTestBase {
*/
public function testDevelReinstallModules() {
// Minimal profile enables only dblog, block and node.
$modules = array('dblog', 'block');
$modules = ['dblog', 'block'];
// Needed for compare correctly the message.
sort($modules);
@@ -48,13 +48,13 @@ class DevelReinstallTest extends WebTestBase {
$this->drupalGet('devel/reinstall');
// Prepare field data in an associative array
$edit = array();
$edit = [];
foreach ($modules as $module) {
$edit["reinstall[$module]"] = TRUE;
}
$this->drupalPostForm('devel/reinstall', $edit, t('Reinstall'));
$this->assertText(t('Uninstalled and installed: @names.', array('@names' => implode(', ', $modules))));
$this->assertText(t('Uninstalled and installed: @names.', ['@names' => implode(', ', $modules)]));
}
}
@@ -1,16 +1,16 @@
<?php
namespace Drupal\devel\Tests;
namespace Drupal\Tests\devel\Functional;
use Drupal\Component\Render\FormattableMarkup;
use Drupal\simpletest\WebTestBase;
use Drupal\Tests\BrowserTestBase;
/**
* Tests switch user.
*
* @group devel
*/
class DevelSwitchUserTest extends WebTestBase {
class DevelSwitchUserTest extends BrowserTestBase {
/**
* Modules to enable.
@@ -276,12 +276,12 @@ class DevelSwitchUserTest extends WebTestBase {
*/
protected function assertSessionByUid($uid) {
$query = \Drupal::database()->select('sessions');
$query->fields('sessions', array('uid'));
$query->fields('sessions', ['uid']);
$query->condition('uid', $uid);
$result = $query->execute()->fetchAll();
if (empty($result)) {
$this->fail(new FormattableMarkup('No session found for uid @uid', array('@uid' => $uid)));
$this->fail(new FormattableMarkup('No session found for uid @uid', ['@uid' => $uid]));
}
elseif (count($result) > 1) {
// If there is more than one session, then that must be unexpected.
@@ -304,7 +304,7 @@ class DevelSwitchUserTest extends WebTestBase {
*/
protected function assertNoSessionByUid($uid) {
$query = \Drupal::database()->select('sessions');
$query->fields('sessions', array('uid'));
$query->fields('sessions', ['uid']);
$query->condition('uid', $uid);
$result = $query->execute()->fetchAll();
$this->assert(empty($result), "No session for uid $uid found.");
@@ -56,7 +56,7 @@ class DatabaseDataCollector extends DataCollector implements DrupalDataCollector
unset($query['caller']['args']);
// Remove query args element if empty.
if (empty($query['args'])) {
if (isset($query['args']) && empty($query['args'])) {
unset($query['args']);
}
@@ -223,8 +223,11 @@ class DatabaseDataCollector extends DataCollector implements DrupalDataCollector
$query['type'] = $type;
$quoted = [];
foreach ((array) $query['args'] as $key => $val) {
$quoted[$key] = is_null($val) ? 'NULL' : $conn->quote($val);
if (isset($query['args'])) {
foreach ((array) $query['args'] as $key => $val) {
$quoted[$key] = is_null($val) ? 'NULL' : $conn->quote($val);
}
}
$query['query_args'] = strtr($query['query'], $quoted);
@@ -108,6 +108,13 @@ class ConfigEntityStorageDecorator extends EntityDecorator implements ConfigEnti
return $this->getOriginalObject()->save($entity);
}
/**
* {@inheritdoc}
*/
public function hasData() {
return $this->getOriginalObject()->hasData();
}
/**
* {@inheritdoc}
*/
@@ -4,6 +4,7 @@ namespace Drupal\webprofiler\EventDispatcher;
use Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher;
use Drupal\webprofiler\Stopwatch;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\EventDispatcher\Event;
use Symfony\Component\HttpKernel\KernelEvents;
@@ -29,10 +30,19 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
protected $notCalledListeners;
/**
* @param \Drupal\webprofiler\Stopwatch $stopwatch
* {@inheritdoc}
*/
public function setStopwatch(Stopwatch $stopwatch) {
$this->stopwatch = $stopwatch;
public function __construct(ContainerInterface $container, array $listeners = []) {
parent::__construct($container, $listeners);
$this->notCalledListeners = $listeners;
}
/**
* {@inheritdoc}
*/
public function addListener($event_name, $listener, $priority = 0) {
parent::addListener($event_name, $listener, $priority);
$this->notCalledListeners[$event_name][$priority][] = ['callable' => $listener];
}
/**
@@ -97,6 +107,13 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
return $this->notCalledListeners;
}
/**
* @param \Drupal\webprofiler\Stopwatch $stopwatch
*/
public function setStopwatch(Stopwatch $stopwatch) {
$this->stopwatch = $stopwatch;
}
/**
* Called before dispatching the event.
*
@@ -158,38 +175,19 @@ class TraceableEventDispatcher extends ContainerAwareEventDispatcher implements
'method' => $definition['callable'][1],
];
// Remove this listener from the $notCalledListeners array.
if (!$this->notCalledListeners) {
$this->notCalledListeners = $this->cloneListeners($this->listeners);
}
foreach ($this->notCalledListeners[$event_name][$priority] as $key => $listener) {
if ($listener['service'][0] == $definition['service'][0] && $listener['service'][1] == $definition['service'][1]) {
unset($this->notCalledListeners[$event_name][$priority][$key]);
}
}
}
/**
* @param $listeners
*
* @return array
*/
private function cloneListeners($listeners) {
$clone = [];
foreach ($listeners as $eventName => $events) {
foreach ($events as $priorityValue => $priorities) {
foreach ($priorities as $key => $listener) {
$clone[$eventName][$priorityValue][$key]['service'] = [
$listener['service'][0],
$listener['service'][1]
];
if (isset($listener['service'])) {
if ($listener['service'][0] == $definition['service'][0] && $listener['service'][1] == $definition['service'][1]) {
unset($this->notCalledListeners[$event_name][$priority][$key]);
}
}
else {
if (get_class($listener['callable'][0]) == get_class($definition['callable'][0]) && $listener['callable'][1] == $definition['callable'][1]) {
unset($this->notCalledListeners[$event_name][$priority][$key]);
}
}
}
return $clone;
}
}
}
@@ -134,7 +134,7 @@ class ConfigForm extends ConfigFormBase {
'#states' => array(
'visible' => array(
array(
':input[name="active_toolbar_items[database]' => array('checked' => TRUE),
'input[name="active_toolbar_items[database]"]' => array('checked' => TRUE),
),
),
),
@@ -31,7 +31,7 @@ class TraceableViewExecutable extends ViewExecutable {
* @return float
*/
public function getExecuteTime() {
return $this->execute_time;
return property_exists($this, 'execute_time') ? $this->execute_time : 0.0;
}
/**
@@ -9,8 +9,8 @@ tags:
dependencies:
- devel
# Information added by Drupal.org packaging script on 2017-08-14
version: '8.x-1.0'
# Information added by Drupal.org packaging script on 2017-10-05
version: '8.x-1.2'
core: '8.x'
project: 'devel'
datestamp: 1502732047
datestamp: 1507197848