unsure if this is nice, honestly

This commit is contained in:
Connor S. Parks
2016-08-20 13:51:12 +01:00
parent dbb87782e3
commit a9fd973b98
4 changed files with 73 additions and 5 deletions

View File

@@ -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
@@ -106,7 +105,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']);
});
}

View File

@@ -52,7 +52,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": [

45
composer.lock generated
View File

@@ -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": "8d282ec03bf68113417ee4eab7c0f4c5",
"content-hash": "b14ade2d704e51ad7f42c91377880304",
"hash": "b1e057f0b4af58332cab28ae468d8604",
"content-hash": "a964c95bed00a5dd448362afa7818d51",
"packages": [
{
"name": "alt-three/badger",
@@ -5560,6 +5560,47 @@
"homepage": "https://symfony.com",
"time": "2016-07-17 14:02:08"
},
{
"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",
"version": "1.1.0",

View File

@@ -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;