diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js index ed6917b9cb..aa9aa20bfe 100644 --- a/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js +++ b/core/tests/Drupal/Nightwatch/Commands/drupalCreateRole.js @@ -22,6 +22,8 @@ exports.command = function drupalCreateRole({ permissions, name = null }, callba this .drupalRelativeURL('/admin/people/roles/add') .setValue('input[name="label"]', roleName) + /* Wait for the machine name to appear so that it can be used later to + select the permissions from the permission page. */ .expect.element('.user-role-form .machine-name-value').to.be.visible.before(2000); this.perform((done) => { diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalLogin.js b/core/tests/Drupal/Nightwatch/Commands/drupalLogin.js index d957fc7808..fb36ae0c11 100644 --- a/core/tests/Drupal/Nightwatch/Commands/drupalLogin.js +++ b/core/tests/Drupal/Nightwatch/Commands/drupalLogin.js @@ -25,4 +25,4 @@ exports.command = function drupalLogin({ name, password }) { }); return this; -}; \ No newline at end of file +}; diff --git a/core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js b/core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js index a05e4b686b..d788b15cc4 100644 --- a/core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js +++ b/core/tests/Drupal/Nightwatch/Commands/drupalUserIsLoggedIn.js @@ -16,4 +16,4 @@ exports.command = function drupalUserIsLoggedIn(callback) { } return this; -}; \ No newline at end of file +}; diff --git a/core/tests/Drupal/TestSite/Commands/TestSiteUserLoginCommand.php b/core/tests/Drupal/TestSite/Commands/TestSiteUserLoginCommand.php index c178e5653b..c990f9bc12 100644 --- a/core/tests/Drupal/TestSite/Commands/TestSiteUserLoginCommand.php +++ b/core/tests/Drupal/TestSite/Commands/TestSiteUserLoginCommand.php @@ -2,14 +2,10 @@ namespace Drupal\TestSite\Commands; -use Drupal\Core\Database\Database; use Drupal\Core\DrupalKernel; use Drupal\Core\Site\Settings; -use Drupal\Core\Test\FunctionalTestSetupTrait; -use Drupal\Core\Test\TestDatabase; -use Drupal\Core\Test\TestRunnerKernel; -use Drupal\Core\Test\TestSetupTrait; use Symfony\Component\Console\Command\Command; +use Symfony\Component\Console\Exception\InvalidArgumentException; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; @@ -17,7 +13,7 @@ use Symfony\Component\HttpFoundation\Request; /** - * Command to get a login link for the test site. + * Command to generate a login link for the test site. * * @internal */ @@ -51,13 +47,15 @@ class TestSiteUserLoginCommand extends Command { */ protected function configure() { $this->setName('user-login') - ->setDescription('Display a one time login link for an user.') + ->setDescription('Generate a one time login link for an user.') ->addArgument('uid', InputArgument::OPTIONAL, 'The id of the user to which the link will be generated', 1) ->addOption('site-path', NULL, InputOption::VALUE_REQUIRED, 'The path for the test site.'); } /** * {@inheritdoc} + * + * @throws \Symfony\Component\Console\Exception\InvalidArgumentException */ protected function execute(InputInterface $input, OutputInterface $output) { $root = dirname(dirname(dirname(dirname(dirname(__DIR__))))); @@ -75,10 +73,13 @@ protected function execute(InputInterface $input, OutputInterface $output) { $kernel->boot(); $container = $kernel->getContainer(); - + $uid = $input->getArgument('uid'); + if (!is_numeric($uid)) { + throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name)); + } $userEntity = $container->get('entity_type.manager') ->getStorage('user') - ->load($input->getArgument('uid')); + ->load($uid); $url = user_pass_reset_url($userEntity) . '/login'; $output->writeln($url); }