1
1
<?php
2
2
/**
3
- * Created by PhpStorm.
4
- * User: rleshchenko
5
- * Date: 7/31/18
6
- * Time: 1:58 PM
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
7
5
*/
8
6
9
7
namespace Magento \Customer \Controller ;
10
8
9
+ use Magento \TestFramework \TestCase \AbstractController ;
10
+ use Magento \Customer \Api \AccountManagementInterface ;
11
+ use Magento \Framework \Data \Form \FormKey ;
12
+ use Magento \TestFramework \Helper \Bootstrap ;
13
+ use Magento \Customer \Model \Session ;
14
+ use Psr \Log \LoggerInterface ;
11
15
12
- class SendTest
16
+ class SendTest extends AbstractController
13
17
{
18
+ /** @var AccountManagementInterface */
19
+ private $ accountManagement ;
14
20
15
- }
21
+ /** @var FormKey */
22
+ private $ formKey ;
23
+
24
+ /**
25
+ * @throws \Magento\Framework\Exception\LocalizedException
26
+ */
27
+ protected function setUp ()
28
+ {
29
+ parent ::setUp ();
30
+ $ logger = $ this ->createMock (LoggerInterface::class);
31
+ $ session = Bootstrap::getObjectManager ()->create (
32
+ Session::class,
33
+ [$ logger ]
34
+ );
35
+ $ this ->accountManagement = Bootstrap::getObjectManager ()->create (AccountManagementInterface::class);
36
+ $ this ->formKey = Bootstrap::getObjectManager ()->create (FormKey::class);
37
+ $ customer = $ this ->accountManagement ->authenticate ('customer@example.com ' , 'password ' );
38
+ $ session ->setCustomerDataAsLoggedIn ($ customer );
39
+ }
40
+
41
+ /**
42
+ * @magentoDataFixture Magento/Customer/_files/customer.php
43
+ */
44
+ public function testExecutePost ()
45
+ {
46
+ $ this ->getRequest ()
47
+ ->setMethod ('POST ' )
48
+ ->setPostValue (
49
+ [
50
+ 'form_key ' => $ this ->formKey ->getFormKey (),
51
+ 'emails ' => 'example1@gmail.com, example2@gmail.com, example3@gmail.com '
52
+ ]
53
+ );
54
+
55
+ $ this ->dispatch ('wishlist/index/send ' );
56
+ $ this ->assertRedirect ($ this ->stringContains ('wishlist/index/index ' ));
57
+ $ this ->assertSessionMessages (
58
+ $ this ->equalTo (['Your wish list has been shared. ' ]),
59
+ \Magento \Framework \Message \MessageInterface::TYPE_SUCCESS
60
+ );
61
+ }
62
+ }
0 commit comments