Laravel 10 + Cachet Core

This commit is contained in:
James Brooks
2024-01-19 20:03:17 +00:00
parent 8b565ab7f0
commit cf674850dd
1271 changed files with 8105 additions and 123368 deletions

View File

@@ -1,87 +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 CachetHQ\Cachet\Models\User;
use CachetHQ\Cachet\Settings\Cache;
use CachetHQ\Cachet\Settings\Repository;
use Illuminate\Foundation\Testing\TestCase;
/**
* This is the abstract test case class.
*
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
abstract class AbstractTestCase extends TestCase
{
use CreatesApplicationTrait;
/**
* Test actor.
*
* @var \CachetHQ\Cachet\Models\User
*/
protected $user;
/**
* Sign in an user if it's the case.
*
* @param \CachetHQ\Cachet\Models\User|null $user
*
* @return \CachetHQ\Tests\Cachet\AbstractTestCase
*/
protected function signIn(User $user = null)
{
$this->user = $user ?: $this->createUser();
$this->be($this->user);
return $this;
}
/**
* Create and return a new user.
*
* @param array $properties
*
* @return \CachetHQ\Cachet\Models\User
*/
protected function createUser($properties = [])
{
return factory(User::class)->create($properties);
}
/**
* Set up the needed configuration to be able to run the tests.
*
* @return \CachetHQ\Tests\Cachet\AbstractTestCase
*/
protected function setupConfig()
{
$env = $this->app->environment();
$repo = $this->app->make(Repository::class);
$cache = $this->app->make(Cache::class);
$loaded = $cache->load($env);
if ($loaded === false) {
$loaded = $repo->all();
$cache->store($env, $loaded);
}
$settings = array_merge($this->app->config->get('setting'), $loaded);
$this->app->config->set('setting', $settings);
return $this;
}
}

View File

@@ -1,42 +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 GrahamCampbell\Analyzer\AnalysisTrait;
use PHPUnit\Framework\TestCase;
/**
* This is the analysis test class.
*
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
class AnalysisTest extends TestCase
{
use AnalysisTrait;
/**
* Get the code paths to analyze.
*
* @return string[]
*/
protected function getPaths()
{
return [
realpath(__DIR__.'/../app'),
realpath(__DIR__.'/../bootstrap'),
realpath(__DIR__.'/../config'),
realpath(__DIR__.'/../database'),
realpath(__DIR__),
];
}
}

View File

@@ -1,43 +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\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>
* @author James Brooks <james@alt-three.com>
*/
abstract class AbstractApiTestCase extends AbstractTestCase
{
use DatabaseMigrations;
/**
* Become a user.
*
* @return $this
*/
protected function beUser()
{
$this->user = factory(User::class)->create([
'username' => 'cachet-test',
]);
$this->be($this->user);
return $this;
}
}

View File

@@ -1,206 +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\Api;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasCreatedEvent;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasRemovedEvent;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasUpdatedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\ComponentGroup;
/**
* 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
{
const COMPONENT_GROUP_1_NAME = 'Component Group 1';
const COMPONENT_GROUP_2_NAME = 'Component Group 2';
public function test_can_get_all_component_groups()
{
$groups = factory(ComponentGroup::class, 2)
->create(['visible' => ComponentGroup::VISIBLE_GUEST]);
$response = $this->json('GET', '/api/v1/components/groups');
$response->assertStatus(200);
$response->assertJsonFragment([
[
'id' => $groups[0]->id,
'name' => $groups[0]->name,
'created_at' => (string) $groups[0]->created_at,
'updated_at' => (string) $groups[0]->updated_at,
'order' => $groups[0]->order,
'collapsed' => $groups[0]->collapsed,
'visible' => $groups[0]->visible,
'enabled_components' => $groups[0]->enabled_components,
'enabled_components_lowest' => $groups[0]->enabled_components_lowest,
'lowest_human_status' => $groups[0]->lowest_human_status,
],
]);
$response->assertJsonFragment([
[
'id' => $groups[1]->id,
'name' => $groups[1]->name,
'created_at' => (string) $groups[1]->created_at,
'updated_at' => (string) $groups[1]->updated_at,
'order' => $groups[1]->order,
'collapsed' => $groups[1]->collapsed,
'visible' => $groups[1]->visible,
'enabled_components' => $groups[1]->enabled_components,
'enabled_components_lowest' => $groups[1]->enabled_components_lowest,
'lowest_human_status' => $groups[1]->lowest_human_status,
],
]);
}
public function test_cannot_get_invalid_component_group()
{
$response = $this->json('GET', '/api/v1/components/groups/1');
$response->assertStatus(404);
}
public function test_cannot_create_component_group_without_authorization()
{
$this->doesntExpectEvents(ComponentGroupWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components/groups');
$response->assertStatus(401);
}
public function test_cannot_create_component_group_without_data()
{
$this->beUser();
$this->doesntExpectEvents(ComponentGroupWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components/groups');
$response->assertStatus(400);
}
public function test_can_create_new_component_group()
{
$this->beUser();
$this->expectsEvents(ComponentGroupWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components/groups', [
'name' => 'Foo',
'order' => 1,
'collapsed' => 1,
'visible' => ComponentGroup::VISIBLE_GUEST,
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'name' => 'Foo',
'order' => 1,
'collapsed' => 1,
'visible' => ComponentGroup::VISIBLE_GUEST,
]);
}
public function test_can_get_single_component_group()
{
$group = factory(ComponentGroup::class)->create();
$response = $this->json('GET', '/api/v1/components/groups/1');
$response->assertStatus(200);
$response->assertJsonFragment(['name' => $group->name]);
}
public function test_can_update_component_group()
{
$this->beUser();
$group = factory(ComponentGroup::class)->create();
$this->expectsEvents(ComponentGroupWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/components/groups/1', [
'name' => 'Lorem Ipsum Groupous',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Lorem Ipsum Groupous']);
}
public function test_can_delete_component_group()
{
$this->beUser();
$group = factory(ComponentGroup::class)->create();
$this->expectsEvents(ComponentGroupWasRemovedEvent::class);
$response = $this->json('DELETE', '/api/v1/components/groups/1');
$response->assertStatus(204);
}
public function test_only_public_component_groups_are_shown_for_a_guest()
{
$this->createComponentGroups();
$response = $this->json('GET', '/api/v1/components/groups');
$response->assertStatus(200);
$response->assertJsonFragment(['name' => self::COMPONENT_GROUP_1_NAME]);
}
public function test_all_component_groups_are_displayed_for_logged_in_users()
{
$this->createComponentGroups()
->signIn();
$response = $this->json('GET', '/api/v1/components/groups');
$response->assertStatus(200);
$response->assertJsonFragment(['name' => self::COMPONENT_GROUP_1_NAME]);
}
/**
* Set up the needed data for the tests.
*
* @return $this
*/
protected function createComponentGroups()
{
$this->createComponentGroup(self::COMPONENT_GROUP_1_NAME, ComponentGroup::VISIBLE_GUEST)
->createComponentGroup(self::COMPONENT_GROUP_2_NAME, ComponentGroup::VISIBLE_AUTHENTICATED);
return $this;
}
/**
* Create a component group.
*
* Also attaches a creator if any given as a parameter or exists in the test class.
*
* @param string $name
* @param string $visible
*
* @return $this
*/
protected function createComponentGroup($name, $visible)
{
factory(ComponentGroup::class)
->create(['name' => $name, 'visible' => $visible]);
return $this;
}
}

View File

