Skip to content

Commit 8a8864e

Browse files
committed
ACP2E-1972: add integration test; fixed unit test
1 parent 7722f88 commit 8a8864e

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

app/code/Magento/Customer/Test/Unit/Controller/Account/LoginPostTest.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use Magento\Framework\Exception\EmailNotConfirmedException;
2525
use Magento\Framework\Exception\State\UserLockedException;
2626
use Magento\Framework\Message\ManagerInterface;
27+
use Magento\Framework\Session\Generic;
2728
use Magento\Framework\Stdlib\Cookie\CookieMetadata;
2829
use Magento\Framework\Stdlib\Cookie\CookieMetadataFactory;
2930
use Magento\Framework\Stdlib\Cookie\PhpCookieManager;
@@ -102,6 +103,11 @@ class LoginPostTest extends TestCase
102103
*/
103104
protected $scopeConfig;
104105

106+
/**
107+
* @var Generic|MockObject
108+
*/
109+
private $generic;
110+
105111
protected function setUp(): void
106112
{
107113
$this->prepareContext();
@@ -135,13 +141,18 @@ protected function setUp(): void
135141
$this->scopeConfig = $this->getMockBuilder(ScopeConfigInterface::class)
136142
->getMockForAbstractClass();
137143

144+
$this->generic = $this->getMockBuilder(Generic::class)
145+
->disableOriginalConstructor()
146+
->getMock();
147+
138148
$this->controller = new LoginPost(
139149
$this->context,
140150
$this->session,
141151
$this->accountManagement,
142152
$this->url,
143153
$this->formkeyValidator,
144-
$this->accountRedirect
154+
$this->accountRedirect,
155+
$this->generic
145156
);
146157
$reflection = new \ReflectionClass(get_class($this->controller));
147158
$reflectionProperty = $reflection->getProperty('scopeConfig');

dev/tests/integration/testsuite/Magento/Customer/Controller/Account/LoginPostTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Magento\Framework\App\Request\Http as HttpRequest;
1313
use Magento\Framework\Message\MessageInterface;
1414
use Magento\Framework\Phrase;
15+
use Magento\Framework\Session\Generic;
1516
use Magento\Framework\Url\EncoderInterface;
1617
use Magento\TestFramework\TestCase\AbstractController;
1718

@@ -33,6 +34,11 @@ class LoginPostTest extends AbstractController
3334
*/
3435
private $customerUrl;
3536

37+
/**
38+
* @var Generic
39+
*/
40+
private $generic;
41+
3642
/**
3743
* @inheritdoc
3844
*/
@@ -43,6 +49,7 @@ protected function setUp(): void
4349
$this->session = $this->_objectManager->get(Session::class);
4450
$this->urlEncoder = $this->_objectManager->get(EncoderInterface::class);
4551
$this->customerUrl = $this->_objectManager->get(Url::class);
52+
$this->generic = $this->_objectManager->get(Generic::class);
4653
}
4754

4855
/**
@@ -220,6 +227,24 @@ public function testNoFormKeyLoginPostAction(): void
220227
);
221228
}
222229

230+
/**
231+
* @magentoConfigFixture current_store customer/startup/redirect_dashboard 1
232+
* @magentoConfigFixture current_store customer/captcha/enable 0
233+
*
234+
* @magentoDataFixture Magento/Customer/_files/customer.php
235+
*
236+
* @return void
237+
*/
238+
public function testVisitorForCustomerLoginPostAction(): void
239+
{
240+
$this->prepareRequest('customer@example.com', 'password');
241+
$this->dispatch('customer/account/loginPost');
242+
$this->assertTrue($this->session->isLoggedIn());
243+
$this->assertRedirect($this->stringContains('customer/account/'));
244+
$this->assertNotEmpty($this->generic->getVisitorData()['visitor_id']);
245+
$this->assertNotEmpty($this->generic->getVisitorData()['customer_id']);
246+
}
247+
223248
/**
224249
* Prepare request
225250
*

0 commit comments

Comments
 (0)