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

ChangePasswordCommandTest::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
8
/**
9
 * @coversDefaultClass \SilverLeague\Console\Command\Member\ChangePasswordCommand
10
 * @package silverstripe-console
11
 * @author  Robbie Averill <[email protected]>
12
 */
13
class ChangePasswordCommandTest extends AbstractCommandTest
14
{
15
    /**
16
     * Create a Member to play with
17
     */
18
    public function setUp()
19
    {
20
        parent::setUp();
21
22
        Member::get()->removeAll();
23
        $member = Member::create();
24
        $member->Email = '[email protected]';
25
        $member->Password = 'notrelevant';
26
        $member->write();
27
    }
28
29
    /**
30
     * {@inheritDoc}
31
     */
32
    public function getTestCommand()
33
    {
34
        return 'member:change-password';
35
    }
36
37
    /**
38
     * Test that our existing Member's password can be changed
39
     *
40
     * @covers ::execute
41
     */
42
    public function testExecute()
43
    {
44
        $tester = $this->executeTest(['email' => '[email protected]', 'password' => 'newpassword']);
45
        $this->assertContains('Password updated', $tester->getDisplay());
46
    }
47
48
    /**
49
     * Test that if an email does not match a Member, then an error is returned
50
     *
51
     * @covers ::execute
52
     */
53
    public function testErrorWhenEmailNotFound()
54
    {
55
        $tester = $this->executeTest(['email' => '[email protected]', 'password' => 'newpassword']);
56
        $this->assertContains('Member with email "[email protected]" was not found', $tester->getDisplay());
57
    }
58
59
    /**
60
     * Ensure that the InputArgument for at least one of the arguments has been added
61
     *
62
     * @covers ::configure
63
     */
64
    public function testConfigure()
65
    {
66
        $this->assertTrue($this->command->getDefinition()->hasArgument('password'));
67
    }
68
}
69