-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW Add AbstractMemberCommand and implement into existing member comm…
…ands
- Loading branch information
1 parent
50c7f92
commit e170561
Showing
7 changed files
with
73 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
|
||
namespace SilverLeague\Console\Command\Member; | ||
|
||
use SilverLeague\Console\Command\SilverStripeCommand; | ||
use SilverStripe\Security\Member; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
/** | ||
* Provides a base for member related commands, lookups etc | ||
* | ||
* @package silverstripe-console | ||
* @author Robbie Averill <robbie@averill.co.nz> | ||
*/ | ||
abstract class AbstractMemberCommand extends SilverStripeCommand | ||
{ | ||
/** | ||
* Get a member by the provided email address, output an error message if not found | ||
* | ||
* @param InputInterface $input | ||
* @param OutputInterface $output | ||
* @return Member|false | ||
*/ | ||
protected function getMember(InputInterface $input, OutputInterface $output) | ||
{ | ||
$email = $this->getOrAskForArgument($input, $output, 'email', 'Enter email address: '); | ||
if (empty($email)) { | ||
$output->writeln('<error>Please enter an email address.</error>'); | ||
return false; | ||
} | ||
|
||
/** @var Member $member */ | ||
$member = Member::get()->filter('email', $email)->first(); | ||
if (!$member) { | ||
$output->writeln('<error>Member with email "' . $email . '" was not found.'); | ||
return false; | ||
} | ||
|
||
return $member; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,14 +50,19 @@ public function testExecute() | |
|
||
$this->command->getApplication()->getHelperSet()->set($questionHelper, 'question'); | ||
|
||
$tester = $this->executeTest( | ||
[ | ||
'email' => '[email protected]', | ||
'password' => 'OpenSe$am3!' | ||
] | ||
); | ||
$tester = $this->executeTest([ | ||
'email' => '[email protected]', | ||
'password' => 'OpenSe$am3!', | ||
]); | ||
$output = $tester->getDisplay(); | ||
$this->assertContains('Member created', $output); | ||
|
||
$tester = $this->executeTest([ | ||
'email' => '[email protected]', | ||
'password' => 'OpenSe$am3!', | ||
]); | ||
$output = $tester->getDisplay(); | ||
$this->assertContains('Member already exists', $output); | ||
} | ||
|
||
/** | ||
|