Added command tests

This commit is contained in:
James Brooks
2015-10-03 16:34:11 +01:00
parent 939bdf0c4e
commit 127d0d0d55
45 changed files with 1163 additions and 25 deletions

View File

@@ -0,0 +1,31 @@
<?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;
use CachetHQ\Tests\Cachet\AbstractAnemicTestCase;
use Illuminate\Contracts\Bus\Dispatcher;
/**
* This is the abstract command test case class.
*
* @author Graham Campbell <graham@alt-three.com>
*/
abstract class AbstractCommandTestCase extends AbstractAnemicTestCase
{
public function testHandlerCanBeResolved()
{
$command = $this->getObjectAndParams()['object'];
$dispatcher = $this->app->make(Dispatcher::class);
$this->assertInstanceOf($this->getHandlerClass(), $dispatcher->resolveHandler($command));
}
}

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\Component;
use CachetHQ\Cachet\Commands\Component\AddComponentCommand;
use CachetHQ\Cachet\Handlers\Commands\Component\AddComponentCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add component command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class AddComponentCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'description' => 'Foo',
'status' => 1,
'link' => 'https://cachethq.io',
'order' => 0,
'group_id' => 0,
];
$object = new AddComponentCommand(
$params['name'],
$params['description'],
$params['status'],
$params['link'],
$params['order'],
$params['group_id']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return AddComponentCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\Component;
use CachetHQ\Cachet\Commands\Component\RemoveComponentCommand;
use CachetHQ\Cachet\Handlers\Commands\Component\RemoveComponentCommandHandler;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the remove component command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveComponentCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['component' => new Component()];
$object = new RemoveComponentCommand($params['component']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return RemoveComponentCommandHandler::class;
}
}

View File

@@ -0,0 +1,59 @@
<?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\Component;
use CachetHQ\Cachet\Commands\Component\UpdateComponentCommand;
use CachetHQ\Cachet\Handlers\Commands\Component\UpdateComponentCommandHandler;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the update component command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateComponentCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'component' => new Component(),
'name' => 'Test',
'description' => 'Foo',
'status' => 1,
'link' => 'https://cachethq.io',
'order' => 0,
'group_id' => 0,
];
$object = new UpdateComponentCommand(
$params['component'],
$params['name'],
$params['description'],
$params['status'],
$params['link'],
$params['order'],
$params['group_id']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateComponentCommandHandler::class;
}
}

View File

@@ -0,0 +1,48 @@
<?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\ComponentGroup;
use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
use CachetHQ\Cachet\Handlers\Commands\ComponentGroup\AddComponentGroupCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add component group command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class AddComponentGroupCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'order' => 0,
];
$object = new AddComponentGroupCommand(
$params['name'],
$params['order']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return AddComponentGroupCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\ComponentGroup;
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
use CachetHQ\Cachet\Handlers\Commands\ComponentGroup\RemoveComponentGroupCommandHandler;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the remove component group command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveComponentGroupCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['group' => new ComponentGroup()];
$object = new RemoveComponentGroupCommand($params['group']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return RemoveComponentGroupCommandHandler::class;
}
}

View File

@@ -0,0 +1,47 @@
<?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\ComponentGroup;
use CachetHQ\Cachet\Commands\ComponentGroup\UpdateComponentGroupCommand;
use CachetHQ\Cachet\Handlers\Commands\ComponentGroup\UpdateComponentGroupCommandHandler;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the update component group command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateComponentGroupCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'group' => new ComponentGroup(),
'name' => 'Foo',
'order' => 1,
];
$object = new UpdateComponentGroupCommand($params['group'], $params['name'], $params['order']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateComponentGroupCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\Incident;
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Handlers\Commands\Incident\RemoveIncidentCommandHandler;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the remove incident command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveIncidentCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['incident' => new Incident()];
$object = new RemoveIncidentCommand($params['incident']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return RemoveIncidentCommandHandler::class;
}
}

View File

@@ -0,0 +1,60 @@
<?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\Incident;
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
use CachetHQ\Cachet\Handlers\Commands\Incident\ReportIncidentCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add incident command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class ReportIncidentCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'status' => 1,
'message' => 'Foo bar baz',
'visible' => 1,
'component_id' => 1,
'component_status' => 1,
'notify' => false,
'incident_date' => null,
];
$object = new ReportIncidentCommand(
$params['name'],
$params['status'],
$params['message'],
$params['visible'],
$params['component_id'],
$params['component_status'],
$params['notify'],
$params['incident_date']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return ReportIncidentCommandHandler::class;
}
}

View File

@@ -0,0 +1,52 @@
<?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\Incident;
use CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand;
use CachetHQ\Cachet\Handlers\Commands\Incident\ReportMaintenanceCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add incident command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class ReportMaintenanceCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'message' => 'Foo bar baz',
'notify' => false,
'timestamp' => '2020-12-30 00:00:01',
];
$object = new ReportMaintenanceCommand(
$params['name'],
$params['message'],
$params['notify'],
$params['timestamp']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return ReportMaintenanceCommandHandler::class;
}
}

View File

@@ -0,0 +1,63 @@
<?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\Incident;
use CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Handlers\Commands\Incident\UpdateIncidentCommandHandler;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the update incident command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateIncidentCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'incident' => new Incident(),
'name' => 'Test',
'status' => 1,
'message' => 'Foo bar baz',
'visible' => 1,
'component_id' => 1,
'component_status' => 1,
'notify' => false,
'incident_date' => null,
];
$object = new UpdateIncidentCommand(
$params['incident'],
$params['name'],
$params['status'],
$params['message'],
$params['visible'],
$params['component_id'],
$params['component_status'],
$params['notify'],
$params['incident_date']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateIncidentCommandHandler::class;
}
}

