|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* This file is part of the haveibeenpwned-bundle package. |
|
5
|
|
|
* |
|
6
|
|
|
* (c) 2019 WEBEWEB |
|
7
|
|
|
* |
|
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
9
|
|
|
* file that was distributed with this source code. |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace WBW\Bundle\HaveIBeenPwnedBundle\Tests; |
|
13
|
|
|
|
|
14
|
|
|
use WBW\Bundle\CoreBundle\Tests\AbstractTestCase as TestCase; |
|
15
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\BreachedAccountInterface; |
|
16
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\BreachesInterface; |
|
17
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\BreachInterface; |
|
18
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\PasteAccountInterface; |
|
19
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\RangeInterface; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Abstract test case. |
|
23
|
|
|
* |
|
24
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
25
|
|
|
* @package WBW\Bundle\HaveIBeenPwnedBundle\Tests |
|
26
|
|
|
* @abstract |
|
27
|
|
|
*/ |
|
28
|
|
|
abstract class AbstractTestCase extends TestCase { |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Breach. |
|
32
|
|
|
* |
|
33
|
|
|
* @var BreachInterface |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $breach; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* Breached account. |
|
39
|
|
|
* |
|
40
|
|
|
* @var BreachedAccountInterface |
|
41
|
|
|
*/ |
|
42
|
|
|
protected $breachedAccount; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* Breaches. |
|
46
|
|
|
* |
|
47
|
|
|
* @var BreachesInterface |
|
48
|
|
|
*/ |
|
49
|
|
|
protected $breaches; |
|
50
|
|
|
|
|
51
|
|
|
/** |
|
52
|
|
|
* Paste. |
|
53
|
|
|
* |
|
54
|
|
|
* @var PasteAccountInterface |
|
55
|
|
|
*/ |
|
56
|
|
|
protected $pasteAccount; |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* Range. |
|
60
|
|
|
* |
|
61
|
|
|
* @var RangeInterface |
|
62
|
|
|
*/ |
|
63
|
|
|
protected $range; |
|
64
|
|
|
|
|
65
|
|
|
/** |
|
66
|
|
|
* {inheritdoc} |
|
67
|
|
|
*/ |
|
68
|
|
|
protected function setUp(): void { |
|
69
|
|
|
parent::setUp(); |
|
70
|
|
|
|
|
71
|
|
|
// Set a Breach mock. |
|
72
|
|
|
$this->breach = $this->getMockBuilder(BreachInterface::class)->getMock(); |
|
|
|
|
|
|
73
|
|
|
$this->breach->expects($this->any())->method("getHaveIBeenPwnedName")->willReturn("Adobe"); |
|
74
|
|
|
|
|
75
|
|
|
// Set a Breached account mock. |
|
76
|
|
|
$this->breachedAccount = $this->getMockBuilder(BreachedAccountInterface::class)->getMock(); |
|
|
|
|
|
|
77
|
|
|
$this->breachedAccount->expects($this->any())->method("getHaveIBeenPwnedAccount")->willReturn("[email protected]"); |
|
78
|
|
|
$this->breachedAccount->expects($this->any())->method("getHaveIBeenPwnedDomain")->willReturn("adobe.com"); |
|
79
|
|
|
$this->breachedAccount->expects($this->any())->method("getHaveIBeenPwnedIncludeUnverified")->willReturn(true); |
|
80
|
|
|
$this->breachedAccount->expects($this->any())->method("getHaveIBeenPwnedTruncateResponse")->willReturn(false); |
|
81
|
|
|
|
|
82
|
|
|
// Set a Breaches mock. |
|
83
|
|
|
$this->breaches = $this->getMockBuilder(BreachesInterface::class)->getMock(); |
|
|
|
|
|
|
84
|
|
|
$this->breaches->expects($this->any())->method("getHaveIBeenPwnedDomain")->willReturn("adobe.com"); |
|
85
|
|
|
|
|
86
|
|
|
// Set a Paste account mock. |
|
87
|
|
|
$this->pasteAccount = $this->getMockBuilder(PasteAccountInterface::class)->getMock(); |
|
|
|
|
|
|
88
|
|
|
$this->pasteAccount->expects($this->any())->method("getHaveIBeenPwnedAccount")->willReturn("[email protected]"); |
|
89
|
|
|
|
|
90
|
|
|
// Set a Range mock. |
|
91
|
|
|
$this->range = $this->getMockBuilder(RangeInterface::class)->getMock(); |
|
|
|
|
|
|
92
|
|
|
$this->range->expects($this->any())->method("getHaveIBeenPwnedHash")->willReturn("21BD1"); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..