|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Defines Ingenerator\Mailhook\MailhookAsserter |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright 2014 inGenerator Ltd |
|
6
|
|
|
* @licence BSD |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Ingenerator\Mailhook; |
|
10
|
|
|
|
|
11
|
|
|
use Ingenerator\Mailhook\Assert\NegativeAssertionRunner; |
|
12
|
|
|
use Ingenerator\Mailhook\Assert\PositiveAssertionRunner; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Asserts that emails exist matching a |
|
16
|
|
|
* |
|
17
|
|
|
* @package Ingenerator\Mailhook |
|
18
|
|
|
* @see spec\Ingenerator\Mailhook\MailhookAsserterSpec |
|
19
|
|
|
*/ |
|
20
|
|
|
class MailhookAsserter { |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @var Assert\NegativeAssertionRunner |
|
24
|
|
|
*/ |
|
25
|
|
|
protected $negative_runner; |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @var Assert\PositiveAssertionRunner |
|
29
|
|
|
*/ |
|
30
|
|
|
protected $positive_runner; |
|
31
|
|
|
|
|
32
|
|
|
public function __construct( |
|
33
|
|
|
PositiveAssertionRunner $positive_runner, |
|
34
|
|
|
NegativeAssertionRunner $negative_runner |
|
35
|
|
|
) |
|
36
|
|
|
{ |
|
37
|
|
|
$this->positive_runner = $positive_runner; |
|
38
|
|
|
$this->negative_runner = $negative_runner; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* @param EmailMatcher $matcher,... Matchers to run |
|
|
|
|
|
|
43
|
|
|
* |
|
44
|
|
|
* @return Email[] |
|
45
|
|
|
*/ |
|
46
|
|
|
public function emailsMatching($matcher = NULL) |
|
|
|
|
|
|
47
|
|
|
{ |
|
48
|
|
|
$matchers = \func_get_args(); |
|
49
|
|
|
|
|
50
|
|
|
return $this->positive_runner->assert($matchers); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @param EmailMatcher $matcher,... Matchers to run |
|
|
|
|
|
|
55
|
|
|
* |
|
56
|
|
|
* @return Email |
|
|
|
|
|
|
57
|
|
|
*/ |
|
58
|
|
|
public function firstEmailMatching($matcher = NULL) |
|
|
|
|
|
|
59
|
|
|
{ |
|
60
|
|
|
$matchers = \func_get_args(); |
|
61
|
|
|
$emails = $this->positive_runner->assert($matchers); |
|
62
|
|
|
|
|
63
|
|
|
return \array_shift($emails); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param EmailMatcher $matcher,... Matchers to run |
|
|
|
|
|
|
68
|
|
|
* |
|
69
|
|
|
* @return null |
|
|
|
|
|
|
70
|
|
|
*/ |
|
71
|
|
|
public function noEmailMatching($matcher = NULL) |
|
|
|
|
|
|
72
|
|
|
{ |
|
73
|
|
|
$matchers = \func_get_args(); |
|
74
|
|
|
|
|
75
|
|
|
return $this->negative_runner->assert($matchers) ? : NULL; |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.
Consider the following example. The parameter
$irelandis not defined by the methodfinale(...).The most likely cause is that the parameter was changed, but the annotation was not.