@@ -1,320 +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\Api;
use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasChangedEvent;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasCreatedEvent;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasRemovedEvent;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Component;
/**
* This is the component test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class ComponentTest extends AbstractApiTestCase
{
public function test_can_get_all_components()
{
$components = factory(Component::class, 3)->create();
$response = $this->json('GET', '/api/v1/components');
$response->assertStatus(200);
$response->assertJsonFragment(['id' => $components[0]->id]);
$response->assertJsonFragment(['id' => $components[1]->id]);
$response->assertJsonFragment(['id' => $components[2]->id]);
}
public function test_can_get_all_components_with_tags()
{
$components = factory(Component::class, 2)->create();
$components[0]->attachTags(['Hello World']);
$components[1]->attachTags(['Foo', 'Bar']);
$response = $this->json('GET', '/api/v1/components', ['tags' => ['foo']]);
$response->assertStatus(200);
$response->assertJsonMissing(['id' => $components[0]->id]);
$response->assertJsonFragment(['id' => $components[1]->id]);
}
public function test_cannot_get_invalid_component()
{
$response = $this->json('GET', '/api/v1/components/1');
$response->assertStatus(404);
}
public function test_cannot_create_component_without_authorization()
{
$this->doesntExpectEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components');
$response->assertStatus(401);
}
public function test_cannot_create_component_without_data()
{
$this->beUser();
$this->doesntExpectEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components');
$response->assertStatus(400);
}
public function test_can_create_component()
{
$this->beUser();
$this->expectsEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components', [
'name' => 'Foo',
'description' => 'Bar',
'status' => 1,
'link' => 'http://example.com',
'order' => 1,
'group_id' => 1,
'enabled' => true,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo']);
}
public function test_can_create_minimal_component()
{
$this->beUser();
$this->expectsEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components', [
'name' => 'Foo',
'status' => 1,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo']);
}
public function test_can_create_component_with_tags()
{
$this->beUser();
$this->expectsEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components', [
'name' => 'Foo',
'description' => 'Bar',
'status' => 1,
'link' => 'http://example.com',
'order' => 1,
'group_id' => 1,
'enabled' => true,
'tags' => 'Foo,Bar',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'tags' => ['foo' => 'Foo', 'bar' => 'Bar']]);
}
public function test_can_create_component_without_enabled_field()
{
$this->beUser();
$this->expectsEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components', [
'name' => 'Foo',
'description' => 'Bar',
'status' => 1,
'link' => 'http://example.com',
'order' => 1,
'group_id' => 1,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'enabled' => true]);
}
public function test_can_create_component_with_meta_data()
{
$this->beUser();
$this->expectsEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components', [
'name' => 'Foo',
'description' => 'Bar',
'status' => 1,
'link' => 'http://example.com',
'order' => 1,
'group_id' => 1,
'enabled' => true,
'meta' => [
'uuid' => '172ff3fb-41f7-49d3-8bcd-f57b53627fa0',
],
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'name' => 'Foo',
'status' => 1,
'meta' => [
'uuid' => '172ff3fb-41f7-49d3-8bcd-f57b53627fa0',
],
]);
}
public function test_can_create_disabled_component()
{
$this->beUser();
$this->expectsEvents(ComponentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/components', [
'name' => 'Foo',
'description' => 'Bar',
'status' => 1,
'link' => 'http://example.com',
'order' => 1,
'group_id' => 1,
'enabled' => 0,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'enabled' => false]);
}
public function test_can_get_newly_created_component()
{
$component = factory(Component::class)->create();
$response = $this->json('GET', '/api/v1/components/1');
$response->assertStatus(200);
$response->assertJsonFragment(['name' => $component->name]);
}
public function test_can_update_component()
{
$this->beUser();
$component = factory(Component::class)->create();
$this->expectsEvents(ComponentWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/components/1', [
'name' => 'Foo',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'enabled' => $component->enabled]);
}
public function test_can_update_component_tags()
{
$this->beUser();
$component = factory(Component::class)->create();
$this->expectsEvents(ComponentWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/components/1', [
'name' => 'Foo',
'tags' => 'Hello',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'enabled' => $component->enabled, 'tags' => ['hello' => 'Hello']]);
}
public function test_can_update_component_without_status_change()
{
$this->beUser();
$component = factory(Component::class)->create();
$this->expectsEvents(ComponentWasUpdatedEvent::class);
$this->doesntExpectEvents(ComponentStatusWasChangedEvent::class);
$response = $this->json('PUT', '/api/v1/components/1', [
'name' => 'Foo',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'enabled' => $component->enabled]);
}
public function test_can_update_component_with_status_change()
{
$this->beUser();
$component = factory(Component::class)->create([
'status' => 1,
]);
$this->expectsEvents([
ComponentWasUpdatedEvent::class,
ComponentStatusWasChangedEvent::class,
]);
$response = $this->json('PUT', '/api/v1/components/1', [
'name' => 'Foo',
'status' => 2,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'status' => 2, 'enabled' => $component->enabled]);
}
public function test_can_update_component_with_meta_data()
{
$this->beUser();
$component = factory(Component::class)->create([
'meta' => [
'uuid' => '172ff3fb-41f7-49d3-8bcd-f57b53627fa0',
],
]);
$this->expectsEvents(ComponentWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/components/1', [
'meta' => [
'uuid' => '172ff3fb-41f7-49d3-8bcd-f57b53627fa0',
'foo' => 'bar',
],
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'meta' => [
'uuid' => '172ff3fb-41f7-49d3-8bcd-f57b53627fa0',
'foo' => 'bar',
],
'enabled' => $component->enabled,
]);
}
public function test_can_delete_component()
{
$this->beUser();
$component = factory(Component::class)->create();
$this->expectsEvents(ComponentWasRemovedEvent::class);
$response = $this->json('DELETE', '/api/v1/components/1');
$response->assertStatus(204);
}
}

View File

@@ -1,79 +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\Api;
use CachetHQ\Cachet\Models\Component;
/**
* 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 test_can_ping()
{
$response = $this->json('GET', '/api/v1/ping');
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonFragment(['data' => 'Pong!']);
}
public function test_see_error_page_for_unknown_endpoint()
{
$response = $this->json('GET', '/api/v1/not-found');
$response->assertStatus(404);
$response->assertHeader('Content-Type', 'application/json');
}
public function test_non_acceptable_content_type()
{
$response = $this->json('GET', '/api/v1/ping', [], ['HTTP_Accept' => 'text/html']);
$response->assertStatus(406);
}
public function test_can_get_system_status()
{
$response = $this->json('GET', '/api/v1/status');
$response->assertStatus(200)
->assertHeader('Cache-Control')
->assertJsonFragment([
'data' => [
'status' => 'success',
'message' => 'System operational',
],
]);
}
public function test_can_get_system_status_not_success()
{
factory(Component::class)->create([
'status' => 3,
]);
$response = $this->json('GET', '/api/v1/status');
$response->assertStatus(200)
->assertHeader('Cache-Control')
->assertJsonFragment([
'data' => [
'status' => 'info',
'message' => 'The system is experiencing issues',
],
]);
}
}

View File

@@ -1,41 +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\Api;
use CachetHQ\Cachet\Models\IncidentTemplate;
/**
* This is the incident template test class.
*
* @author Marc Hagen <hello@marchagen.nl>
*/
class IncidentTemplateTest extends AbstractApiTestCase
{
public function test_can_get_all_incident_templates()
{
$templates = factory(IncidentTemplate::class, 3)->create();
$response = $this->json('GET', '/api/v1/incidents/templates');
$response->assertJsonFragment(['id' => $templates[0]->id]);
$response->assertJsonFragment(['id' => $templates[1]->id]);
$response->assertJsonFragment(['id' => $templates[2]->id]);
$response->assertStatus(200);
}
public function test_cannot_get_invalid_incident_template()
{
$response = $this->json('GET', '/api/v1/incidents/templates/1');
$response->assertStatus(404);
}
}

View File

