1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the smsmode-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\SmsModeBundle\Tests\Event; |
13
|
|
|
|
14
|
|
|
use WBW\Bundle\SmsModeBundle\Tests\AbstractTestCase; |
15
|
|
|
use WBW\Bundle\SmsModeBundle\Tests\Fixtures\Event\TestEvent; |
16
|
|
|
use WBW\Library\SmsMode\Entity\SmsModeEntityInterface; |
17
|
|
|
use WBW\Library\SmsMode\Request\AccountBalanceRequest; |
18
|
|
|
use WBW\Library\SmsMode\Response\AccountBalanceResponse; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* Abstract event test. |
22
|
|
|
* |
23
|
|
|
* @author webeweb <https://github.com/webeweb> |
24
|
|
|
* @package WBW\Bundle\SmsModeBundle\Tests\Event |
25
|
|
|
*/ |
26
|
|
|
class AbstractEventTest extends AbstractTestCase { |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Entity. |
30
|
|
|
* |
31
|
|
|
* @var SmsModeEntityInterface |
32
|
|
|
*/ |
33
|
|
|
private $entity; |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* {inheritdoc} |
37
|
|
|
*/ |
38
|
|
|
protected function setUp(): void { |
39
|
|
|
parent::setUp(); |
40
|
|
|
|
41
|
|
|
// Set a sMsmode entity mock. |
42
|
|
|
$this->entity = $this->getMockBuilder(SmsModeEntityInterface::class)->getMock(); |
|
|
|
|
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* Test setRequest() |
47
|
|
|
* |
48
|
|
|
* @return void |
49
|
|
|
*/ |
50
|
|
|
public function testSetRequest(): void { |
51
|
|
|
|
52
|
|
|
// Set a Request mock. |
53
|
|
|
$request = new AccountBalanceRequest(); |
54
|
|
|
|
55
|
|
|
$obj = new TestEvent("eventName", $this->entity); |
56
|
|
|
|
57
|
|
|
$obj->setRequest($request); |
58
|
|
|
$this->assertSame($request, $obj->getRequest()); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* Test setResponse() |
63
|
|
|
* |
64
|
|
|
* @return void |
65
|
|
|
*/ |
66
|
|
|
public function testSetResponse(): void { |
67
|
|
|
|
68
|
|
|
// Set a Response mock. |
69
|
|
|
$response = new AccountBalanceResponse(); |
70
|
|
|
|
71
|
|
|
$obj = new TestEvent("eventName", $this->entity); |
72
|
|
|
|
73
|
|
|
$obj->setResponse($response); |
74
|
|
|
$this->assertSame($response, $obj->getResponse()); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* Test __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..