View File

@@ -0,0 +1,58 @@
<?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\Metric;
use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
use CachetHQ\Cachet\Handlers\Commands\Metric\AddMetricCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add metric command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class AddMetricCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'name' => 'Coffee',
'suffix' => 'cups',
'description' => 'Cups of coffee consumed',
'default_value' => 0,
'calc_type' => 0,
'display_chart' => 1,
'places' => 0,
];
$object = new AddMetricCommand(
$params['name'],
$params['suffix'],
$params['description'],
$params['default_value'],
$params['calc_type'],
$params['display_chart'],
$params['places']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return AddMetricCommandHandler::class;
}
}

View File

@@ -0,0 +1,51 @@
<?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\Metric;
use CachetHQ\Cachet\Commands\Metric\AddMetricPointCommand;
use CachetHQ\Cachet\Handlers\Commands\Metric\AddMetricPointCommandHandler;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add metric point command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class AddMetricPointCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'metric' => new Metric(),
'value' => 1,
'created_at' => '2020-12-30 12:00:00',
];
$object = new AddMetricPointCommand(
$params['metric'],
$params['value'],
$params['created_at']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return AddMetricPointCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\Metric;
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
use CachetHQ\Cachet\Handlers\Commands\Metric\RemoveMetricCommandHandler;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the remove metric command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveMetricCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['metric' => new Metric()];
$object = new RemoveMetricCommand($params['metric']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return RemoveMetricCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\Metric;
use CachetHQ\Cachet\Commands\Metric\RemoveMetricPointCommand;
use CachetHQ\Cachet\Handlers\Commands\Metric\RemoveMetricPointCommandHandler;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the remove metric point command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveMetricPointCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['metricPoint' => new MetricPoint()];
$object = new RemoveMetricPointCommand($params['metricPoint']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return RemoveMetricPointCommandHandler::class;
}
}

View File

@@ -0,0 +1,61 @@
<?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\Metric;
use CachetHQ\Cachet\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Handlers\Commands\Metric\UpdateMetricCommandHandler;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the update metric command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateMetricCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'metric' => new Metric(),
'name' => 'Coffee',
'suffix' => 'cups',
'description' => 'Cups of coffee consumed',
'default_value' => 0,
'calc_type' => 0,
'display_chart' => 1,
'places' => 0,
];
$object = new UpdateMetricCommand(
$params['metric'],
$params['name'],
$params['suffix'],
$params['description'],
$params['default_value'],
$params['calc_type'],
$params['display_chart'],
$params['places']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateMetricCommandHandler::class;
}
}

View File

@@ -0,0 +1,54 @@
<?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\Metric;
use CachetHQ\Cachet\Commands\Metric\UpdateMetricPointCommand;
use CachetHQ\Cachet\Handlers\Commands\Metric\UpdateMetricPointCommandHandler;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the update metric point command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateMetricPointCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'point' => new MetricPoint(),
'metric' => new Metric(),
'value' => 1,
'created_at' => '2012-12-30 12:00:00',
];
$object = new UpdateMetricPointCommand(
$params['point'],
$params['metric'],
$params['value'],
$params['created_at']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateMetricPointCommandHandler::class;
}
}

View File

@@ -0,0 +1,48 @@
<?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\Subscriber;
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
use CachetHQ\Cachet\Handlers\Commands\Subscriber\SubscribeSubscriberCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the subscribe subscriber command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class SubscribeSubscriberCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'email' => 'support@cachethq.io',
'verified' => true,
];
$object = new SubscribeSubscriberCommand(
$params['email'],
$params['verified']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return SubscribeSubscriberCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\Subscriber;
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Handlers\Commands\Subscriber\UnsubscribeSubscriberCommandHandler;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the unsubscribe subscriber command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UnsubscribeSubscriberCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new UnsubscribeSubscriberCommand($params['subscriber']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return UnsubscribeSubscriberCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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\Subscriber;
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
use CachetHQ\Cachet\Handlers\Commands\Subscriber\VerifySubscriberCommandHandler;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the verify subscriber command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class VerifySubscriberCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new VerifySubscriberCommand($params['subscriber']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return VerifySubscriberCommandHandler::class;
}
}

View File

@@ -0,0 +1,52 @@
<?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 CachetHQ\Cachet\Commands\User\AddTeamMemberCommand;
use CachetHQ\Cachet\Handlers\Commands\User\AddTeamMemberCommandHandler;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the add team member command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class AddTeamMemberCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = [
'username' => 'Test',
'password' => 'fooey',
'email' => 'test@test.com',
'level' => 1,
];
$object = new AddTeamMemberCommand(
$params['username'],
$params['password'],
$params['email'],
$params['level']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return AddTeamMemberCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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 CachetHQ\Cachet\Commands\User\GenerateApiTokenCommand;
use CachetHQ\Cachet\Handlers\Commands\User\GenerateApiTokenCommandHandler;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the generate api token command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class GenerateApiTokenCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new GenerateApiTokenCommand($params['user']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return GenerateApiTokenCommandHandler::class;
}
}

View File

@@ -0,0 +1,43 @@
<?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 CachetHQ\Cachet\Commands\User\RemoveUserCommand;
use CachetHQ\Cachet\Handlers\Commands\User\RemoveUserCommandHandler;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
/**
* This is the remove user command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveUserCommandTest extends AbstractCommandTestCase
{
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new RemoveUserCommand($params['user']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return RemoveUserCommandHandler::class;
}
}