Added per-component subscriptions. Closes #734

This commit is contained in:
James Brooks
2016-01-10 15:54:54 +00:00
committed by James Brooks
parent e5c137f82b
commit ac3888f7c8
29 changed files with 620 additions and 17 deletions

View File

@@ -72,4 +72,13 @@ class SubscriberTest extends AbstractApiTestCase
$this->delete("/api/v1/subscribers/{$subscriber->id}");
$this->assertResponseStatus(204);
}
public function testDeleteSubscription()
{
$this->beUser();
$subscription = factory('CachetHQ\Cachet\Models\Subscription')->create();
$this->delete("/api/v1/subscriptions/{$subscription->id}");
$this->assertResponseStatus(204);
}
}

View File

@@ -28,8 +28,8 @@ class SubscribeSubscriberCommandTest extends AbstractTestCase
protected function getObjectAndParams()
{
$params = ['email' => 'support@cachethq.io', 'verified' => true];
$object = new SubscribeSubscriberCommand($params['email'], $params['verified']);
$params = ['email' => 'support@cachethq.io', 'verified' => true, 'subscriptions' => null];
$object = new SubscribeSubscriberCommand($params['email'], $params['verified'], $params['subscriptions']);
return compact('params', 'object');
}

View File

@@ -0,0 +1,41 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\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

@@ -18,7 +18,7 @@ class ComponentWasUpdatedEventTest extends AbstractComponentEventTestCase
{
protected function objectHasHandlers()
{
return false;
return true;
}
protected function getObjectAndParams()

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of Cachet.
*
* (c) Alt Three Services Limited
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace CachetHQ\Tests\Cachet\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');
}
}