@@ -1,233 +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\Api;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentTemplate;
/**
* This is the incident test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class IncidentTest extends AbstractApiTestCase
{
public function test_can_get_all_incidents()
{
$incidents = factory(Incident::class, 3)->create();
$response = $this->json('GET', '/api/v1/incidents');
$response->assertStatus(200);
$response->assertJsonFragment(['id' => $incidents[0]->id]);
$response->assertJsonFragment(['id' => $incidents[1]->id]);
$response->assertJsonFragment(['id' => $incidents[2]->id]);
}
public function test_cannot_get_invalid_component()
{
$response = $this->json('GET', '/api/v1/incidents/0');
$response->assertStatus(404);
}
public function test_cannot_create_incident_without_authorization()
{
$this->doesntExpectEvents(IncidentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/incidents');
$response->assertStatus(401);
}
public function test_cannot_create_incident_with_missing_data()
{
$this->beUser();
$this->doesntExpectEvents(IncidentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/incidents');
$response->assertStatus(400);
}
public function test_can_create_incident()
{
$this->beUser();
$this->expectsEvents(IncidentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/incidents', [
'name' => 'Foo',
'message' => 'Lorem ipsum dolor sit amet',
'status' => 1,
'visible' => 1,
'stickied' => false,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo']);
}
public function test_can_create_incident_with_component_status()
{
$component = factory(Component::class)->create();
$this->beUser();
$this->expectsEvents(IncidentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/incidents', [
'name' => 'Foo',
'message' => 'Lorem ipsum dolor sit amet',
'status' => 1,
'component_id' => $component->id,
'component_status' => 1,
'visible' => 1,
'stickied' => false,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo']);
}
public function test_can_create_incident_with_template()
{
$template = factory(IncidentTemplate::class)->create();
$this->beUser();
$this->expectsEvents(IncidentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/incidents', [
'name' => 'Foo',
'status' => 1,
'visible' => 1,
'stickied' => false,
'template' => $template->slug,
'vars' => [
'name' => 'Foo',
'message' => 'Hello there this is a foo!',
],
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'name' => 'Foo',
'message' => "Name: Foo,\nMessage: Hello there this is a foo!",
]);
}
public function test_can_get_newly_created_incident()
{
$incident = factory(Incident::class)->create();
$response = $this->json('GET', '/api/v1/incidents/1');
$response->assertStatus(200);
$response->assertJsonFragment(['name' => $incident->name]);
}
public function test_can_update_incident()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$this->expectsEvents(IncidentWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/incidents/1', [
'name' => 'Foo',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo']);
}
public function test_can_update_incident_with_template()
{
$this->beUser();
$template = factory(IncidentTemplate::class)->create([
'template' => 'Hello there this is a foo in my {{ incident.name }}!',
]);
$incident = factory(Incident::class)->create();
$this->expectsEvents(IncidentWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/incidents/1', [
'name' => 'Foo',
'template' => $template->slug,
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'name' => 'Foo',
'message' => 'Hello there this is a foo in my Foo!',
]);
}
public function test_can_update_incident_when_no_user_is_associated()
{
$incident = factory(Incident::class)->create(['user_id' => null]);
$this->beUser();
$this->expectsEvents(IncidentWasUpdatedEvent::class);
$response = $this->json('PUT', '/api/v1/incidents/1', [
'name' => 'Updated incident name',
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'name' => 'Updated incident name',
'user_id' => null,
]);
}
public function test_can_delete_incident()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$this->expectsEvents(IncidentWasRemovedEvent::class);
$response = $this->json('DELETE', '/api/v1/incidents/1');
$response->assertStatus(204);
}
public function test_can_create_incident_with_meta_data()
{
$this->beUser();
$this->expectsEvents(IncidentWasCreatedEvent::class);
$response = $this->json('POST', '/api/v1/incidents', [
'name' => 'Foo',
'message' => 'Lorem ipsum dolor sit amet',
'status' => 1,
'meta' => [
'id' => 123456789,
],
]);
$response->assertStatus(200);
$response->assertJsonFragment([
'meta' => [
'id' => 123456789,
],
]);
}
}

View File

@@ -1,104 +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\Api;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\IncidentUpdate;
/**
* This is the incident update test class.
*
* @author James Brooks <james@alt-three.com>
*/
class IncidentUpdateTest extends AbstractApiTestCase
{
public function test_can_get_all_incident_updates()
{
$incident = factory(Incident::class)->create();
$updates = factory(IncidentUpdate::class, 3)->create([
'incident_id' => $incident->id,
]);
$response = $this->json('GET', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(200);
$response->assertJsonFragment(['id' => $updates[0]->id]);
$response->assertJsonFragment(['id' => $updates[1]->id]);
$response->assertJsonFragment(['id' => $updates[2]->id]);
}
public function test_cannot_get_invalid_incident_update()
{
$response = $this->json('GET', '/api/v1/incidents/1/updates/1');
$response->assertStatus(404);
}
public function test_cannot_create_incident_update_without_authorization()
{
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(401);
}
public function test_cannot_create_incident_update_without_data()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates");
$response->assertStatus(400);
}
public function test_can_create_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$response = $this->json('POST', "/api/v1/incidents/{$incident->id}/updates", [
'status' => 4,
'message' => 'Incident fixed!',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['incident_id' => $incident->id]);
}
public function test_can_update_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$update = factory(IncidentUpdate::class)->create();
$response = $this->json('PUT', "/api/v1/incidents/{$incident->id}/updates/{$update->id}", [
'message' => 'Message updated :smile:',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['message' => 'Message updated :smile:']);
}
public function test_can_delete_incident_update()
{
$this->beUser();
$incident = factory(Incident::class)->create();
$update = factory(IncidentUpdate::class)->create();
$response = $this->json('DELETE', "/api/v1/incidents/{$incident->id}/updates/{$update->id}");
$response->assertStatus(204);
}
}

View File

