|
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\Event; |
|
13
|
|
|
|
|
14
|
|
|
use WBW\Bundle\HaveIBeenPwnedBundle\Tests\AbstractTestCase; |
|
15
|
|
|
use WBW\Bundle\HaveIBeenPwnedBundle\Tests\Fixtures\Event\TestEvent; |
|
16
|
|
|
use WBW\Library\HaveIBeenPwned\Entity\HaveIBeenPwnedEntityInterface; |
|
17
|
|
|
use WBW\Library\HaveIBeenPwned\Request\AbstractRequest; |
|
18
|
|
|
use WBW\Library\HaveIBeenPwned\Response\AbstractResponse; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* Abstract event test. |
|
22
|
|
|
* |
|
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
|
24
|
|
|
* @package WBW\Bundle\HaveIBeenPwnedBundle\Tests\Event |
|
25
|
|
|
*/ |
|
26
|
|
|
class AbstractEventTest extends AbstractTestCase { |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Entity. |
|
30
|
|
|
* |
|
31
|
|
|
* @var HaveIBeenPwnedEntityInterface |
|
32
|
|
|
*/ |
|
33
|
|
|
private $entity; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* {inheritdoc} |
|
37
|
|
|
*/ |
|
38
|
|
|
protected function setUp(): void { |
|
39
|
|
|
parent::setUp(); |
|
40
|
|
|
|
|
41
|
|
|
// Set a HaveIBeenPwned entity mock. |
|
42
|
|
|
$this->entity = $this->getMockBuilder(HaveIBeenPwnedEntityInterface::class)->getMock(); |
|
|
|
|
|
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* Tests setRequest() |
|
47
|
|
|
* |
|
48
|
|
|
* @return void |
|
49
|
|
|
*/ |
|
50
|
|
|
public function testSetRequest(): void { |
|
51
|
|
|
|
|
52
|
|
|
// Set a Request mock. |
|
53
|
|
|
$request = $this->getMockBuilder(AbstractRequest::class)->getMock(); |
|
54
|
|
|
|
|
55
|
|
|
$obj = new TestEvent("eventName", $this->entity); |
|
56
|
|
|
|
|
57
|
|
|
$obj->setRequest($request); |
|
58
|
|
|
$this->assertSame($request, $obj->getRequest()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Tests setResponse() |
|
63
|
|
|
* |
|
64
|
|
|
* @return void |
|
65
|
|
|
*/ |
|
66
|
|
|
public function testSetResponse(): void { |
|
67
|
|
|
|
|
68
|
|
|
// Set a Response mock. |
|
69
|
|
|
$response = $this->getMockBuilder(AbstractResponse::class)->getMock(); |
|
70
|
|
|
|
|
71
|
|
|
$obj = new TestEvent("eventName", $this->entity); |
|
72
|
|
|
|
|
73
|
|
|
$obj->setResponse($response); |
|
74
|
|
|
$this->assertSame($response, $obj->getResponse()); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Tests __construct() |
|
79
|
|
|
* |
|
80
|
|
|
* @return void |
|
81
|
|
|
*/ |
|
82
|
|
|
public function test__construct(): void { |
|
83
|
|
|
|
|
84
|
|
|
$obj = new TestEvent("eventName", $this->entity); |
|
85
|
|
|
|
|
86
|
|
|
$this->assertEquals("eventName", $obj->getEventName()); |
|
87
|
|
|
$this->assertSame($this->entity, $obj->getEntity()); |
|
88
|
|
|
$this->assertNull($obj->getRequest()); |
|
89
|
|
|
$this->assertNull($obj->getResponse()); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
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..