diff --git a/src/Listeners/AddFromSubmission.php b/src/Listeners/AddFromSubmission.php index 6bd4c75..11bd0e8 100755 --- a/src/Listeners/AddFromSubmission.php +++ b/src/Listeners/AddFromSubmission.php @@ -3,13 +3,13 @@ namespace Edalzell\Mailchimp\Listeners; use Edalzell\Mailchimp\Subscriber; -use Statamic\Forms\Submission; +use Statamic\Events\SubmissionCreated; class AddFromSubmission { - public function handle(Submission $submission) + public function handle(SubmissionCreated $event) { - $subscriber = new Subscriber($submission->data(), $this->formConfig($submission->form()->handle())); + $subscriber = new Subscriber($event->submission->data(), $this->formConfig($event->submission->form()->handle())); $subscriber->subscribe(); } diff --git a/tests/Unit/ListenersTest.php b/tests/Unit/ListenersTest.php index 7043624..486a9a6 100644 --- a/tests/Unit/ListenersTest.php +++ b/tests/Unit/ListenersTest.php @@ -7,7 +7,6 @@ use Illuminate\Support\Facades\Event; use Statamic\Events\SubmissionCreated; use Statamic\Facades\Form as FormAPI; -use Statamic\Fields\Blueprint; use Statamic\Forms\Form as Form; use Statamic\Forms\Submission; @@ -22,28 +21,24 @@ public function setUp(): void FormAPI::all()->each->delete(); - $blueprint = (new Blueprint)->setHandle('post')->save(); - $this->form = FormAPI::make('contact_us') ->title('Contact Us') - ->blueprint($blueprint) ->honeypot('winnie'); $this->form->save(); - $this->submission = $this->form->createSubmission(); + $this->submission = $this->form->makeSubmission(); $this->submission - ->unguard() ->data(['foo'=>'bar']); } /** @test */ public function does_respond_to_events() { - $this->mock(AddFromSubmission::class, function ($mock) { - $mock->shouldReceive('handle')->once(); - }); + $event = new SubmissionCreated($this->submission); + + $this->mock(AddFromSubmission::class)->shouldReceive('handle')->with($event)->once(); - Event::dispatch(SubmissionCreated::class, $this->submission); + Event::dispatch($event); } } diff --git a/tests/Unit/SubscriberTest.php b/tests/Unit/SubscriberTest.php index 55e24e3..6dcf87b 100644 --- a/tests/Unit/SubscriberTest.php +++ b/tests/Unit/SubscriberTest.php @@ -5,7 +5,6 @@ use Edalzell\Mailchimp\Subscriber; use Edalzell\Mailchimp\Tests\TestCase; use Statamic\Facades\Form as FormAPI; -use Statamic\Fields\Blueprint; use Statamic\Forms\Form as Form; use Statamic\Forms\Submission; @@ -20,18 +19,14 @@ public function setUp(): void FormAPI::all()->each->delete(); - $blueprint = (new Blueprint)->setHandle('post')->save(); - $this->form = FormAPI::make('contact_us') ->title('Contact Us') - ->blueprint($blueprint) ->honeypot('winnie'); $this->form->save(); - $this->submission = $this->form->createSubmission(); + $this->submission = $this->form->makeSubmission(); $this->submission - ->unguard() ->data(['foo'=>'bar']); }