protected function setupMockResponse(RequestInterface $request, $response) { // If a string is passed in, assume its a path to a HTTP representation if (is_string($response)) { $response = $this->getFixture($response); } $this->client->send(Argument::is($request))->shouldBeCalled()->willReturn($response); }
/** * @dataProvider right * * @expectedException \Fazland\Notifire\Exception\NotificationFailedException * * @param Sms $sms */ public function testNotifyShouldCallSkebbySendReceiveFailingResponseAndThrowNotificationFailedException(Sms $sms) { $skebbySms = SkebbySms::create()->setRecipients($sms->getTo())->setText($sms->getContent()); $response = new Response(self::RESPONSE_FAIL); $this->skebby->send($skebbySms)->shouldBeCalled(); $this->skebby->send($skebbySms)->willReturn([$response]); $this->handler->notify($sms); /** @var Result $result */ foreach ($sms->getResultSet()->all() as $result) { $this->assertTrue(Result::FAIL === $result->getResult()); } }
public function testShouldSetMultipartAlternativeIfEmailIsMultipart() { $email = new Email(); $email->addPart(Email\Part::create('BODY PART', 'text/plain'))->addPart(Email\Part::create('PART 2', 'text/html')); $this->mailer->send(Argument::that(function ($argument) { if (!$argument instanceof \Swift_Message) { return false; } $this->assertCount(2, $argument->getChildren()); $this->assertEquals('multipart/alternative', $argument->getContentType()); return true; }))->willReturn(1); $this->handler->notify($email); }
public function testOnNewAccountCreated() { $userName = '******'; $userEmail = '*****@*****.**'; $messageBody = 'Body'; $messageSubject = 'Subject'; $template = $this->prophet->prophesize('Twig_Template'); $event = $this->prophet->prophesize('Smoovio\\Bundle\\CoreBundle\\Event\\NewAccountCreatedEvent'); $user = $this->prophet->prophesize('Smoovio\\Bundle\\CoreBundle\\Entity\\User'); $this->templating->loadTemplate($this->templateName)->willReturn($template->reveal())->shouldBeCalled(); $template->renderBlock('subject', [])->willReturn('Subject'); $event->getUser()->willReturn($user); $user->getUsername()->willReturn($userName); $user->getEmail()->willReturn($userEmail); $template->renderBlock('body', ['username' => $userName])->willReturn($messageBody)->shouldBeCalled(); $this->mailer->send(Argument::that(function (\Swift_Message $message) use($userEmail, $messageBody, $messageSubject) { $this->assertSame($this->sender, $message->getSender()); $this->assertSame($userEmail, $message->getTo()); $this->assertSame($messageSubject, $message->getSubject()); $this->assertSame($messageBody, $message->getBody()); })); $this->listener->onNewAccountCreated($event->reveal()); $this->prophet->checkPredictions(); }