Completed
Push — master ( 01b890...0ab6a2 )
by Robbie
01:15
created

CreateCommandTest::getTestCommand()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace SilverLeague\Console\Tests\Command\Member;
4
5
use SilverLeague\Console\Tests\Command\AbstractCommandTest;
6
use SilverStripe\Security\Member;
7
use Symfony\Component\Console\Helper\QuestionHelper;
8
9
/**
10
 * @coversDefaultClass \SilverLeague\Console\Command\Member\CreateCommand
11
 * @package silverstripe-console
12
 * @author  Robbie Averill <[email protected]>
13
 */
14
class CreateCommandTest extends AbstractCommandTest
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19
    public function getTestCommand()
20
    {
21
        return 'member:create';
22
    }
23
24
    /**
25
     * Test that a Member can be created
26
     *
27
     * @covers ::execute
28
     */
29
    public function testExecute()
30
    {
31
        // Remove any existing members from the database
32
        Member::get()->removeAll();
33
34
        $questionHelper = $this
35
            ->getMockBuilder(QuestionHelper::class)
36
            ->setMethods(['ask'])
37
            ->getMock();
38
39
        $questionHelper
40
            ->expects($this->atLeastOnce())
41
            ->method('ask')
42
            ->willReturn(false);
43
44
        $this->command->getApplication()->getHelperSet()->set($questionHelper, 'question');
45
46
        $tester = $this->executeTest(
47
            [
48
                'email'    => '[email protected]',
49
                'password' => 'opensesame'
50
            ]
51
        );
52
        $output = $tester->getDisplay();
53
        $this->assertContains('Member created', $output);
54
    }
55
56
    /**
57
     * Ensure that the InputArgument for at least one of the arguments has been added
58
     *
59
     * @covers ::configure
60
     */
61
    public function testConfigure()
62
    {
63
        $this->assertTrue($this->command->getDefinition()->hasArgument('email'));
64
    }
65
}
66