|
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
|
|
|
|