public function testSend() { $this->event->expects($this->once())->method('getUser')->willReturn($this->user); $this->event->expects($this->once())->method('getToken')->willReturn('test_token'); \Mail::shouldReceive('send')->once(); $this->listener->handle($this->event); }
/** * @test */ public function canInviteQuizmasters() { $tournament = Tournament::firstOrFail(); // verify the quizzing preferences email is sent Mail::shouldReceive('queue')->once(); $this->visit('/tournaments/' . $tournament->slug . '/group')->click('Add Quizmaster')->type('John', 'first_name')->type('Gutson', 'last_name')->type('tester123' . time() . '@no-domain.com', 'email')->press('Save & Continue')->see('Quizmaster has been added')->see('John Gutson'); }
public function testCommandWithMailNotificationOptions() { $prod_repo_mock = Mockery::mock('Giftertipster\\Repository\\Product\\ProductRepositoryInterface'); $prod_repo_mock->shouldReceive('getRefreshedIdRange')->once()->with(1, null, 100)->andReturn([['id' => 1, 'vendor' => 'amz', 'vendor_id' => 'a1'], ['id' => 2, 'vendor' => 'amz', 'vendor_id' => 'a2']]); $prod_repo_mock->shouldReceive('getRefreshedIdRange')->once()->with(3, null, 100)->andReturn(false); $this->app->instance('Giftertipster\\Repository\\Product\\ProductRepositoryInterface', $prod_repo_mock); $amz_prod_repo_mock = Mockery::mock('Giftertipster\\Repository\\AmzProduct\\AmzProductRepositoryInterface'); $amz_prod_repo_mock->shouldReceive('detailLookup')->with('a1, a2')->once()->andReturn([['vendor' => 'amz', 'vendor_id' => 'a2'], ['vendor' => 'amz', 'vendor_id' => 'a1']]); $this->app->instance('Giftertipster\\Repository\\AmzProduct\\AmzProductRepositoryInterface', $amz_prod_repo_mock); $prod_suite_repo_mock = Mockery::mock('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface'); $prod_suite_repo_mock->shouldreceive('update')->with(1, ['vendor' => 'amz', 'vendor_id' => 'a1'], true)->once()->andReturn(true); $prod_suite_repo_mock->shouldreceive('update')->with(2, ['vendor' => 'amz', 'vendor_id' => 'a2'], true)->once()->andReturn(true); $this->app->instance('Giftertipster\\Repository\\ProductSuite\\ProductSuiteRepositoryInterface', $prod_suite_repo_mock); $job = $this->app->make('Giftertipster\\Entity\\Eloquent\\RangeCronJob'); $job->last_id_processed = 0; $job->last_status = 'success'; $cron_job_repo_mock = Mockery::mock('Giftertipster\\Repository\\RangeCronJob\\RangeCronJobRepositoryInterface'); $cron_job_repo_mock->shouldReceive('findJob')->with('products_update')->once()->andReturn($job); $cron_job_repo_mock->shouldReceive('updateJob')->with($job, 'in_progress', 2)->once()->andReturn(true); $cron_job_repo_mock->shouldReceive('updateJob')->with($job, 'success', 2)->once()->andReturn(true); $this->app->instance('Giftertipster\\Repository\\RangeCronJob\\RangeCronJobRepositoryInterface', $cron_job_repo_mock); \Mail::shouldReceive('send')->once(); $tester = new CommandTester(new UpdateProducts()); $tester->execute(['--mail-notification' => true]); }
public function testEsarz() { $this->mock->shouldReceive('create')->once(); $this->app->instance('Food', $this->mock); Validator::shouldReceive('make')->once()->andReturn(Mockery::mock(['fails' => false])); Mail::shouldReceive('send')->once()->with('emails.post', ['title' => 'dasdasd'], $this->getSendCallbackMock()); $this->call('POST', 'esarz', array('title' => 'dasdasd')); $this->assertRedirectedToRoute('foods.index'); }
/** * * @return void */ public function testSubscription() { $user = factory(App\Droit\Newsletter\Entities\Newsletter_users::class)->make(); $user->subscriptions = factory(App\Droit\Newsletter\Entities\Newsletter_subscriptions::class)->make(); $this->subscription->shouldReceive('findByEmail')->once()->andReturn(null); $this->subscription->shouldReceive('create')->once()->andReturn($user); Mail::shouldReceive('send')->once(); $response = $this->call('POST', 'subscribe', ['email' => '*****@*****.**']); $this->assertRedirectedTo('/'); }
/** * @param $queryParams * @param $expectedResult * * @dataProvider providerTestSendEmail */ public function testSendEmail($queryParams, $expectedResult) { if ($queryParams['save'] == true && $expectedResult == 201) { $totalBefore = Email::count(); } Mail::shouldReceive('send')->andReturn(true); Mail::shouldReceive('queue')->andReturn(true); $this->call('POST', '/api/emails/send', $queryParams, [], [], $this->serverParams); $this->assertResponseStatus($expectedResult); if ($queryParams['save'] == true && $expectedResult == 201) { $totalAfter = Email::count(); $this->assertEquals($totalBefore, $totalAfter - 1); } }
public function testSendEmailConfirmation() { $form = Form::where('slug', 'test-with-email-confirmation')->firstOrFail(); Mail::shouldReceive('send')->once()->andReturnUsing(function ($view, $data, $callback) { // replicate the behavior of Illuminate\Mail\Mailer::callMessageBuilder() // so we can test what would have been the result of the send() method $message = new Message(new Swift_Message()); call_user_func($callback, $message); $this->assertEquals('*****@*****.**', collect($message->getTo())->keys()->first()); return $message; }); $response = $this->call('POST', '/forms/' . $form->slug, ['email' => '*****@*****.**']); $this->assertEquals(201, $response->status()); }
/** * @test */ public function loginViaOAuth2() { Mail::shouldReceive('send'); $this->expectsEvents('auth.registered'); $this->call('GET', '/login/' . ThirdPartyAuthenticator::PROVIDER_GOOGLE, ['code' => uniqid()]); $this->assertRedirectedTo('/dashboard'); //assert user created $name = explode(' ', $this->providerUser->getName()); $createdUser = User::where('first_name', $name[0])->where('last_name', $name[1])->where('email', $this->providerUser->getEmail())->where('avatar', $this->providerUser->getAvatar())->first(); $this->assertGreaterThan(0, $createdUser->id); //assert OAuth id is linked to user $userProvider = $createdUser->providers->first(); $this->assertEquals(ThirdPartyAuthenticator::PROVIDER_GOOGLE, $userProvider->provider); $this->assertEquals($this->providerUser->getId(), $userProvider->provider_id); }
public function testEmail() { $user = $this->user; $subject = 'Your Password Reset Link'; Mail::shouldReceive('send')->once()->with('emails.password', m::on(function ($data) { $this->assertArrayHasKey('user', $data); return true; }), m::on(function (\Closure $closure) use($user, $subject) { $mock = m::mock('Illuminate\\Mail\\Message'); $mock->shouldReceive('to')->once()->with($user->email)->andReturn($mock); //simulate the chaining $mock->shouldReceive('subject')->once()->with($subject); $closure($mock); return true; })); $this->visit('/password/email')->see('Reset Password')->type($this->email, 'email')->press('Send Password Reset Link'); }
public function testSendMail() { $datas = $this->validData(['title' => 'TITLE', 'question' => 'QUESTION']); $filterd_datas = []; foreach ($datas as $key => $value) { if ($key[0] != '_') { $filterd_datas[$key] = $value; } } $message = m::mock(Message::class); $message->shouldReceive('from')->once()->with($datas['email'], $datas['name'])->andReturn($message); $message->shouldReceive('replyTo')->once()->with($datas['email'], $datas['name'])->andReturn($message); $message->shouldReceive('to')->once()->with($this->to['address'], $this->to['name'])->andReturn($message); $message->shouldReceive('subject')->once()->with($datas['_mailform_subject'])->andReturn($message); \Mail::shouldReceive('send')->once()->with(['text' => 'emails.mailform'], ['data' => $filterd_datas], m::on(function (\Closure $closure) use($message) { $closure($message); return true; })); $mailForm = new SendMailForm($datas); $mailForm->handle(); }
/** * @test */ public function receivesNotificationsForPastDueRegistrationFees() { Mail::shouldReceive('queue')->once(); Artisan::call(\BibleBowl\Seasons\RemindGroupsOfPendingRegistrationPayments::COMMAND); }
/** * @test */ public function receivesNotificationsForOutstandingRegistrationFees() { Mail::shouldReceive('queue')->once(); Artisan::call(\BibleBowl\Seasons\NotifyOfficeOfOutstandingRegistrationPayments::COMMAND); }
public function testOk_several() { Recaptcha::shouldReceive('verify')->once()->andReturn(true); Mail::shouldReceive('raw')->once()->with('#test mail toto => tata#', Mockery::on(function ($closure) { $message = Mockery::mock('Illuminate\\Mailer\\Message'); $message->shouldReceive('to')->with('*****@*****.**', 'toto')->andReturn(Mockery::self()); $message->shouldReceive('subject')->with('test mail title')->andReturn(Mockery::self()); $closure($message); return true; }))->andReturn(true); Mail::shouldReceive('raw')->once()->with('#test mail tutu => toto#', Mockery::on(function ($closure) { $message = Mockery::mock('Illuminate\\Mailer\\Message'); $message->shouldReceive('to')->with('*****@*****.**', 'tutu')->andReturn(Mockery::self()); $message->shouldReceive('subject')->with('test mail title')->andReturn(Mockery::self()); $closure($message); return true; }))->andReturn(true); Sms::shouldReceive('message')->once()->with('0612345678', '#test sms "tata\' => &tutu#')->andReturn(true); Sms::shouldReceive('message')->once()->with('0712345678', '#test sms "tutu\' => &toto#')->andReturn(true); $content = $this->ajaxPost('/', ['g-recaptcha-response' => 'mocked', 'name' => ['toto', 'tata', 'tutu'], 'email' => ['*****@*****.**', '', '*****@*****.**'], 'phone' => ['', '0612345678', '0712345678'], 'exclusions' => [['2'], ['0'], ['1']], 'title' => 'test mail title', 'contentMail' => 'test mail {SANTA} => {TARGET}', 'contentSMS' => 'test sms "{SANTA}\' => &{TARGET}'], 200); $this->assertEquals(['Envoyé avec succès !'], $content); }
/** * @test */ public function it_sends_a_localized_email() { $this->mail->shouldReceive('send'); $this->transmail->locale('en_US.utf8')->template('welcome')->subject('welcome')->send($this->header, $this->params); }