Skip to content

Commit ac526cb

Browse files
authored
Merge pull request #67 from joselfonseca/feature/emit-event-for-registered-user
Emit event of user registered
2 parents e141778 + 90cc6c8 commit ac526cb

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/GraphQL/Mutations/Register.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public function resolve($rootValue, array $args, GraphQLContext $context = null,
3030
if ($model instanceof MustVerifyEmail) {
3131
$model->sendEmailVerificationNotification();
3232

33+
event(new Registered($model));
34+
3335
return [
3436
'tokens' => [],
3537
'status' => 'MUST_VERIFY_EMAIL',

tests/Integration/GraphQL/Mutations/Register.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
namespace Joselfonseca\LighthouseGraphQLPassport\Tests\Integration\GraphQL\Mutations;
44

5+
use Illuminate\Auth\Events\Registered;
6+
use Illuminate\Support\Facades\Event;
57
use Illuminate\Support\Facades\Notification;
68
use Joselfonseca\LighthouseGraphQLPassport\Notifications\VerifyEmail;
79
use Joselfonseca\LighthouseGraphQLPassport\Tests\TestCase;
@@ -51,6 +53,7 @@ public function test_it_sends_email_verification()
5153
{
5254
config()->set('auth.providers.users.model', UserVerifyEmail::class);
5355
Notification::fake();
56+
Event::fake([Registered::class]);
5457
$this->createClient();
5558
$response = $this->postGraphQL([
5659
'query' => 'mutation {
@@ -73,5 +76,6 @@ public function test_it_sends_email_verification()
7376
[$user],
7477
VerifyEmail::class
7578
);
79+
Event::assertDispatched(Registered::class);
7680
}
7781
}

0 commit comments

Comments
 (0)