Skip to content

Commit c30f40d

Browse files
author
Roman Leshchenko
committed
MAGETWO-92177: Wrong behavior of the list action
1 parent 96c373b commit c30f40d

File tree

1 file changed

+69
-0
lines changed

1 file changed

+69
-0
lines changed
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace Magento\Customer\Controller\Adminhtml\Index;
8+
9+
use Magento\TestFramework\TestCase\AbstractBackendController;
10+
use Magento\TestFramework\Helper\Bootstrap;
11+
use Magento\Newsletter\Model\SubscriberFactory;
12+
use Magento\Backend\Model\Session;
13+
use Magento\Framework\Data\Form\FormKey;
14+
15+
/**
16+
* Class MassUnsubscribeTest
17+
* @package Magento\Customer\Controller\Adminhtml\Index
18+
*/
19+
class MassUnsubscribeTest extends AbstractBackendController
20+
{
21+
/**
22+
* Base controller URL
23+
*
24+
* @var string
25+
*/
26+
protected $baseControllerUrl = 'http://localhost/index.php/backend/customer/index/index';
27+
28+
protected function tearDown()
29+
{
30+
/**
31+
* Unset customer data
32+
*/
33+
Bootstrap::getObjectManager()->get(Session::class)->setCustomerData(null);
34+
35+
/**
36+
* Unset messages
37+
*/
38+
Bootstrap::getObjectManager()->get(Session::class)->getMessages(true);
39+
}
40+
41+
/**
42+
* @magentoDataFixture Magento/Customer/_files/two_customers.php
43+
*/
44+
public function testMassUnsubscribAction()
45+
{
46+
$subscriberFactory = Bootstrap::getObjectManager()->get(SubscriberFactory::class);
47+
$formKey = $this->_objectManager->get(FormKey::class);
48+
$this->assertNull($subscriberFactory->create()->loadByCustomerId(1)->getSubscriberStatus());
49+
$this->assertNull($subscriberFactory->create()->loadByCustomerId(2)->getSubscriberStatus());
50+
51+
$this->getRequest()->setParams(
52+
[
53+
'selected' => [1, 2],
54+
'namespace' => 'customer_listing',
55+
'form_key' => $formKey->getFormKey()
56+
]
57+
)
58+
->setMethod('POST');
59+
$this->dispatch('backend/customer/index/massUnsubscribe');
60+
61+
$this->assertRedirect($this->stringStartsWith($this->baseControllerUrl));
62+
$this->assertSessionMessages(
63+
$this->equalTo(['A total of 2 record(s) were updated.']),
64+
\Magento\Framework\Message\MessageInterface::TYPE_SUCCESS
65+
);
66+
}
67+
68+
69+
}

0 commit comments

Comments
 (0)