Completed
Pull Request — master (#1)
by Paul
06:16 queued 02:53
created

DeleteTestUsersCommand::configure()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 8

Duplication

Lines 11
Ratio 100 %
Metric Value
dl 11
loc 11
rs 9.4285
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace Codeception\Module\Drupal\UserRegistry\Command;
4
5
use Codeception\Exception\Module as ModuleException;
6
use Symfony\Component\Console\Command\Command;
7
use Symfony\Component\Console\Input\InputArgument;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
11
/**
12
 * Class DeleteTestUsersCommand.
13
 *
14
 * @package Codeception\Module\Drupal\UserRegistry\Command
15
 */
16 View Code Duplication
class DeleteTestUsersCommand extends Command
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    use TestUsersCommandTrait;
19
20
    /**
21
     * Configuration for this command.
22
     */
23
    protected function configure()
24
    {
25
        $this
26
            ->setName('users:delete')
27
            ->setDescription('Delete test users.')
28
            ->addArgument(
29
                'suite',
30
                InputArgument::OPTIONAL,
31
                "Which suite configuration to use. Defaults to 'acceptance'."
32
            );
33
    }
34
35
    /**
36
     * Execute command: create any defined test users on the configured Drush alias.
37
     *
38
     * @todo Codeception debug calls won't work here.
39
     *
40
     * @param InputInterface $input
41
     *   The command input.
42
     *
43
     * @param OutputInterface $output
44
     *   The command output.
45
     *
46
     * @return int|null|void
47
     *
48
     * @throws ModuleException
49
     */
50
    protected function execute(InputInterface $input, OutputInterface $output)
51
    {
52
        // The suite name can be passed as an argument. Without it, the command defaults to 'acceptance'.
53
        $suiteName = $input->getArgument('suite');
54
        if (!$suiteName) {
55
            $suiteName = 'acceptance';
56
        }
57
58
        $this->getTestUsers($suiteName);
59
        $this->testUserManager->deleteUsers($this->users);
60
    }
61
}
62