@@ -1,182 +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\Api;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
use Carbon\Carbon;
/**
* 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
{
public function test_can_get_all_metric_points()
{
$metric = factory(Metric::class)->create();
$metricPoint = factory(MetricPoint::class, 3)->create([
'metric_id' => $metric->id,
]);
$response = $this->json('GET', "/api/v1/metrics/{$metric->id}/points");
$response->assertJsonFragment(['id' => $metricPoint[0]->id]);
$response->assertJsonFragment(['id' => $metricPoint[1]->id]);
$response->assertJsonFragment(['id' => $metricPoint[2]->id]);
$response->assertStatus(200);
}
public function test_can_get_all_metric_points_in_order_by_latests()
{
$metric = factory(Metric::class)->create();
$metricPoint1 = factory(MetricPoint::class)->create([
'metric_id' => $metric->id,
'created_at' => Carbon::parse('2016-12-01 2:00pm'),
'updated_at' => Carbon::parse('2016-12-01 2:00pm'),
]);
$metricPoint2 = factory(MetricPoint::class)->create([
'metric_id' => $metric->id,
'created_at' => Carbon::parse('2016-12-01 1:00pm'),
'updated_at' => Carbon::parse('2016-12-01 1:00pm'),
]);
$metricPoint3 = factory(MetricPoint::class)->create([
'metric_id' => $metric->id,
'created_at' => Carbon::parse('2016-12-01 4:00pm'),
'updated_at' => Carbon::parse('2016-12-01 4:00pm'),
]);
$response = $this->json('GET', "/api/v1/metrics/{$metric->id}/points");
$response->assertJson([
'data' => [
['id' => $metricPoint3->id],
['id' => $metricPoint1->id],
['id' => $metricPoint2->id],
],
]);
$response->assertStatus(200);
}
public function test_cannot_create_metric_point_without_authorization()
{
$metric = factory(Metric::class)->create();
$metricPoint = factory(MetricPoint::class)->create([
'metric_id' => $metric->id,
]);
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points");
$response->assertStatus(401);
}
public function test_can_create_metric_point()
{
$this->beUser();
$metric = factory(Metric::class)->create();
$metricPoint = factory(MetricPoint::class)->make([
'metric_id' => $metric->id,
]);
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points", $metricPoint->toArray());
$response->assertStatus(200);
$response->assertJsonFragment(['value' => $metricPoint->value]);
}
public function test_can_create_metric_point_with_timestamp()
{
$this->beUser();
// prevent tests breaking due to rolling into the next second
Carbon::setTestNow(Carbon::now());
$metric = factory(Metric::class)->create();
$createdAt = Carbon::now();
$metricPoint = factory(MetricPoint::class)->make([
'metric_id' => $metric->id,
]);
$postData = $metricPoint->toArray();
$postData['timestamp'] = $createdAt->timestamp;
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points", $postData);
// Round value to match ours
$timestamp = 30 * round($createdAt->timestamp / 30);
$response->assertStatus(200);
$response->assertJsonFragment([
'value' => $metricPoint->value,
'created_at' => Carbon::createFromFormat('U', $timestamp)->setTimezone(config('cachet.timezone'))->toDateTimeString(),
]);
}
public function test_can_create_metric_point_with_timestamp_timezone()
{
$this->beUser();
// prevent tests breaking due to rolling into the next second
Carbon::setTestNow(Carbon::now());
$timezone = 'America/Mexico_City';
$metric = factory(Metric::class)->create();
$createdAt = Carbon::now()->timezone($timezone);
$metricPoint = factory(MetricPoint::class)->make([
'metric_id' => $metric->id,
]);
$postData = $metricPoint->toArray();
$postData['timestamp'] = $createdAt->timestamp;
$response = $this->json('POST', "/api/v1/metrics/{$metric->id}/points", $postData, ['Time-Zone' => $timezone]);
// Round value to match ours
$timestamp = 30 * round($createdAt->timestamp / 30);
$response->assertStatus(200);
$response->assertJsonFragment([
'value' => $metricPoint->value,
'created_at' => Carbon::createFromFormat('U', $timestamp)->setTimezone($timezone)->toDateTimeString(),
]);
}
public function test_can_update_metric_point()
{
$this->beUser();
$metric = factory(Metric::class)->create();
$metricPoint = factory(MetricPoint::class)->create([
'metric_id' => $metric->id,
]);
$response = $this->json('PUT', "/api/v1/metrics/{$metric->id}/points/{$metricPoint->id}", [
'value' => 999,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['value' => 999]);
}
public function test_can_delete_metric_point()
{
$this->beUser();
$metric = factory(Metric::class)->create();
$metricPoint = factory(MetricPoint::class)->create([
'metric_id' => $metric->id,
]);
$response = $this->json('DELETE', "/api/v1/metrics/{$metric->id}/points/{$metricPoint->id}");
$response->assertStatus(204);
}
}

View File

@@ -1,109 +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\Api;
use CachetHQ\Cachet\Models\Metric;
/**
* This is the metric test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class MetricTest extends AbstractApiTestCase
{
public function test_can_get_all_metrics()
{
$metrics = factory(Metric::class, 3)->create();
$response = $this->json('GET', '/api/v1/metrics');
$response->assertJsonFragment(['id' => $metrics[0]->id]);
$response->assertJsonFragment(['id' => $metrics[1]->id]);
$response->assertJsonFragment(['id' => $metrics[2]->id]);
$response->assertStatus(200);
}
public function test_cannot_get_invalid_metric()
{
$response = $this->json('GET', '/api/v1/metrics/0');
$response->assertStatus(404);
}
public function test_cannot_create_metric_without_authorization()
{
$response = $this->json('POST', '/api/v1/metrics');
$response->assertStatus(401);
}
public function test_cannot_create_metric_without_data()
{
$this->beUser();
$response = $this->json('POST', '/api/v1/metrics');
$response->assertStatus(400);
}
public function test_can_create_metric()
{
$this->beUser();
$response = $this->json('POST', '/api/v1/metrics', [
'name' => 'Foo',
'suffix' => 'foo\'s per second',
'description' => 'Lorem ipsum dolor',
'default_value' => 1,
'display_chart' => 1,
'places' => 0,
'view' => 0,
'threshold' => 5,
'order' => 1,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo']);
}
public function test_can_get_newly_created_metric()
{
$incident = factory(Metric::class)->create();
$response = $this->json('GET', '/api/v1/metrics/1');
$response->assertStatus(200);
$response->assertJsonFragment(['name' => $incident->name]);
}
public function test_can_update_metric()
{
$this->beUser();
$metric = factory(Metric::class)->create();
$response = $this->json('PUT', '/api/v1/metrics/1', [
'name' => 'Foo',
'view' => 2,
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Foo', 'default_view' => 2]);
}
public function test_can_delete_metric()
{
$this->beUser();
$metric = factory(Metric::class)->create();
$response = $this->json('DELETE', '/api/v1/metrics/1');
$response->assertStatus(204);
}
}

View File

@@ -1,88 +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\Api;
use CachetHQ\Cachet\Models\Schedule;
use Illuminate\Support\Arr;
/**
* This is the schedule test class.
*
* @author James Brooks <james@alt-three.com>
*/
class ScheduleTest extends AbstractApiTestCase
{
public function test_can_get_all_schedules()
{
$schedules = factory(Schedule::class, 3)->create();
$response = $this->json('GET', '/api/v1/schedules');
$response->assertStatus(200);
$response->assertJsonFragment(['id' => $schedules[0]->id]);
$response->assertJsonFragment(['id' => $schedules[1]->id]);
$response->assertJsonFragment(['id' => $schedules[2]->id]);
}
public function test_can_get_single_schedule()
{
$schedule = factory(Schedule::class)->create();
$response = $this->json('GET', '/api/v1/schedules/'.$schedule->id);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => $schedule->name]);
}
public function test_can_create_schedule()
{
$this->beUser();
$schedule = [
'name' => 'Test Schedule',
'message' => 'Foo bar, baz.',
'status' => 1,
'scheduled_at' => date('Y-m-d H:i'),
];
$response = $this->json('POST', '/api/v1/schedules/', $schedule);
Arr::forget($schedule, 'scheduled_at');
$response->assertStatus(200);
$response->assertJsonFragment($schedule);
}
public function test_can_update_schedule()
{
$this->beUser();
$schedule = factory(Schedule::class)->create();
$response = $this->json('PUT', '/api/v1/schedules/'.$schedule->id, [
'name' => 'Updated schedule',
]);
$response->assertStatus(200);
$response->assertJsonFragment(['name' => 'Updated schedule']);
}
public function test_can_delete_schedule()
{
$this->beUser();
factory(Schedule::class)->create();
$response = $this->json('DELETE', '/api/v1/schedules/1');
$response->assertStatus(204);
}
}

View File

@@ -1,128 +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\Api;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasSubscribedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Cachet\Models\Subscription;
use Illuminate\Support\Facades\Notification;
/**
* This is the subscriber test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class SubscriberTest extends AbstractApiTestCase
{
public function test_can_get_all_subscribers()
{
$this->beUser();
$subscriber = factory(Subscriber::class)->create();
$response = $this->json('GET', '/api/v1/subscribers');
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/json');
}
public function test_cannot_get_subscribers_without_authorization()
{
$response = $this->json('GET', '/api/v1/subscribers');
$response->assertStatus(401);
$response->assertHeader('Content-Type', 'application/json');
}
public function test_can_create_subscriber()
{
$this->beUser();
Notification::fake();
$this->expectsEvents(SubscriberHasSubscribedEvent::class);
$response = $this->json('POST', '/api/v1/subscribers', [
'email' => 'support@alt-three.com',
]);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonFragment(['email' => 'support@alt-three.com']);
}
public function test_can_create_subscriber_automatically_verified()
{
$this->beUser();
Notification::fake();
$this->expectsEvents(SubscriberHasSubscribedEvent::class);
$response = $this->json('POST', '/api/v1/subscribers', [
'email' => 'support@alt-three.com',
'verify' => true,
]);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonFragment(['email' => 'support@alt-three.com']);
}
public function test_can_create_subscriber_with_subscription()
{
$this->beUser();
factory(Component::class, 3)->create();
$response = $this->json('POST', '/api/v1/subscribers', [
'email' => 'support@alt-three.com',
'verify' => true,
'components' => [
1,
3,
],
]);
$response->assertStatus(200);
$response->assertHeader('Content-Type', 'application/json');
$response->assertJsonFragment(['email' => 'support@alt-three.com']);
$data = $response->decodeResponseJson();
$this->assertCount(2, $data['data']['subscriptions']);
$this->assertEquals(1, $data['data']['subscriptions'][0]['component_id']);
$this->assertEquals(3, $data['data']['subscriptions'][1]['component_id']);
}
public function test_can_delete_subscriber()
{
$this->beUser();
$subscriber = factory(Subscriber::class)->create();
$response = $this->json('DELETE', "/api/v1/subscribers/{$subscriber->id}");
$response->assertStatus(204);
}
public function test_can_delete_subscription()
{
$this->beUser();
$subscription = factory(Subscription::class)->create();
$response = $this->json('DELETE', "/api/v1/subscriptions/{$subscription->id}");
$response->assertStatus(204);
}
}

View File

@@ -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\Bus\Commands;
use AltThree\TestBench\ExistenceTrait;
use PHPUnit\Framework\TestCase;
/**
* This is the command existence test class.
*
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <james@alt-three.com>
*/
class CommandExistenceTest extends TestCase
{
use ExistenceTrait;
protected function getSourcePath()
{
return realpath(__DIR__.'/../../../app/Bus/Commands');
}
}

