-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Standardise the team member commands. Closes #1881
- Loading branch information
Showing
7 changed files
with
49 additions
and
28 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 |
---|---|---|
|
@@ -11,7 +11,12 @@ | |
|
||
namespace CachetHQ\Cachet\Bus\Commands\User; | ||
|
||
final class AddTeamMemberCommand | ||
/** | ||
* This is the add user command. | ||
* | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
final class AddUserCommand | ||
{ | ||
/** | ||
* The user username. | ||
|
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 |
---|---|---|
|
@@ -11,7 +11,12 @@ | |
|
||
namespace CachetHQ\Cachet\Bus\Commands\User; | ||
|
||
final class InviteTeamMemberCommand | ||
/** | ||
* This is the invite user command. | ||
* | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
final class InviteUserCommand | ||
{ | ||
/** | ||
* The invite emails. | ||
|
@@ -30,7 +35,7 @@ final class InviteTeamMemberCommand | |
]; | ||
|
||
/** | ||
* Create a new invite team member command instance. | ||
* Create a new invite user command instance. | ||
* | ||
* @param string[] $emails | ||
* | ||
|
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 |
---|---|---|
|
@@ -11,20 +11,25 @@ | |
|
||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User; | ||
|
||
use CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand; | ||
use CachetHQ\Cachet\Bus\Commands\User\AddUserCommand; | ||
use CachetHQ\Cachet\Bus\Events\User\UserWasAddedEvent; | ||
use CachetHQ\Cachet\Models\User; | ||
|
||
class AddTeamMemberCommandHandler | ||
/** | ||
* This is the add user command handler. | ||
* | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
class AddUserCommandHandler | ||
{ | ||
/** | ||
* Handle the add team member command. | ||
* Handle the add user command. | ||
* | ||
* @param \CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand $command | ||
* @param \CachetHQ\Cachet\Bus\Commands\User\AddUserCommand $command | ||
* | ||
* @return \CachetHQ\Cachet\Models\User | ||
*/ | ||
public function handle(AddTeamMemberCommand $command) | ||
public function handle(AddUserCommand $command) | ||
{ | ||
$user = User::create([ | ||
'username' => $command->username, | ||
|
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 |
---|---|---|
|
@@ -11,20 +11,25 @@ | |
|
||
namespace CachetHQ\Cachet\Bus\Handlers\Commands\User; | ||
|
||
use CachetHQ\Cachet\Bus\Commands\User\InviteTeamMemberCommand; | ||
use CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand; | ||
use CachetHQ\Cachet\Bus\Events\User\UserWasInvitedEvent; | ||
use CachetHQ\Cachet\Models\Invite; | ||
|
||
class InviteTeamMemberCommandHandler | ||
/** | ||
* This is the invite user command handler. | ||
* | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
class InviteUserCommandHandler | ||
{ | ||
/** | ||
* Handle the invite team member command. | ||
* | ||
* @param \CachetHQ\Cachet\Bus\Commands\User\InviteTeamMemberCommand $command | ||
* @param \CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand $command | ||
* | ||
* @return void | ||
*/ | ||
public function handle(InviteTeamMemberCommand $command) | ||
public function handle(InviteUserCommand $command) | ||
{ | ||
foreach ($command->emails as $email) { | ||
$invite = Invite::create([ | ||
|
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 |
---|---|---|
|
@@ -12,17 +12,17 @@ | |
namespace CachetHQ\Tests\Cachet\Bus\Commands\User; | ||
|
||
use AltThree\TestBench\CommandTrait; | ||
use CachetHQ\Cachet\Bus\Commands\User\AddTeamMemberCommand; | ||
use CachetHQ\Cachet\Bus\Handlers\Commands\User\AddTeamMemberCommandHandler; | ||
use CachetHQ\Cachet\Bus\Commands\User\AddUserCommand; | ||
use CachetHQ\Cachet\Bus\Handlers\Commands\User\AddUserCommandHandler; | ||
use CachetHQ\Tests\Cachet\AbstractTestCase; | ||
|
||
/** | ||
* This is the add team member command test class. | ||
* This is the add user command test class. | ||
* | ||
* @author James Brooks <[email protected]> | ||
* @author Graham Campbell <[email protected]> | ||
*/ | ||
class AddTeamMemberCommandTest extends AbstractTestCase | ||
class AddUserCommandTest extends AbstractTestCase | ||
{ | ||
use CommandTrait; | ||
|
||
|
@@ -35,7 +35,7 @@ protected function getObjectAndParams() | |
'level' => 1, | ||
]; | ||
|
||
$object = new AddTeamMemberCommand( | ||
$object = new AddUserCommand( | ||
$params['username'], | ||
$params['password'], | ||
$params['email'], | ||
|
@@ -52,6 +52,6 @@ protected function objectHasRules() | |
|
||
protected function getHandlerClass() | ||
{ | ||
return AddTeamMemberCommandHandler::class; | ||
return AddUserCommandHandler::class; | ||
} | ||
} |
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 |
---|---|---|
|
@@ -12,23 +12,24 @@ | |
namespace CachetHQ\Tests\Cachet\Bus\Commands\User; | ||
|
||
use AltThree\TestBench\CommandTrait; | ||
use CachetHQ\Cachet\Bus\Commands\User\InviteTeamMemberCommand; | ||
use CachetHQ\Cachet\Bus\Handlers\Commands\User\InviteTeamMemberCommandHandler; | ||
use CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand; | ||
use CachetHQ\Cachet\Bus\Handlers\Commands\User\InviteUserCommandHandler; | ||
use CachetHQ\Tests\Cachet\AbstractTestCase; | ||
|
||
/** | ||
* This is the invite team member command test class. | ||
* This is the invite user command test class. | ||
* | ||
* @author Graham Campbell <[email protected]> | ||
* @author James Brooks <[email protected]> | ||
*/ | ||
class InviteTeamMemberCommandTest extends AbstractTestCase | ||
class InviteUserCommandTest extends AbstractTestCase | ||
{ | ||
use CommandTrait; | ||
|
||
protected function getObjectAndParams() | ||
{ | ||
$params = ['emails' => ['[email protected]']]; | ||
$object = new InviteTeamMemberCommand($params['emails']); | ||
$object = new InviteUserCommand($params['emails']); | ||
|
||
return compact('params', 'object'); | ||
} | ||
|
@@ -40,6 +41,6 @@ protected function objectHasRules() | |
|
||
protected function getHandlerClass() | ||
{ | ||
return InviteTeamMemberCommandHandler::class; | ||
return InviteUserCommandHandler::class; | ||
} | ||
} |