5
5
*/
6
6
namespace Magento \Customer \Controller ;
7
7
8
+ use Magento \Customer \Api \AccountManagementInterface ;
9
+ use Magento \Framework \Data \Form \FormKey ;
8
10
use Magento \TestFramework \Helper \Bootstrap ;
9
11
10
12
class AddressTest extends \Magento \TestFramework \TestCase \AbstractController
11
13
{
12
- /** @var \Magento\Customer\Api\ AccountManagementInterface */
14
+ /** @var AccountManagementInterface */
13
15
private $ accountManagement ;
14
16
17
+ /** @var FormKey */
18
+ private $ formKey ;
19
+
15
20
protected function setUp ()
16
21
{
17
22
parent ::setUp ();
@@ -20,9 +25,8 @@ protected function setUp()
20
25
'Magento\Customer\Model\Session ' ,
21
26
[$ logger ]
22
27
);
23
- $ this ->accountManagement = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
24
- 'Magento\Customer\Api\AccountManagementInterface '
25
- );
28
+ $ this ->accountManagement = Bootstrap::getObjectManager ()->create (AccountManagementInterface::class);
29
+ $ this ->formKey = Bootstrap::getObjectManager ()->create (FormKey::class);
26
30
$ customer = $ this ->accountManagement ->authenticate ('customer@example.com ' , 'password ' );
27
31
$ session ->setCustomerDataAsLoggedIn ($ customer );
28
32
}
@@ -152,6 +156,7 @@ public function testFailedFormPostAction()
152
156
public function testDeleteAction ()
153
157
{
154
158
$ this ->getRequest ()->setParam ('id ' , 1 );
159
+ $ this ->getRequest ()->setParam ('form_key ' , $ this ->formKey ->getFormKey ());
155
160
// we are overwriting the address coming from the fixture
156
161
$ this ->dispatch ('customer/address/delete ' );
157
162
@@ -169,6 +174,7 @@ public function testDeleteAction()
169
174
public function testWrongAddressDeleteAction ()
170
175
{
171
176
$ this ->getRequest ()->setParam ('id ' , 555 );
177
+ $ this ->getRequest ()->setParam ('form_key ' , $ this ->formKey ->getFormKey ());
172
178
// we are overwriting the address coming from the fixture
173
179
$ this ->dispatch ('customer/address/delete ' );
174
180
0 commit comments