View File

@@ -1,66 +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\Bus\Commands\Component;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Component\CreateComponentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Component\CreateComponentCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create component command test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class CreateComponentCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'description' => 'Foo',
'status' => 1,
'link' => 'https://cachethq.io',
'order' => 0,
'group_id' => 0,
'enabled' => true,
'meta' => null,
'tags' => 'Foo, Bar',
];
$object = new CreateComponentCommand(
$params['name'],
$params['description'],
$params['status'],
$params['link'],
$params['order'],
$params['group_id'],
$params['enabled'],
$params['meta'],
$params['tags']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateComponentCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\Component;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Component\RemoveComponentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Component\RemoveComponentCommandHandler;
use CachetHQ\Cachet\Models\Component;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['component' => new Component()];
$object = new RemoveComponentCommand($params['component']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveComponentCommandHandler::class;
}
}

View File

@@ -1,72 +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\Bus\Commands\Component;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Component\UpdateComponentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Component\UpdateComponentCommandHandler;
use CachetHQ\Cachet\Models\Component;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'component' => new Component(),
'name' => 'Test',
'description' => 'Foo',
'status' => 1,
'link' => 'https://cachethq.io',
'order' => 0,
'group_id' => 0,
'enabled' => true,
'meta' => null,
'tags' => null,
'silent' => false,
];
$object = new UpdateComponentCommand(
$params['component'],
$params['name'],
$params['description'],
$params['status'],
$params['link'],
$params['order'],
$params['group_id'],
$params['enabled'],
$params['meta'],
$params['tags'],
$params['silent']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateComponentCommandHandler::class;
}
}

View File

@@ -1,58 +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\Bus\Commands\ComponentGroup;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\CreateComponentGroupCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup\CreateComponentGroupCommandHandler;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create component group command test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class CreateComponentGroupCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'order' => 0,
'collapsed' => 1,
'visible' => ComponentGroup::VISIBLE_AUTHENTICATED,
];
$object = new CreateComponentGroupCommand(
$params['name'],
$params['order'],
$params['collapsed'],
$params['visible']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateComponentGroupCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\ComponentGroup;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\RemoveComponentGroupCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup\RemoveComponentGroupCommandHandler;
use CachetHQ\Cachet\Models\ComponentGroup;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['group' => new ComponentGroup()];
$object = new RemoveComponentGroupCommand($params['group']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveComponentGroupCommandHandler::class;
}
}

View File

@@ -1,59 +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\Bus\Commands\ComponentGroup;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\ComponentGroup\UpdateComponentGroupCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\ComponentGroup\UpdateComponentGroupCommandHandler;
use CachetHQ\Cachet\Models\ComponentGroup;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'group' => new ComponentGroup(),
'name' => 'Foo',
'order' => 1,
'collapsed' => 2,
'visible' => ComponentGroup::VISIBLE_AUTHENTICATED,
];
$object = new UpdateComponentGroupCommand(
$params['group'],
$params['name'],
$params['order'],
$params['collapsed'],
$params['visible']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateComponentGroupCommandHandler::class;
}
}

View File

@@ -1,73 +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\Bus\Commands\Incident;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Incident\CreateIncidentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\CreateIncidentCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create incident command test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class CreateIncidentCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'status' => 1,
'message' => 'Foo bar baz',
'visible' => 1,
'component_id' => 1,
'component_status' => 1,
'notify' => false,
'stickied' => false,
'occurred_at' => null,
'template' => null,
'template_vars' => [],
'meta' => [],
];
$object = new CreateIncidentCommand(
$params['name'],
$params['status'],
$params['message'],
$params['visible'],
$params['component_id'],
$params['component_status'],
$params['notify'],
$params['stickied'],
$params['occurred_at'],
$params['template'],
$params['template_vars'],
$params['meta']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateIncidentCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\Incident;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Incident\RemoveIncidentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\RemoveIncidentCommandHandler;
use CachetHQ\Cachet\Models\Incident;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['incident' => new Incident()];
$object = new RemoveIncidentCommand($params['incident']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveIncidentCommandHandler::class;
}
}

View File

@@ -1,74 +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\Bus\Commands\Incident;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Incident\UpdateIncidentCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Incident\UpdateIncidentCommandHandler;
use CachetHQ\Cachet\Models\Incident;
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 AbstractTestCase
{
use CommandTrait;
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,
'stickied' => false,
'occurred_at' => null,
'template' => null,
'template_vars' => [],
];
$object = new UpdateIncidentCommand(
$params['incident'],
$params['name'],
$params['status'],
$params['message'],
$params['visible'],
$params['component_id'],
$params['component_status'],
$params['notify'],
$params['stickied'],
$params['occurred_at'],
$params['template'],
$params['template_vars']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateIncidentCommandHandler::class;
}
}

View File

@@ -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\Bus\Events\IncidentUpdate;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the abstract incident update event test case class.
*
* @author James Brooks <james@alt-three.com>
*/
abstract class AbstractIncidentUpdateCommandTest extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [IncidentUpdateEventInterface::class];
}
}

View File

@@ -1,52 +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\Bus\Commands\IncidentUpdate;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\CreateIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\CreateIncidentUpdateCommandHandler;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create incident update command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class CreateIncidentUpdateCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'incident' => new Incident(),
'status' => 1,
'message' => 'Foo',
'user' => new User(),
];
$object = new CreateIncidentUpdateCommand($params['incident'], $params['status'], $params['message'], null, null, $params['user']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateIncidentUpdateCommandHandler::class;
}
}

View File

@@ -1,41 +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\Bus\Commands\IncidentUpdate;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\RemoveIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\RemoveIncidentUpdateCommandHandler;
use CachetHQ\Cachet\Models\IncidentUpdate;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the remove incident update command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class RemoveIncidentUpdateCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['incidentUpdate' => new IncidentUpdate()];
$object = new RemoveIncidentUpdateCommand($params['incidentUpdate']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveIncidentUpdateCommandHandler::class;
}
}

View File

@@ -1,52 +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\Bus\Commands\IncidentUpdate;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\IncidentUpdate\UpdateIncidentUpdateCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\IncidentUpdate\UpdateIncidentUpdateCommandHandler;
use CachetHQ\Cachet\Models\IncidentUpdate;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the update incident update command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateIncidentUpdateCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['update' => new IncidentUpdate(), 'status' => 1, 'message' => 'Updating!', 'user' => new User()];
$object = new UpdateIncidentUpdateCommand(
$params['update'],
$params['status'],
$params['message'],
$params['user']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateIncidentUpdateCommandHandler::class;
}
}

View File

@@ -1,41 +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\Bus\Commands\Invite;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Invite\ClaimInviteCommand;
use CachetHQ\Cachet\Bus\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

@@ -1,71 +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\Bus\Commands\Metric;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Metric\CreateMetricCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create metric command test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class CreateMetricCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'name' => 'Coffee',
'suffix' => 'cups',
'description' => 'Cups of coffee consumed',
'default_value' => 0,
'calc_type' => 0,
'display_chart' => 1,
'places' => 0,
'default_view' => 0,
'threshold' => 0,
'order' => 0,
'visible' => 1,
];
$object = new CreateMetricCommand(
$params['name'],
$params['suffix'],
$params['description'],
$params['default_value'],
$params['calc_type'],
$params['display_chart'],
$params['places'],
$params['default_view'],
$params['threshold'],
$params['order'],
$params['visible']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateMetricCommandHandler::class;
}
}

View File

