mirror of
https://github.com/CachetHQ/Cachet.git
synced 2025-01-17 21:49:01 +01:00
commit
f3d2b5ba9c
@ -39,6 +39,7 @@
|
||||
"roumen/feed": "^2.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"alt-three/testbench": "^1.0",
|
||||
"filp/whoops": "^1.1",
|
||||
"fzaninotto/faker": "^1.5",
|
||||
"graham-campbell/testbench-core": "^1.1",
|
||||
|
62
composer.lock
generated
62
composer.lock
generated
@ -4,8 +4,8 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"hash": "68368056b2e111808dc9fde989b5324d",
|
||||
"content-hash": "976eda704e6a191e2bd557cb919f1ed6",
|
||||
"hash": "d02e0141216bd2f17d2c97a5e7d0baab",
|
||||
"content-hash": "2dd41f1dc4f63c1ffae8cb0fc62ebfb5",
|
||||
"packages": [
|
||||
{
|
||||
"name": "alt-three/emoji",
|
||||
@ -3694,6 +3694,64 @@
|
||||
}
|
||||
],
|
||||
"packages-dev": [
|
||||
{
|
||||
"name": "alt-three/testbench",
|
||||
"version": "dev-master",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/AltThree/TestBench.git",
|
||||
"reference": "cf53fab68ef3e397a0a72dc93fba2c65735916fa"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/AltThree/TestBench/zipball/cf53fab68ef3e397a0a72dc93fba2c65735916fa",
|
||||
"reference": "cf53fab68ef3e397a0a72dc93fba2c65735916fa",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"graham-campbell/testbench-core": "^1.1",
|
||||
"php": ">=5.5.9"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "^4.8|^5.0"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.0-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"AltThree\\TestBench\\": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "James Brooks",
|
||||
"email": "james@alt-three.com"
|
||||
},
|
||||
{
|
||||
"name": "Graham Campbell",
|
||||
"email": "graham@alt-three.com"
|
||||
},
|
||||
{
|
||||
"name": "Joseph Cohen",
|
||||
"email": "joe@alt-three.com"
|
||||
}
|
||||
],
|
||||
"description": "Provides Some Testing Traits For Alt Three Applications",
|
||||
"keywords": [
|
||||
"Alt Three",
|
||||
"TestBench",
|
||||
"application"
|
||||
],
|
||||
"time": "2015-12-06 10:47:25"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/instantiator",
|
||||
"version": "1.0.5",
|
||||
|
@ -1,67 +0,0 @@
|
||||
<?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;
|
||||
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* This is the abstract anemic test case class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractAnemicTestCase extends AbstractTestCase
|
||||
{
|
||||
public function testClassIsFinal()
|
||||
{
|
||||
$rc = new ReflectionClass($this->getObjectAndParams()['object']);
|
||||
|
||||
$this->assertTrue($rc->isFinal());
|
||||
}
|
||||
|
||||
public function testPropertiesMatchTheConstructor()
|
||||
{
|
||||
$rc = new ReflectionClass($this->getObjectAndParams()['object']);
|
||||
|
||||
$properties = array_map(function ($property) {
|
||||
return $property->getName();
|
||||
}, $rc->getProperties());
|
||||
|
||||
$params = array_map(function ($param) {
|
||||
return $param->getName();
|
||||
}, $rc->getMethod('__construct')->getParameters());
|
||||
|
||||
if ($this->objectHasRules()) {
|
||||
$params[] = 'rules';
|
||||
}
|
||||
|
||||
$this->assertSame($properties, $params);
|
||||
}
|
||||
|
||||
public function testPropertiesAreCorrectlyDefined()
|
||||
{
|
||||
$rc = new ReflectionClass($this->getObjectAndParams()['object']);
|
||||
|
||||
foreach ($rc->getProperties() as $property) {
|
||||
$this->assertTrue($property->isPublic());
|
||||
$this->assertFalse($property->isStatic());
|
||||
}
|
||||
}
|
||||
|
||||
public function testPropertyAccessBehavesCorrectly()
|
||||
{
|
||||
extract($this->getObjectAndParams());
|
||||
|
||||
foreach ($params as $key => $value) {
|
||||
$this->assertSame($value, $object->{$key});
|
||||
}
|
||||
}
|
||||
}
|
@ -11,10 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
use Illuminate\Foundation\Testing\TestCase;
|
||||
|
||||
/**
|
||||
* This is the abstract test case class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractTestCase extends TestCase
|
||||
{
|
||||
/**
|
||||
@ -37,14 +41,4 @@ abstract class AbstractTestCase extends TestCase
|
||||
|
||||
return $app;
|
||||
}
|
||||
|
||||
/**
|
||||
* Become a user.
|
||||
*/
|
||||
protected function beUser()
|
||||
{
|
||||
$this->user = factory(User::class)->create();
|
||||
|
||||
$this->be($this->user);
|
||||
}
|
||||
}
|
||||
|
36
tests/Api/AbstractApiTestCase.php
Normal file
36
tests/Api/AbstractApiTestCase.php
Normal file
@ -0,0 +1,36 @@
|
||||
<?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\Api;
|
||||
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
/**
|
||||
* This is the abstract api test case class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractApiTestCase extends AbstractTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
/**
|
||||
* Become a user.
|
||||
*/
|
||||
protected function beUser()
|
||||
{
|
||||
$this->user = factory(User::class)->create();
|
||||
|
||||
$this->be($this->user);
|
||||
}
|
||||
}
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class ComponentGroupTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the component group test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class ComponentGroupTest extends AbstractApiTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testGetGroups()
|
||||
{
|
||||
$groups = factory('CachetHQ\Cachet\Models\ComponentGroup', 3)->create();
|
||||
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class ComponentTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the component test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class ComponentTest extends AbstractApiTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testGetComponents()
|
||||
{
|
||||
$components = factory('CachetHQ\Cachet\Models\Component', 3)->create();
|
||||
|
@ -11,9 +11,13 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
class GeneralTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the general test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class GeneralTest extends AbstractApiTestCase
|
||||
{
|
||||
public function testGetPing()
|
||||
{
|
||||
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class IncidentTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the incident test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class IncidentTest extends AbstractApiTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testGetIncidents()
|
||||
{
|
||||
$incidents = factory('CachetHQ\Cachet\Models\Incident', 3)->create();
|
||||
|
@ -11,14 +11,16 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class MetricPointTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the metric point test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class MetricPointTest extends AbstractApiTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testGetMetricPoint()
|
||||
{
|
||||
$metric = factory('CachetHQ\Cachet\Models\Metric')->create();
|
||||
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class MetricTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the metric test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class MetricTest extends AbstractApiTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testGetMetrics()
|
||||
{
|
||||
$metrics = factory('CachetHQ\Cachet\Models\Metric', 3)->create();
|
||||
|
@ -11,13 +11,14 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Api;
|
||||
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
|
||||
class SubscriberTest extends AbstractTestCase
|
||||
/**
|
||||
* This is the subscriber test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class SubscriberTest extends AbstractApiTestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testGetSubscribersUnauthenticated()
|
||||
{
|
||||
$this->get('/api/v1/subscribers');
|
||||
|
@ -1,31 +0,0 @@
|
||||
<?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));
|
||||
}
|
||||
}
|
@ -11,17 +11,21 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Component;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Component\AddComponentCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Component\AddComponentCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add component command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class AddComponentCommandTest extends AbstractCommandTestCase
|
||||
class AddComponentCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Component;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Component\RemoveComponentCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Component\RemoveComponentCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove component command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RemoveComponentCommandTest extends AbstractCommandTestCase
|
||||
class RemoveComponentCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['component' => new Component()];
|
||||
@ -31,11 +35,6 @@ class RemoveComponentCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveComponentCommandHandler::class;
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Component;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Component\UpdateComponentCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Component\UpdateComponentCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Component;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update component command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UpdateComponentCommandTest extends AbstractCommandTestCase
|
||||
class UpdateComponentCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -35,6 +39,7 @@ class UpdateComponentCommandTest extends AbstractCommandTestCase
|
||||
'group_id' => 0,
|
||||
'enabled' => true,
|
||||
];
|
||||
|
||||
$object = new UpdateComponentCommand(
|
||||
$params['component'],
|
||||
$params['name'],
|
||||
|
@ -11,27 +11,26 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\ComponentGroup;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\AddComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\ComponentGroup\AddComponentGroupCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add component group command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class AddComponentGroupCommandTest extends AbstractCommandTestCase
|
||||
class AddComponentGroupCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'name' => 'Test',
|
||||
'order' => 0,
|
||||
];
|
||||
$object = new AddComponentGroupCommand(
|
||||
$params['name'],
|
||||
$params['order']
|
||||
);
|
||||
$params = ['name' => 'Test', 'order' => 0];
|
||||
|
||||
$object = new AddComponentGroupCommand($params['name'], $params['order']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\ComponentGroup;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\RemoveComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\ComponentGroup\RemoveComponentGroupCommandHandler;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove component group command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RemoveComponentGroupCommandTest extends AbstractCommandTestCase
|
||||
class RemoveComponentGroupCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['group' => new ComponentGroup()];
|
||||
@ -31,11 +35,6 @@ class RemoveComponentGroupCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveComponentGroupCommandHandler::class;
|
||||
|
@ -11,25 +11,25 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\ComponentGroup;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\ComponentGroup\UpdateComponentGroupCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\ComponentGroup\UpdateComponentGroupCommandHandler;
|
||||
use CachetHQ\Cachet\Models\ComponentGroup;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update component group command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UpdateComponentGroupCommandTest extends AbstractCommandTestCase
|
||||
class UpdateComponentGroupCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'group' => new ComponentGroup(),
|
||||
'name' => 'Foo',
|
||||
'order' => 1,
|
||||
];
|
||||
$params = ['group' => new ComponentGroup(), 'name' => 'Foo', 'order' => 1];
|
||||
$object = new UpdateComponentGroupCommand($params['group'], $params['name'], $params['order']);
|
||||
|
||||
return compact('params', 'object');
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Incident;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Incident\RemoveIncidentCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Incident\RemoveIncidentCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove incident command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RemoveIncidentCommandTest extends AbstractCommandTestCase
|
||||
class RemoveIncidentCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['incident' => new Incident()];
|
||||
@ -31,11 +35,6 @@ class RemoveIncidentCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveIncidentCommandHandler::class;
|
||||
|
@ -11,17 +11,21 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Incident;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportIncidentCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Incident\ReportIncidentCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add incident command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class ReportIncidentCommandTest extends AbstractCommandTestCase
|
||||
class ReportIncidentCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -36,6 +40,7 @@ class ReportIncidentCommandTest extends AbstractCommandTestCase
|
||||
'template' => null,
|
||||
'template_vars' => null,
|
||||
];
|
||||
|
||||
$object = new ReportIncidentCommand(
|
||||
$params['name'],
|
||||
$params['status'],
|
||||
|
@ -11,17 +11,21 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Incident;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Incident\ReportMaintenanceCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Incident\ReportMaintenanceCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add incident command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class ReportMaintenanceCommandTest extends AbstractCommandTestCase
|
||||
class ReportMaintenanceCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -30,6 +34,7 @@ class ReportMaintenanceCommandTest extends AbstractCommandTestCase
|
||||
'notify' => false,
|
||||
'timestamp' => '2020-12-30 00:00:01',
|
||||
];
|
||||
|
||||
$object = new ReportMaintenanceCommand(
|
||||
$params['name'],
|
||||
$params['message'],
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Incident;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Incident\UpdateIncidentCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Incident\UpdateIncidentCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Incident;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update incident command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UpdateIncidentCommandTest extends AbstractCommandTestCase
|
||||
class UpdateIncidentCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -38,6 +42,7 @@ class UpdateIncidentCommandTest extends AbstractCommandTestCase
|
||||
'template' => null,
|
||||
'template_vars' => null,
|
||||
];
|
||||
|
||||
$object = new UpdateIncidentCommand(
|
||||
$params['incident'],
|
||||
$params['name'],
|
||||
|
@ -11,17 +11,21 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Metric;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Metric\AddMetricCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add metric command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class AddMetricCommandTest extends AbstractCommandTestCase
|
||||
class AddMetricCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -33,6 +37,7 @@ class AddMetricCommandTest extends AbstractCommandTestCase
|
||||
'display_chart' => 1,
|
||||
'places' => 0,
|
||||
];
|
||||
|
||||
$object = new AddMetricCommand(
|
||||
$params['name'],
|
||||
$params['suffix'],
|
||||
|
@ -11,30 +11,26 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Metric;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Metric\AddMetricPointCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Metric\AddMetricPointCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add metric point command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class AddMetricPointCommandTest extends AbstractCommandTestCase
|
||||
class AddMetricPointCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
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']
|
||||
);
|
||||
$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');
|
||||
}
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Metric;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Metric\RemoveMetricCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove metric command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RemoveMetricCommandTest extends AbstractCommandTestCase
|
||||
class RemoveMetricCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['metric' => new Metric()];
|
||||
@ -31,11 +35,6 @@ class RemoveMetricCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveMetricCommandHandler::class;
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Metric;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Metric\RemoveMetricPointCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Metric\RemoveMetricPointCommandHandler;
|
||||
use CachetHQ\Cachet\Models\MetricPoint;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove metric point command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RemoveMetricPointCommandTest extends AbstractCommandTestCase
|
||||
class RemoveMetricPointCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['metricPoint' => new MetricPoint()];
|
||||
@ -31,11 +35,6 @@ class RemoveMetricPointCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveMetricPointCommandHandler::class;
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Metric;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Metric\UpdateMetricCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Metric\UpdateMetricCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Metric;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update metric command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UpdateMetricCommandTest extends AbstractCommandTestCase
|
||||
class UpdateMetricCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -35,6 +39,7 @@ class UpdateMetricCommandTest extends AbstractCommandTestCase
|
||||
'display_chart' => 1,
|
||||
'places' => 0,
|
||||
];
|
||||
|
||||
$object = new UpdateMetricCommand(
|
||||
$params['metric'],
|
||||
$params['name'],
|
||||
|
@ -11,19 +11,23 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Metric;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
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;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the update metric point command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UpdateMetricPointCommandTest extends AbstractCommandTestCase
|
||||
class UpdateMetricPointCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -32,6 +36,7 @@ class UpdateMetricPointCommandTest extends AbstractCommandTestCase
|
||||
'value' => 1,
|
||||
'created_at' => '2012-12-30 12:00:00',
|
||||
];
|
||||
|
||||
$object = new UpdateMetricPointCommand(
|
||||
$params['point'],
|
||||
$params['metric'],
|
||||
|
@ -11,27 +11,25 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Subscriber;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\SubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Subscriber\SubscribeSubscriberCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the subscribe subscriber command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class SubscribeSubscriberCommandTest extends AbstractCommandTestCase
|
||||
class SubscribeSubscriberCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
'email' => 'support@cachethq.io',
|
||||
'verified' => true,
|
||||
];
|
||||
$object = new SubscribeSubscriberCommand(
|
||||
$params['email'],
|
||||
$params['verified']
|
||||
);
|
||||
$params = ['email' => 'support@cachethq.io', 'verified' => true];
|
||||
$object = new SubscribeSubscriberCommand($params['email'], $params['verified']);
|
||||
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Subscriber;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\UnsubscribeSubscriberCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Subscriber\UnsubscribeSubscriberCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the unsubscribe subscriber command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UnsubscribeSubscriberCommandTest extends AbstractCommandTestCase
|
||||
class UnsubscribeSubscriberCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['subscriber' => new Subscriber()];
|
||||
@ -31,11 +35,6 @@ class UnsubscribeSubscriberCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return UnsubscribeSubscriberCommandHandler::class;
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\Subscriber;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\Subscriber\VerifySubscriberCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\Subscriber\VerifySubscriberCommandHandler;
|
||||
use CachetHQ\Cachet\Models\Subscriber;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the verify subscriber command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class VerifySubscriberCommandTest extends AbstractCommandTestCase
|
||||
class VerifySubscriberCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['subscriber' => new Subscriber()];
|
||||
@ -31,11 +35,6 @@ class VerifySubscriberCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return VerifySubscriberCommandHandler::class;
|
||||
|
@ -11,17 +11,21 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\User;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\User\AddTeamMemberCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\User\AddTeamMemberCommandHandler;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the add team member command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class AddTeamMemberCommandTest extends AbstractCommandTestCase
|
||||
class AddTeamMemberCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = [
|
||||
@ -30,6 +34,7 @@ class AddTeamMemberCommandTest extends AbstractCommandTestCase
|
||||
'email' => 'test@test.com',
|
||||
'level' => 1,
|
||||
];
|
||||
|
||||
$object = new AddTeamMemberCommand(
|
||||
$params['username'],
|
||||
$params['password'],
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\User;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\User\GenerateApiTokenCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\User\GenerateApiTokenCommandHandler;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the generate api token command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class GenerateApiTokenCommandTest extends AbstractCommandTestCase
|
||||
class GenerateApiTokenCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
@ -31,11 +35,6 @@ class GenerateApiTokenCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return GenerateApiTokenCommandHandler::class;
|
||||
|
@ -11,18 +11,22 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Commands\User;
|
||||
|
||||
use AltThree\TestBench\CommandTrait;
|
||||
use CachetHQ\Cachet\Commands\User\RemoveUserCommand;
|
||||
use CachetHQ\Cachet\Handlers\Commands\User\RemoveUserCommandHandler;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
use CachetHQ\Tests\Cachet\Commands\AbstractCommandTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
/**
|
||||
* This is the remove user command test class.
|
||||
*
|
||||
* @author James Brooks <james@alt-three.com>
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RemoveUserCommandTest extends AbstractCommandTestCase
|
||||
class RemoveUserCommandTest extends AbstractTestCase
|
||||
{
|
||||
use CommandTrait;
|
||||
|
||||
protected function getObjectAndParams()
|
||||
{
|
||||
$params = ['user' => new User()];
|
||||
@ -31,11 +35,6 @@ class RemoveUserCommandTest extends AbstractCommandTestCase
|
||||
return compact('params', 'object');
|
||||
}
|
||||
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function getHandlerClass()
|
||||
{
|
||||
return RemoveUserCommandHandler::class;
|
||||
|
@ -1,64 +0,0 @@
|
||||
<?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\Events;
|
||||
|
||||
use CachetHQ\Cachet\Providers\EventServiceProvider;
|
||||
use CachetHQ\Tests\Cachet\AbstractAnemicTestCase;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* This is the abstract event test case class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractEventTestCase extends AbstractAnemicTestCase
|
||||
{
|
||||
protected function objectHasRules()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function objectHasHandlers()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public function testEventImplementsTheCorrectInterfaces()
|
||||
{
|
||||
$event = $this->getObjectAndParams()['object'];
|
||||
|
||||
foreach ($this->getEventInterfaces() as $interface) {
|
||||
$this->assertInstanceOf($interface, $event);
|
||||
}
|
||||
}
|
||||
|
||||
public function testEventHasRegisteredHandlers()
|
||||
{
|
||||
$property = (new ReflectionClass(EventServiceProvider::class))->getProperty('listen');
|
||||
$property->setAccessible(true);
|
||||
|
||||
$class = get_class($this->getObjectAndParams()['object']);
|
||||
$mappings = $property->getValue(new EventServiceProvider($this->app));
|
||||
|
||||
$this->assertTrue(isset($mappings[$class]));
|
||||
|
||||
if ($this->objectHasHandlers()) {
|
||||
$this->assertGreaterThan(0, count($mappings[$class]));
|
||||
} else {
|
||||
$this->assertSame(0, count($mappings[$class]));
|
||||
}
|
||||
|
||||
foreach ($mappings[$class] as $handler) {
|
||||
$this->assertInstanceOf($handler, $this->app->make($handler));
|
||||
}
|
||||
}
|
||||
}
|
@ -11,11 +11,19 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Events\User;
|
||||
|
||||
use AltThree\TestBench\EventTrait;
|
||||
use CachetHQ\Cachet\Events\User\UserEventInterface;
|
||||
use CachetHQ\Tests\Cachet\Events\AbstractEventTestCase;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
|
||||
class AbstractUserEventTestCase extends AbstractEventTestCase
|
||||
/**
|
||||
* This is the abstract user event test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
abstract class AbstractUserEventTestCase extends AbstractTestCase
|
||||
{
|
||||
use EventTrait;
|
||||
|
||||
protected function getEventInterfaces()
|
||||
{
|
||||
return [UserEventInterface::class];
|
||||
|
@ -14,6 +14,11 @@ namespace CachetHQ\Tests\Cachet\Events\User;
|
||||
use CachetHQ\Cachet\Events\User\UserWasAddedEvent;
|
||||
use CachetHQ\Cachet\Models\User;
|
||||
|
||||
/**
|
||||
* This is the user was added event test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class UserWasAddedEventTest extends AbstractUserEventTestCase
|
||||
{
|
||||
protected function objectHasHandlers()
|
||||
|
@ -14,6 +14,11 @@ namespace CachetHQ\Tests\Cachet\Functional;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use Illuminate\Contracts\Console\Kernel;
|
||||
|
||||
/**
|
||||
* This is the command test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class CommandTest extends AbstractTestCase
|
||||
{
|
||||
public function testMigrations()
|
||||
|
@ -11,17 +11,15 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Providers\AppServiceProvider;
|
||||
use AltThree\TestBench\ServiceProviderTrait;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use GrahamCampbell\TestBenchCore\LaravelTrait;
|
||||
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||
|
||||
/**
|
||||
* This is the app service provider test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class AppServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use LaravelTrait, ServiceProviderTrait;
|
||||
|
||||
protected function getServiceProviderClass($app)
|
||||
{
|
||||
return AppServiceProvider::class;
|
||||
}
|
||||
use ServiceProviderTrait;
|
||||
}
|
||||
|
@ -11,67 +11,15 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Providers\EventServiceProvider;
|
||||
use AltThree\TestBench\EventServiceProviderTrait;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use GrahamCampbell\TestBenchCore\LaravelTrait;
|
||||
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
|
||||
use ReflectionClass;
|
||||
|
||||
/**
|
||||
* This is the event service provider test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class EventServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use LaravelTrait, ServiceProviderTrait;
|
||||
|
||||
protected function getServiceProviderClass($app)
|
||||
{
|
||||
return EventServiceProvider::class;
|
||||
}
|
||||
|
||||
public function testIsAnEventServiceProvider()
|
||||
{
|
||||
$class = $this->getServiceProviderClass($this->app);
|
||||
$reflection = new ReflectionClass($class);
|
||||
$provider = new ReflectionClass(ServiceProvider::class);
|
||||
$msg = "Expected class '$class' to be an event service provider.";
|
||||
$this->assertTrue($reflection->isSubclassOf($provider), $msg);
|
||||
}
|
||||
|
||||
public function testListenerMapIsAnArray()
|
||||
{
|
||||
$map = $this->getListenerMap();
|
||||
$this->assertInternalType('array', $map);
|
||||
$this->assertGreaterThan(0, count($map));
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testListenerMapIsAnArray
|
||||
*/
|
||||
public function testListenerMapEventsExist()
|
||||
{
|
||||
$map = $this->getListenerMap();
|
||||
foreach (array_keys($map) as $event) {
|
||||
$this->assertTrue(class_exists($event));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testListenerMapIsAnArray
|
||||
*/
|
||||
public function testListenerMapKeysAreSorted()
|
||||
{
|
||||
$map = $this->getListenerMap();
|
||||
$events = array_keys($map);
|
||||
sort($events);
|
||||
$this->assertSame($events, array_keys($map));
|
||||
}
|
||||
|
||||
protected function getListenerMap()
|
||||
{
|
||||
$class = $this->getServiceProviderClass($this->app);
|
||||
$reflection = new ReflectionClass($class);
|
||||
$property = $reflection->getProperty('listen');
|
||||
$property->setAccessible(true);
|
||||
|
||||
return $property->getValue(new $class($this->app));
|
||||
}
|
||||
use EventServiceProviderTrait;
|
||||
}
|
||||
|
@ -11,17 +11,15 @@
|
||||
|
||||
namespace CachetHQ\Tests\Cachet\Providers;
|
||||
|
||||
use CachetHQ\Cachet\Providers\RepositoryServiceProvider;
|
||||
use AltThree\TestBench\ServiceProviderTrait;
|
||||
use CachetHQ\Tests\Cachet\AbstractTestCase;
|
||||
use GrahamCampbell\TestBenchCore\LaravelTrait;
|
||||
use GrahamCampbell\TestBenchCore\ServiceProviderTrait;
|
||||
|
||||
/**
|
||||
* This is the repository service provider test class.
|
||||
*
|
||||
* @author Graham Campbell <graham@alt-three.com>
|
||||
*/
|
||||
class RepositoryServiceProviderTest extends AbstractTestCase
|
||||
{
|
||||
use LaravelTrait, ServiceProviderTrait;
|
||||
|
||||
protected function getServiceProviderClass($app)
|
||||
{
|
||||
return RepositoryServiceProvider::class;
|
||||
}
|
||||
use ServiceProviderTrait;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user