コード例 #1
0
ファイル: AssertionRunner.php プロジェクト: edusegzy/mailhook
 /**
  * Run assertions and throw if they do not pass
  *
  * @param EmailMatcher[] $matchers
  *
  * @return \Ingenerator\Mailhook\Email[] emails that matched the assertion
  */
 public function assert($matchers = array())
 {
     $this->mailhook->refresh();
     $mails = $this->filterer->filterEmails($this->mailhook->getEmails(), $matchers);
     $this->do_assert($mails, $matchers);
     return $mails;
 }
コード例 #2
0
 /**
  * @param \Ingenerator\Mailhook\EmailListFilterer $filterer
  * @param \Ingenerator\Mailhook\Email             $email_1
  * @param \Ingenerator\Mailhook\Email             $email_2
  *
  * @throws \PhpSpec\Exception\Example\FailureException
  */
 function it_throws_if_any_matching_emails($filterer, $email_1, $email_2)
 {
     $filterer->filterEmails(Argument::any(), Argument::any())->willReturn(array($email_1, $email_2));
     try {
         $this->subject->assert();
         throw new FailureException("Expected EmailAssertionFailedException");
     } catch (EmailAssertionFailedException $e) {
         // Expected
     }
 }
コード例 #3
0
 /**
  * @param \Ingenerator\Mailhook\EmailMatcher $matcher_1
  * @param \Ingenerator\Mailhook\EmailMatcher $matcher_2
  */
 function it_returns_emails_matching_all_matchers_with_some_good_and_some_bad($matcher_1, $matcher_2)
 {
     $both_good = new DummyEmail();
     $both_bad = new DummyEmail();
     $one_good = new DummyEmail();
     $two_good = new DummyEmail();
     $this->given_matcher_matches($matcher_1, array($both_good, $one_good));
     $this->given_matcher_matches($matcher_2, array($both_good, $two_good));
     $this->subject->filterEmails(array($both_good, $one_good, $two_good, $both_bad), array($matcher_1, $matcher_2))->shouldBe(array($both_good));
 }
コード例 #4
0
 /**
  * @param \Ingenerator\Mailhook\EmailListFilterer $filterer
  * @param \Ingenerator\Mailhook\EmailMatcher      $matcher
  */
 function it_filters_with_one_matcher($filterer, $matcher)
 {
     $this->try_assert_with(array($matcher));
     $filterer->filterEmails(Argument::any(), array($matcher))->shouldHaveBeenCalled();
 }
コード例 #5
0
 /**
  * @param \Ingenerator\Mailhook\EmailListFilterer $filterer
  * @param \Ingenerator\Mailhook\Email             $email_1
  * @param \Ingenerator\Mailhook\Email             $email_2
  */
 function it_returns_matching_emails_on_success($filterer, $email_1, $email_2)
 {
     $filterer->filterEmails(Argument::any(), Argument::any())->willReturn(array($email_1, $email_2));
     $this->subject->assert()->shouldBe(array($email_1, $email_2));
 }