@@ -1,47 +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\Bus\Commands\Metric;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Metric\CreateMetricPointCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Metric\CreateMetricPointCommandHandler;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create metric point command test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class CreateMetricPointCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['metric' => new Metric(), 'value' => 1, 'created_at' => '2020-12-30 12:00:00'];
$object = new CreateMetricPointCommand($params['metric'], $params['value'], $params['created_at']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateMetricPointCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\Metric;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Metric\RemoveMetricCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Metric\RemoveMetricCommandHandler;
use CachetHQ\Cachet\Models\Metric;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['metric' => new Metric()];
$object = new RemoveMetricCommand($params['metric']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveMetricCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\Metric;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Metric\RemoveMetricPointCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Metric\RemoveMetricPointCommandHandler;
use CachetHQ\Cachet\Models\MetricPoint;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['metricPoint' => new MetricPoint()];
$object = new RemoveMetricPointCommand($params['metricPoint']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveMetricPointCommandHandler::class;
}
}

View File

@@ -1,74 +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\Bus\Commands\Metric;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Metric\UpdateMetricCommandHandler;
use CachetHQ\Cachet\Models\Metric;
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 AbstractTestCase
{
use CommandTrait;
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,
'default_view' => 0,
'threshold' => 0,
'order' => 0,
'visible' => 1,
];
$object = new UpdateMetricCommand(
$params['metric'],
$params['name'],
$params['suffix'],
$params['description'],
$params['default_value'],
$params['calc_type'],
$params['display_chart'],
$params['places'],
$params['default_view'],
$params['threshold'],
$params['order'],
$params['visible']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateMetricCommandHandler::class;
}
}

View File

@@ -1,59 +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\Bus\Commands\Metric;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Metric\UpdateMetricPointCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Metric\UpdateMetricPointCommandHandler;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\MetricPoint;
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 AbstractTestCase
{
use CommandTrait;
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

@@ -1,61 +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\Bus\Commands\Schedule;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Schedule\CreateScheduleCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Schedule\CreateScheduleCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create schedule command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class CreateScheduleCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'name' => 'Test',
'message' => 'Foo',
'status' => 1,
'scheduled_at' => date('Y-m-d H:i'),
'completed_at' => date('Y-m-d H:i'),
'components' => [],
'notify' => 1,
];
$object = new CreateScheduleCommand(
$params['name'],
$params['message'],
$params['status'],
$params['scheduled_at'],
$params['completed_at'],
$params['components'],
$params['notify']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateScheduleCommandHandler::class;
}
}

View File

@@ -1,50 +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\Bus\Commands\Schedule;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Schedule\DeleteScheduleCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Schedule\DeleteScheduleCommandHandler;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create schedule command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class DeleteScheduleCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'schedule' => new Schedule(),
];
$object = new DeleteScheduleCommand(
$params['schedule']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return DeleteScheduleCommandHandler::class;
}
}

View File

@@ -1,62 +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\Bus\Commands\Schedule;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Schedule\UpdateScheduleCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Schedule\UpdateScheduleCommandHandler;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create schedule command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateScheduleCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'schedule' => new Schedule(),
'name' => 'Foo',
'message' => 'Bar',
'status' => 1,
'scheduled_at' => date('Y-m-d H:i'),
'completed_at' => date('Y-m-d H:i'),
'components' => [],
];
$object = new UpdateScheduleCommand(
$params['schedule'],
$params['name'],
$params['message'],
$params['status'],
$params['scheduled_at'],
$params['completed_at'],
$params['components']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return UpdateScheduleCommandHandler::class;
}
}

View File

@@ -1,46 +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\Bus\Commands\Subscriber;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Subscriber\SubscribeSubscriberCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber\SubscribeSubscriberCommandHandler;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['email' => 'support@cachethq.io', 'verified' => true, 'subscriptions' => null];
$object = new SubscribeSubscriberCommand($params['email'], $params['verified'], $params['subscriptions']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return SubscribeSubscriberCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\Subscriber;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriberCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber\UnsubscribeSubscriberCommandHandler;
use CachetHQ\Cachet\Models\Subscriber;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new UnsubscribeSubscriberCommand($params['subscriber']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return UnsubscribeSubscriberCommandHandler::class;
}
}

View File

@@ -1,41 +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\Bus\Commands\Subscriber;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UnsubscribeSubscriptionCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber\UnsubscribeSubscriptionCommandHandler;
use CachetHQ\Cachet\Models\Subscription;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the unsubscribe subscriber command test class.
*
* @author Joseph Cohen <joe@alt-three.com>
*/
class UnsubscribeSubscriptionCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['subscription' => new Subscription()];
$object = new UnsubscribeSubscriptionCommand($params['subscription']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return UnsubscribeSubscriptionCommandHandler::class;
}
}

View File

@@ -1,41 +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\Bus\Commands\Subscriber;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Subscriber\UpdateSubscriberSubscriptionCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber\UpdateSubscriberSubscriptionCommandHandler;
use CachetHQ\Cachet\Models\Subscriber;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the update subscriber subscription command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateSubscriberSubscriptionCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber(), 'subscriptions' => null];
$object = new UpdateSubscriberSubscriptionCommand($params['subscriber'], $params['subscriptions']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return UpdateSubscriberSubscriptionCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\Subscriber;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\Subscriber\VerifySubscriberCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\Subscriber\VerifySubscriberCommandHandler;
use CachetHQ\Cachet\Models\Subscriber;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new VerifySubscriberCommand($params['subscriber']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return VerifySubscriberCommandHandler::class;
}
}

View File

@@ -1,49 +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\Bus\Commands\System\Config;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\System\Config\UpdateConfigCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\System\Config\UpdateConfigCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the update config command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UpdateConfigCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'values' => [
'FOO' => 'bar',
],
];
$object = new UpdateConfigCommand($params['values']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return UpdateConfigCommandHandler::class;
}
}

View File

@@ -1,57 +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\Bus\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\User\CreateUserCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\User\CreateUserCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the create user command test class.
*
* @author James Brooks <james@alt-three.com>
* @author Graham Campbell <graham@alt-three.com>
*/
class CreateUserCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = [
'username' => 'Test',
'password' => 'fooey',
'email' => 'test@example.com',
'level' => 1,
];
$object = new CreateUserCommand(
$params['username'],
$params['password'],
$params['email'],
$params['level']
);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return CreateUserCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\User\GenerateApiTokenCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\User\GenerateApiTokenCommandHandler;
use CachetHQ\Cachet\Models\User;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new GenerateApiTokenCommand($params['user']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return GenerateApiTokenCommandHandler::class;
}
}

View File

@@ -1,46 +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\Bus\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\User\InviteUserCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\User\InviteUserCommandHandler;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the invite user command test class.
*
* @author Graham Campbell <graham@alt-three.com>
* @author James Brooks <graham@alt-three.com>
*/
class InviteUserCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['emails' => ['foo@example.com']];
$object = new InviteUserCommand($params['emails']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return true;
}
protected function getHandlerClass()
{
return InviteUserCommandHandler::class;
}
}

View File

@@ -1,42 +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\Bus\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\User\RemoveUserCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\User\RemoveUserCommandHandler;
use CachetHQ\Cachet\Models\User;
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 AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new RemoveUserCommand($params['user']);
return compact('params', 'object');
}
protected function getHandlerClass()
{
return RemoveUserCommandHandler::class;
}
}

View File

@@ -1,56 +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\Bus\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\User\SignupUserCommand;
use CachetHQ\Cachet\Bus\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@example.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;
}
}

View File

@@ -1,47 +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\Bus\Commands\User;
use AltThree\TestBench\CommandTrait;
use CachetHQ\Cachet\Bus\Commands\User\WelcomeUserCommand;
use CachetHQ\Cachet\Bus\Handlers\Commands\User\WelcomeUserCommandHandler;
use CachetHQ\Cachet\Models\User;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the welcome user command test class.
*
* @author James Brooks <james@alt-three.com>
*/
class WelcomeUserCommandTest extends AbstractTestCase
{
use CommandTrait;
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new WelcomeUserCommand($params['user']);
return compact('params', 'object');
}
protected function objectHasRules()
{
return false;
}
protected function getHandlerClass()
{
return WelcomeUserCommandHandler::class;
}
}

View File

@@ -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\Bus\Events\Beacon;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the abstract beacon event test case.
*
* @author James Brooks <james@alt-three.com>
*/
abstract class AbstractBeaconEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [BeaconEventInterface::class];
}
}

View File

@@ -1,35 +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\Bus\Events\Beacon;
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconFailedToSendEvent;
/**
* This is the beacon was sent event test.
*
* @author James Brooks <james@alt-three.com>
*/
class BeaconFailedToSendEventTest extends AbstractBeaconEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = [];
$object = new BeaconFailedToSendEvent();
return compact('params', 'object');
}
}

View File

@@ -1,35 +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\Bus\Events\Beacon;
use CachetHQ\Cachet\Bus\Events\Beacon\BeaconWasSentEvent;
/**
* This is the beacon was sent event test.
*
* @author James Brooks <james@alt-three.com>
*/
class BeaconWasSentEventTest extends AbstractBeaconEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = [];
$object = new BeaconWasSentEvent();
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\Component;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Component\ComponentEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractComponentEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [ComponentEventInterface::class];
}
}

View File

@@ -1,79 +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\Bus\Events\Component;
use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasChangedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use MailThief\Testing\InteractsWithMail;
/**
* This is the component status was changed event test.
*
* @author James Brooks <james@alt-three.com>
*/
class ComponentStatusWasChangedEventTest extends AbstractComponentEventTestCase
{
use DatabaseMigrations;
use InteractsWithMail;
public function testComponentUpdateEmailWasSent()
{
$user = factory('CachetHQ\Cachet\Models\User')->create();
$component = factory('CachetHQ\Cachet\Models\Component')->create([
'status' => 2,
]);
$subscriber = factory('CachetHQ\Cachet\Models\Subscriber')->create([
'verified_at' => '1970-01-01 00:00:00',
]);
$subscriber->subscriptions()->create(['component_id' => $component->id]);
$this->app['events']->fire(new ComponentStatusWasChangedEvent($user, $component, 1, 2, false));
$this->seeMessageFor($subscriber->email);
$this->seeMessageWithSubject(trans('notifications.component.status_update.mail.subject'));
$message = $this->getMailer()->lastMessage();
$this->assertTrue($message->contains($component->name));
$this->assertTrue($message->contains(trans('cachet.components.status.'.$component->status)));
}
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = [
'user' => new User(),
'component' => new Component(),
'original_status' => 1,
'new_status' => 2,
'silent' => false,
];
$object = new ComponentStatusWasChangedEvent(
$params['user'],
$params['component'],
$params['original_status'],
$params['new_status'],
$params['silent']
);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Component;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasCreatedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\User;
class ComponentWasCreatedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'component' => new Component()];
$object = new ComponentWasCreatedEvent($params['user'], $params['component']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Component;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasRemovedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\User;
class ComponentWasRemovedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'component' => new Component()];
$object = new ComponentWasRemovedEvent($params['user'], $params['component']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Component;
use CachetHQ\Cachet\Bus\Events\Component\ComponentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Component;
use CachetHQ\Cachet\Models\User;
class ComponentWasUpdatedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'component' => new Component()];
$object = new ComponentWasUpdatedEvent($params['user'], $params['component']);
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\ComponentGroup;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractComponentGroupEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [ComponentGroupEventInterface::class];
}
}

View File

@@ -1,32 +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\Bus\Events\ComponentGroup;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasCreatedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\User;
class ComponentGroupWasCreatedEventTest extends AbstractComponentGroupEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'group' => new ComponentGroup()];
$object = new ComponentGroupWasCreatedEvent($params['user'], $params['group']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\ComponentGroup;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasRemovedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\User;
class ComponentGroupWasRemovedEventTest extends AbstractComponentGroupEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'group' => new ComponentGroup()];
$object = new ComponentGroupWasRemovedEvent($params['user'], $params['group']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\ComponentGroup;
use CachetHQ\Cachet\Bus\Events\ComponentGroup\ComponentGroupWasUpdatedEvent;
use CachetHQ\Cachet\Models\ComponentGroup;
use CachetHQ\Cachet\Models\User;
class ComponentGroupWasUpdatedEventTest extends AbstractComponentGroupEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'group' => new ComponentGroup()];
$object = new ComponentGroupWasUpdatedEvent($params['user'], $params['group']);
return compact('params', 'object');
}
}

View File

@@ -1,30 +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\Bus\Events;
use AltThree\TestBench\ExistenceTrait;
use PHPUnit\Framework\TestCase;
/**
* This is the event existence test class.
*
* @author Graham Campbell <graham@alt-three.com>
*/
class EventExistenceTest extends TestCase
{
use ExistenceTrait;
protected function getSourcePath()
{
return realpath(__DIR__.'/../../../app/Bus/Events');
}
}

View File

@@ -1,26 +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\Bus\Events\Incident;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractIncidentEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [IncidentEventInterface::class];
}
}

View File

