Skip to content

more documentation for interactive commands #29

@tacman

Description

@tacman

In this case, is 'kbond' what is typed in on the CLI when create:user is run? As opposed to being the arguments?

        $this->executeConsoleCommand('create:user', ['kbond'])
            ->assertSuccessful()
            ->assertOutputContains('Creating regular user "kbond"')
        ;

I'm not sure how adding the --no-interaction works.

        // advanced testing interactive commands
        $this->consoleCommand(CreateUserCommand::class)
            ->addInput('kbond')
            ->addOption('--no-interaction') // commands are run interactively if input is provided, use this option to disable
            ->execute()
            ->assertSuccessful()
            ->assertOutputContains('Creating regular user "kbond"')
        ;

I guess I'm looking for a way to test interactive loops, like a command that asks for an email and role, throwing a message if the email already exists.

bin/console add:users

enter email>
abc@def.com
new email!  enter role>
ROLE_USER
@abc@def added with ROLE_USER
enter email>
xyz@def.com
new email!  enter role>
ROLE_ADMIN
@xyz@def added with ROLE_ADMIN
enter email>
abc@def.com
abc@def exists.  enter role>
ROLE_ADMIN
abc@def updated to ROLE_ADMIN
enter email>

Success.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions