Merge pull request #1198 from cachethq/commands

Commands
This commit is contained in:
Graham Campbell 2015-12-06 11:37:08 +00:00
commit c73c5d28a1
10 changed files with 156 additions and 10 deletions

View File

@ -116,7 +116,7 @@ final class ReportIncidentCommand
*
* @return void
*/
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date, $template, $template_vars)
public function __construct($name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date, $template, array $template_vars = null)
{
$this->name = $name;
$this->status = $status;

View File

@ -125,7 +125,7 @@ final class UpdateIncidentCommand
*
* @return void
*/
public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date, $template, $template_vars)
public function __construct(Incident $incident, $name, $status, $message, $visible, $component_id, $component_status, $notify, $incident_date, $template, array $template_vars = null)
{
$this->incident = $incident;
$this->name = $name;

View File

@ -11,23 +11,25 @@
namespace CachetHQ\Cachet\Commands\Invite;
use CachetHQ\Cachet\Models\Invite;
final class ClaimInviteCommand
{
/**
* The invte to mark as claimed.
*
* @var \CachetHQ\Cachet\Model\Invite
* @var \CachetHQ\Cachet\Models\Invite
*/
public $invite;
/**
* Create a new claim invite command instance.
*
* @param \CachetHQ\Cachet\Model\Invite $invite
* @param \CachetHQ\Cachet\Models\Invite $invite
*
* @return void
*/
public function __construct($invite)
public function __construct(Invite $invite)
{
$this->invite = $invite;
}

View File

@ -25,7 +25,7 @@ final class UnsubscribeSubscriberCommand
/**
* Create a unsubscribe subscriber command instance.
*
* @param string $subscriber
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
*
* @return void
*/

View File

@ -25,7 +25,7 @@ final class VerifySubscriberCommand
/**
* Create a verify subscriber command instance.
*
* @param string $subscriber
* @param \CachetHQ\Cachet\Models\Subscriber $subscriber
*
* @return void
*/

View File

@ -11,6 +11,8 @@
namespace CachetHQ\Cachet\Commands\User;
use CachetHQ\Cachet\Models\User;
final class GenerateApiTokenCommand
{
/**
@ -27,7 +29,7 @@ final class GenerateApiTokenCommand
*
* @return void
*/
public function __construct($user)
public function __construct(User $user)
{
$this->user = $user;
}

View File

@ -32,11 +32,11 @@ final class InviteTeamMemberCommand
/**
* Create a new invite team member command instance.
*
* @param array $email
* @param string[] $email
*
* @return void
*/
public function __construct($emails)
public function __construct(array $emails)
{
$this->emails = $emails;
}

View File

@ -0,0 +1,41 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\Commands\Invite;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Commands\Invite\ClaimInviteCommand;
use CachetHQ\Cachet\Handlers\Commands\Invite\ClaimInviteCommandHandler;
use CachetHQ\Cachet\Models\Invite;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the claim invite command test class.
*
* @author Graham Campbell <graham@alt-three.com>
*/
class ClaimInviteCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['invite' => new Invite()];
$object = new ClaimInviteCommand($params['invite']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return ClaimInviteCommandHandler::class;
}
}

View File

@ -0,0 +1,45 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Commands\User\InviteTeamMemberCommand;
use CachetHQ\Cachet\Handlers\Commands\User\InviteTeamMemberCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the invite team member command test class.
*
* @author Graham Campbell <graham@alt-three.com>
*/
class InviteTeamMemberCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['emails' => ['foo@example.com']];
$object = new InviteTeamMemberCommand($params['emails']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return InviteTeamMemberCommandHandler::class;
}
}

View File

@ -0,0 +1,56 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Commands\User\SignupUserCommand;
use CachetHQ\Cachet\Handlers\Commands\User\SignupUserCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the signup user command test class.
*
* @author Graham Campbell <graham@alt-three.com>
*/
class SignupUserCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'username' => 'Test',
'password' => 'fooey',
'email' => 'test@test.com',
'level' => 1,
];
$object = new SignupUserCommand(
$params['username'],
$params['password'],
$params['email'],
$params['level']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return SignupUserCommandHandler::class;
}
}