@@ -1,41 +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\Bus\Events\Incident;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasCreatedEvent;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User;
/**
* This is the incident was created event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class IncidentWasCreatedEventTest extends AbstractIncidentEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = [
'user' => new User(),
'incident' => new Incident(),
'notify' => true,
];
$object = new IncidentWasCreatedEvent($params['user'], $params['incident'], $params['notify']);
return compact('params', 'object');
}
}

View File

@@ -1,37 +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\Bus\Events\Incident;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasRemovedEvent;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User;
/**
* This is the incident was removed event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class IncidentWasRemovedEventTest extends AbstractIncidentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'incident' => new Incident()];
$object = new IncidentWasRemovedEvent($params['user'], $params['incident']);
return compact('params', 'object');
}
}

View File

@@ -1,37 +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\Bus\Events\Incident;
use CachetHQ\Cachet\Bus\Events\Incident\IncidentWasUpdatedEvent;
use CachetHQ\Cachet\Models\Incident;
use CachetHQ\Cachet\Models\User;
/**
* This is the incident was updated event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class IncidentWasUpdatedEventTest extends AbstractIncidentEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'incident' => new Incident()];
$object = new IncidentWasUpdatedEvent($params['user'], $params['incident']);
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\IncidentUpdate;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractIncidentUpdateEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [IncidentUpdateEventInterface::class];
}
}

View File

@@ -1,32 +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\Bus\Events\IncidentUpdate;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasRemovedEvent;
use CachetHQ\Cachet\Models\IncidentUpdate;
use CachetHQ\Cachet\Models\User;
class IncidentUpdateWasRemovedEventTest extends AbstractIncidentUpdateEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'update' => new IncidentUpdate()];
$object = new IncidentUpdateWasRemovedEvent($params['user'], $params['update']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\IncidentUpdate;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasReportedEvent;
use CachetHQ\Cachet\Models\IncidentUpdate;
use CachetHQ\Cachet\Models\User;
class IncidentUpdateWasReportedEventTest extends AbstractIncidentUpdateEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'update' => new IncidentUpdate()];
$object = new IncidentUpdateWasReportedEvent($params['user'], $params['update']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\IncidentUpdate;
use CachetHQ\Cachet\Bus\Events\IncidentUpdate\IncidentUpdateWasUpdatedEvent;
use CachetHQ\Cachet\Models\IncidentUpdate;
use CachetHQ\Cachet\Models\User;
class IncidentUpdateWasUpdatedEventTest extends AbstractIncidentUpdateEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'update' => new IncidentUpdate()];
$object = new IncidentUpdateWasUpdatedEvent($params['user'], $params['update']);
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\Invite;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Invite\InviteEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractInviteEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [InviteEventInterface::class];
}
}

View File

@@ -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\Bus\Events\Invite;
use CachetHQ\Cachet\Bus\Events\Invite\InviteWasClaimedEvent;
use CachetHQ\Cachet\Models\Invite;
class InviteWasClaimedEventTest extends AbstractInviteEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['invite' => new Invite()];
$object = new InviteWasClaimedEvent($params['invite']);
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\Metric;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Metric\MetricEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractMetricEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [MetricEventInterface::class];
}
}

View File

@@ -1,37 +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\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasCreatedEvent;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
/**
* This is the metric point was created event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class MetricPointWasCreatedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'metricPoint' => new MetricPoint()];
$object = new MetricPointWasCreatedEvent($params['user'], $params['metricPoint']);
return compact('params', 'object');
}
}

View File

@@ -1,37 +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\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasRemovedEvent;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
/**
* This is the metric point was removed event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class MetricPointWasRemovedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'metricPoint' => new MetricPoint()];
$object = new MetricPointWasRemovedEvent($params['user'], $params['metricPoint']);
return compact('params', 'object');
}
}

View File

@@ -1,37 +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\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\Metric\MetricPointWasUpdatedEvent;
use CachetHQ\Cachet\Models\MetricPoint;
use CachetHQ\Cachet\Models\User;
/**
* This is the metric point was updated event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class MetricPointWasUpdatedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'metricPoint' => new MetricPoint()];
$object = new MetricPointWasUpdatedEvent($params['user'], $params['metricPoint']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasCreatedEvent;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
class MetricWasCreatedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'metric' => new Metric()];
$object = new MetricWasCreatedEvent($params['user'], $params['metric']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasRemovedEvent;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
class MetricWasRemovedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'metric' => new Metric()];
$object = new MetricWasRemovedEvent($params['user'], $params['metric']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Metric;
use CachetHQ\Cachet\Bus\Events\Metric\MetricWasUpdatedEvent;
use CachetHQ\Cachet\Models\Metric;
use CachetHQ\Cachet\Models\User;
class MetricWasUpdatedEventTest extends AbstractMetricEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'metric' => new Metric()];
$object = new MetricWasUpdatedEvent($params['user'], $params['metric']);
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\Schedule;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractScheduleEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [ScheduleEventInterface::class];
}
}

View File

@@ -1,32 +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\Bus\Events\Schedule;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasCreatedEvent;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Cachet\Models\User;
class ScheduleWasCreatedEventTest extends AbstractScheduleEventTestCase
{
protected function objectHasHandlers()
{
return true;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'schedule' => new Schedule()];
$object = new ScheduleWasCreatedEvent($params['user'], $params['schedule']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Schedule;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasRemovedEvent;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Cachet\Models\User;
class ScheduleWasRemovedEventTest extends AbstractScheduleEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'schedule' => new Schedule()];
$object = new ScheduleWasRemovedEvent($params['user'], $params['schedule']);
return compact('params', 'object');
}
}

View File

@@ -1,32 +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\Bus\Events\Schedule;
use CachetHQ\Cachet\Bus\Events\Schedule\ScheduleWasUpdatedEvent;
use CachetHQ\Cachet\Models\Schedule;
use CachetHQ\Cachet\Models\User;
class ScheduleWasUpdatedEventTest extends AbstractScheduleEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User(), 'schedule' => new Schedule()];
$object = new ScheduleWasUpdatedEvent($params['user'], $params['schedule']);
return compact('params', 'object');
}
}

View File

@@ -1,26 +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\Bus\Events\Subscriber;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
abstract class AbstractSubscriberEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [SubscriberEventInterface::class];
}
}

View File

@@ -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\Bus\Events\Subscriber;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasSubscribedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasSubscribedEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasSubscribedEvent($params['subscriber']);
return compact('params', 'object');
}
}

View File

@@ -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\Bus\Events\Subscriber;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasUnsubscribedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasUnsubscribedEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasUnsubscribedEvent($params['subscriber']);
return compact('params', 'object');
}
}

View File

@@ -1,36 +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\Bus\Events\Subscriber;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasUpdatedSubscriptionsEvent;
use CachetHQ\Cachet\Models\Subscriber;
/**
* This is the subscriber has updated subscriptions event test.
*
* @author James Brooks <james@alt-three.com>
*/
class SubscriberHasUpdatedSubscriptionsEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasUpdatedSubscriptionsEvent($params['subscriber']);
return compact('params', 'object');
}
}

View File

@@ -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\Bus\Events\Subscriber;
use CachetHQ\Cachet\Bus\Events\Subscriber\SubscriberHasVerifiedEvent;
use CachetHQ\Cachet\Models\Subscriber;
class SubscriberHasVerifiedEventTest extends AbstractSubscriberEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['subscriber' => new Subscriber()];
$object = new SubscriberHasVerifiedEvent($params['subscriber']);
return compact('params', 'object');
}
}

View File

@@ -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\Bus\Events\System;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\System\SystemEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* This is the abstract system event test class.
*
* @author James Brooks <james@alt-three.com>
*/
abstract class AbstractSystemEventTestCase extends AbstractTestCase
{
use EventTrait;
protected function getEventInterfaces()
{
return [SystemEventInterface::class];
}
}

View File

@@ -1,35 +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\Bus\Events\System;
use CachetHQ\Cachet\Bus\Events\System\SystemCheckedForUpdatesEvent;
/**
* This is the system checked for updates event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class SystemCheckedForUpdatesEventTest extends AbstractSystemEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = [];
$object = new SystemCheckedForUpdatesEvent();
return compact('params', 'object');
}
}

View File

@@ -1,35 +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\Bus\Events\System;
use CachetHQ\Cachet\Bus\Events\System\SystemWasInstalledEvent;
/**
* This is the system was installed event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class SystemWasInstalledEventTest extends AbstractSystemEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = [];
$object = new SystemWasInstalledEvent();
return compact('params', 'object');
}
}

View File

@@ -1,35 +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\Bus\Events\System;
use CachetHQ\Cachet\Bus\Events\System\SystemWasResetEvent;
/**
* This is the system was reset event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class SystemWasResetEventTest extends AbstractSystemEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = [];
$object = new SystemWasResetEvent();
return compact('params', 'object');
}
}

View File

@@ -1,35 +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\Bus\Events\System;
use CachetHQ\Cachet\Bus\Events\System\SystemWasUpdatedEvent;
/**
* This is the system was updated event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class SystemWasUpdatedEventTest extends AbstractSystemEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = [];
$object = new SystemWasUpdatedEvent();
return compact('params', 'object');
}
}

View File

@@ -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\Bus\Events\User;
use AltThree\TestBench\EventTrait;
use CachetHQ\Cachet\Bus\Events\User\UserEventInterface;
use CachetHQ\Tests\Cachet\AbstractTestCase;
/**
* 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];
}
}

View File

@@ -1,40 +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\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\User\UserAcceptedInviteEvent;
use CachetHQ\Cachet\Models\Invite;
use CachetHQ\Cachet\Models\User;
/**
* This is the user accepted invite event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserAcceptedInviteEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = [
'user' => new User(),
'invite' => new Invite(),
];
$object = new UserAcceptedInviteEvent($params['user'], $params['invite']);
return compact('params', 'object');
}
}

View File

@@ -1,36 +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\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\User\UserDisabledTwoAuthEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the user disabled two auth event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserDisabledTwoAuthEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new UserDisabledTwoAuthEvent($params['user']);
return compact('params', 'object');
}
}

View File

@@ -1,36 +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\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\User\UserEnabledTwoAuthEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the user enabled two auth event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserEnabledTwoAuthEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new UserEnabledTwoAuthEvent($params['user']);
return compact('params', 'object');
}
}

View File

@@ -1,36 +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\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\User\UserFailedTwoAuthEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the user failed two auth event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserFailedTwoAuthEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new UserFailedTwoAuthEvent($params['user']);
return compact('params', 'object');
}
}

View File

@@ -1,36 +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\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\User\UserLoggedInEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the user logged in event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserLoggedInEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new UserLoggedInEvent($params['user']);
return compact('params', 'object');
}
}

View File

@@ -1,36 +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\Bus\Events\User;
use CachetHQ\Cachet\Bus\Events\User\UserLoggedOutEvent;
use CachetHQ\Cachet\Models\User;
/**
* This is the user logged out event test class.
*
* @author James Brooks <james@alt-three.com>
*/
class UserLoggedOutEventTest extends AbstractUserEventTestCase
{
protected function objectHasHandlers()
{
return false;
}
protected function getObjectAndParams()
{
$params = ['user' => new User()];
$object = new UserLoggedOutEvent($params['user']);
return compact('params', 'object');
}
}

Some files were not shown because too many files have changed in this diff Show More