diff --git a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php index e6f66f03..95c138d2 100644 --- a/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php +++ b/app/Bus/Handlers/Events/Component/SendComponentUpdateEmailNotificationHandler.php @@ -15,7 +15,6 @@ use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasUpdatedEvent; use CachetHQ\Cachet\Models\Component; use CachetHQ\Cachet\Models\Subscriber; use Illuminate\Contracts\Mail\MailQueue; -use Illuminate\Mail\Message; use McCool\LaravelAutoPresenter\Facades\AutoPresenter; class SendComponentUpdateEmailNotificationHandler @@ -111,7 +110,7 @@ class SendComponentUpdateEmailNotificationHandler $this->mailer->queue([ 'html' => 'emails.components.update-html', 'text' => 'emails.components.update-text', - ], $mail, function (Message $message) use ($mail) { + ], $mail, function ($message) use ($mail) { $message->to($mail['email'])->subject($mail['subject']); }); } diff --git a/app/Composers/Modules/ComponentsComposer.php b/app/Composers/Modules/ComponentsComposer.php index b581e045..10555c21 100644 --- a/app/Composers/Modules/ComponentsComposer.php +++ b/app/Composers/Modules/ComponentsComposer.php @@ -17,7 +17,7 @@ use Illuminate\Contracts\Auth\Guard; use Illuminate\Contracts\View\View; /** - * This is the status page composer. + * This is the components composer. * * @author James Brooks * @author Connor S. Parks @@ -44,7 +44,7 @@ class ComponentsComposer } /** - * Index page view composer. + * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * diff --git a/app/Composers/Modules/MetricsComposer.php b/app/Composers/Modules/MetricsComposer.php index 83870afb..cc0c38a3 100644 --- a/app/Composers/Modules/MetricsComposer.php +++ b/app/Composers/Modules/MetricsComposer.php @@ -15,6 +15,12 @@ use CachetHQ\Cachet\Models\Metric; use Illuminate\Contracts\Config\Repository; use Illuminate\Contracts\View\View; +/** + * This is the metrics composer. + * + * @author James Brooks + * @author Connor S. Parks + */ class MetricsComposer { /** @@ -25,7 +31,7 @@ class MetricsComposer protected $config; /** - * Create a new metrics composer. + * Create a new metrics composer instance. * * @param \Illuminate\Contracts\Config\Repository $config * @@ -37,7 +43,7 @@ class MetricsComposer } /** - * Metrics view composer. + * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * diff --git a/app/Composers/Modules/ScheduledComposer.php b/app/Composers/Modules/ScheduledComposer.php index 4dac2fe4..d2f3a927 100644 --- a/app/Composers/Modules/ScheduledComposer.php +++ b/app/Composers/Modules/ScheduledComposer.php @@ -15,7 +15,7 @@ use CachetHQ\Cachet\Models\Incident; use Illuminate\Contracts\View\View; /** - * This is the status page composer. + * This is the scheduled composer. * * @author James Brooks * @author Connor S. Parks @@ -23,7 +23,7 @@ use Illuminate\Contracts\View\View; class ScheduledComposer { /** - * Index page view composer. + * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * diff --git a/app/Composers/Modules/StatusComposer.php b/app/Composers/Modules/StatusComposer.php index f507021e..6449bfe5 100644 --- a/app/Composers/Modules/StatusComposer.php +++ b/app/Composers/Modules/StatusComposer.php @@ -15,7 +15,7 @@ use CachetHQ\Cachet\Integrations\Contracts\System; use Illuminate\Contracts\View\View; /** - * This is the status page composer. + * This is the status composer. * * @author James Brooks * @author Connor S. Parks @@ -30,7 +30,7 @@ class StatusComposer protected $system; /** - * Create a new status page composer instance. + * Create a new status composer instance. * * @param \CachetHQ\Cachet\Integrations\Contracts\System $system * @@ -42,7 +42,7 @@ class StatusComposer } /** - * Index page view composer. + * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * diff --git a/app/Composers/Modules/StickiedComposer.php b/app/Composers/Modules/StickiedComposer.php index dfb18659..084c9ff6 100644 --- a/app/Composers/Modules/StickiedComposer.php +++ b/app/Composers/Modules/StickiedComposer.php @@ -16,7 +16,7 @@ use CachetHQ\Cachet\Models\Incident; use Illuminate\Contracts\View\View; /** - * This is the status page composer. + * This is the stickied composer. * * @author James Brooks * @author Connor S. Parks @@ -25,7 +25,7 @@ use Illuminate\Contracts\View\View; class StickiedComposer { /** - * Index page view composer. + * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * diff --git a/app/Composers/Modules/TimelineComposer.php b/app/Composers/Modules/TimelineComposer.php index b0772c3d..7064a00c 100644 --- a/app/Composers/Modules/TimelineComposer.php +++ b/app/Composers/Modules/TimelineComposer.php @@ -14,7 +14,7 @@ namespace CachetHQ\Cachet\Composers\Modules; use Illuminate\Contracts\View\View; /** - * This is the status page composer. + * This is the timeline composer. * * @author James Brooks * @author Connor S. Parks @@ -22,7 +22,7 @@ use Illuminate\Contracts\View\View; class TimelineComposer { /** - * Index page view composer. + * Bind data to the view. * * @param \Illuminate\Contracts\View\View $view * diff --git a/composer.json b/composer.json index e06c81c1..e47634d2 100644 --- a/composer.json +++ b/composer.json @@ -53,7 +53,8 @@ "mockery/mockery": "0.9.5", "phpunit/phpunit": "4.8.21", "symfony/css-selector": "^3.0", - "symfony/dom-crawler": "^3.0" + "symfony/dom-crawler": "^3.0", + "tightenco/mailthief": "^0.2.3" }, "autoload": { "classmap": [ diff --git a/composer.lock b/composer.lock index 58af88b0..017cd1c2 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "1e913bd58bbbc4f626d0418762dcfd5a", - "content-hash": "a9bffd0764d483e1b33ed9f0fc1302ce", + "hash": "beb947157999db1d55d9af092dd81f37", + "content-hash": "89a23d2b2505160bda9ead17b9b0c0d4", "packages": [ { "name": "alt-three/badger", @@ -3238,16 +3238,16 @@ }, { "name": "symfony/css-selector", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/css-selector.git", - "reference": "2851e1932d77ce727776154d659b232d061e816a" + "reference": "ca809c64072e0fe61c1c7fb3c76cdc32265042ac" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/css-selector/zipball/2851e1932d77ce727776154d659b232d061e816a", - "reference": "2851e1932d77ce727776154d659b232d061e816a", + "url": "https://api.github.com/repos/symfony/css-selector/zipball/ca809c64072e0fe61c1c7fb3c76cdc32265042ac", + "reference": "ca809c64072e0fe61c1c7fb3c76cdc32265042ac", "shasum": "" }, "require": { @@ -3287,7 +3287,7 @@ ], "description": "Symfony CssSelector Component", "homepage": "https://symfony.com", - "time": "2016-06-29 05:41:56" + "time": "2016-09-06 11:02:40" }, { "name": "symfony/debug", @@ -3348,7 +3348,7 @@ }, { "name": "symfony/event-dispatcher", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/event-dispatcher.git", @@ -4057,16 +4057,16 @@ }, { "name": "twig/twig", - "version": "v1.25.0", + "version": "v1.26.0", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "f16a634ab08d87e520da5671ec52153d627f10f6" + "reference": "81c2b5fd36581370c7731387f05dcdb577050513" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/f16a634ab08d87e520da5671ec52153d627f10f6", - "reference": "f16a634ab08d87e520da5671ec52153d627f10f6", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/81c2b5fd36581370c7731387f05dcdb577050513", + "reference": "81c2b5fd36581370c7731387f05dcdb577050513", "shasum": "" }, "require": { @@ -4079,7 +4079,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.25-dev" + "dev-master": "1.26-dev" } }, "autoload": { @@ -4114,7 +4114,7 @@ "keywords": [ "templating" ], - "time": "2016-09-21 23:05:12" + "time": "2016-10-02 16:19:13" }, { "name": "vlucas/phpdotenv", @@ -5516,7 +5516,7 @@ }, { "name": "symfony/dom-crawler", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/dom-crawler.git", @@ -5572,16 +5572,16 @@ }, { "name": "symfony/yaml", - "version": "v3.1.4", + "version": "v3.1.5", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d" + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d", - "reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d", + "url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3", + "reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3", "shasum": "" }, "require": { @@ -5617,7 +5617,48 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2016-09-02 02:12:52" + "time": "2016-09-25 08:27:07" + }, + { + "name": "tightenco/mailthief", + "version": "v0.2.3", + "source": { + "type": "git", + "url": "https://github.com/tightenco/mailthief.git", + "reference": "274d4129ad8ad80cd122ab5448f31f1bb554fa8a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tightenco/mailthief/zipball/274d4129ad8ad80cd122ab5448f31f1bb554fa8a", + "reference": "274d4129ad8ad80cd122ab5448f31f1bb554fa8a", + "shasum": "" + }, + "require": { + "illuminate/mail": "^5.1", + "illuminate/view": "^5.1" + }, + "require-dev": { + "mockery/mockery": "^0.9.5", + "phpunit/phpunit": "^5.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "MailThief\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Adam Wathan", + "email": "adam.wathan@gmail.com" + } + ], + "description": "A fake Mailer for Laravel applications that takes the pain out of testing mail.", + "time": "2016-08-03 17:38:40" }, { "name": "webmozart/assert", diff --git a/tests/Bus/Events/Component/ComponentStatusWasUpdatedEventTest.php b/tests/Bus/Events/Component/ComponentStatusWasUpdatedEventTest.php index bffc38a1..4747ca3b 100644 --- a/tests/Bus/Events/Component/ComponentStatusWasUpdatedEventTest.php +++ b/tests/Bus/Events/Component/ComponentStatusWasUpdatedEventTest.php @@ -13,6 +13,8 @@ namespace CachetHQ\Tests\Cachet\Bus\Events\Component; use CachetHQ\Cachet\Bus\Events\Component\ComponentStatusWasUpdatedEvent; use CachetHQ\Cachet\Models\Component; +use Illuminate\Foundation\Testing\DatabaseMigrations; +use MailThief\Testing\InteractsWithMail; /** * This is the component status was updated event test. @@ -21,6 +23,31 @@ use CachetHQ\Cachet\Models\Component; */ class ComponentStatusWasUpdatedEventTest extends AbstractComponentEventTestCase { + use DatabaseMigrations, InteractsWithMail; + + public function testComponentUpdateEmailWasSent() + { + $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 ComponentStatusWasUpdatedEvent($component, 1, 2)); + + $this->seeMessageFor($subscriber->email); + $this->seeMessageWithSubject(trans('cachet.subscriber.email.component.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;