ltsecurityinc安防产品在线商城代码

This commit is contained in:
2026-09-14 17:47:10 +08:00
parent 57d8444c15
commit 6a3c9c5bd8
14539 changed files with 1775310 additions and 0 deletions
@@ -0,0 +1,352 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Customer\Controller\Account;
use Magento\Customer\Api\CustomerRepositoryInterface;
use Magento\Customer\Api\Data\CustomerInterface;
use Magento\Customer\Model\CustomerRegistry;
use Magento\Customer\Model\Delegation\Storage as DelegatedStorage;
use Magento\Framework\App\Http;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Exception\NoSuchEntityException;
use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Stdlib\CookieManagerInterface;
use Magento\Framework\UrlInterface;
use Magento\Sales\Model\Order;
use Magento\Sales\Model\Order\Item as OrderItem;
use Magento\Store\Model\StoreManagerInterface;
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
use Magento\TestFramework\Request;
use Magento\TestFramework\TestCase\AbstractController;
use Magento\Theme\Controller\Result\MessagePlugin;
/**
* Tests from customer account create post action.
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CreatePostTest extends AbstractController
{
/**
* @var TransportBuilderMock
*/
private $transportBuilderMock;
/**
* @var StoreManagerInterface
*/
private $storeManager;
/**
* @var CustomerRepositoryInterface
*/
private $customerRepository;
/**
* @var CustomerRegistry
*/
private $customerRegistry;
/**
* @var CookieManagerInterface
*/
private $cookieManager;
/**
* @var UrlInterface
*/
private $urlBuilder;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->transportBuilderMock = $this->_objectManager->get(TransportBuilderMock::class);
$this->storeManager = $this->_objectManager->get(StoreManagerInterface::class);
$this->customerRepository = $this->_objectManager->get(CustomerRepositoryInterface::class);
$this->customerRegistry = $this->_objectManager->get(CustomerRegistry::class);
$this->cookieManager = $this->_objectManager->get(CookieManagerInterface::class);
$this->urlBuilder = $this->_objectManager->get(UrlInterface::class);
}
/**
* Tests that without form key user account won't be created
* and user will be redirected on account creation page again.
*
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @return void
*/
public function testNoFormKeyCreatePostAction(): void
{
$this->fillRequestWithAccountData('test1@email.com');
$this->getRequest()->setPostValue('form_key', null);
$this->dispatch('customer/account/createPost');
$this->assertCustomerNotExists('test1@email.com');
$this->assertRedirect($this->stringEndsWith('customer/account/create/'));
$this->assertSessionMessages(
$this->stringContains((string)__('Invalid Form Key. Please refresh the page.')),
MessageInterface::TYPE_ERROR
);
}
/**
* Check that DateTime option is NOT changed after creating Customer account for which guest order was placed.
*
* @return void
* @magentoDataFixture Magento/Sales/_files/guest_order_with_product_and_custom_options.php
*/
public function testCreateCustomerAccountAfterIssuingGuestOrder(): void
{
/** @var Order $order */
$order = $this->_objectManager->create(Order::class);
$order->loadByIncrementId('100000001');
/** @var CustomerInterface $customer */
$customer = $this->_objectManager->create(CustomerInterface::class);
/** @var DelegatedStorage $delegatedStorage */
$delegatedStorage = $this->_objectManager->get(DelegatedStorage::class);
$delegatedStorage->storeNewOperation($customer, ['__sales_assign_order_id' => $order->getId()]);
$this->fillRequestWithAccountData('customer@example.com');
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringEndsWith('customer/account/'));
$this->assertSessionMessages(
$this->containsEqual(
(string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName())
),
MessageInterface::TYPE_SUCCESS
);
$expectedResult = [
'year' => '2021',
'month' => '9',
'day' => '9',
'hour' => '2',
'minute' => '2',
'day_part' => 'am',
'date_internal' => '2021-09-09 02:02:00',
];
/** @var OrderItem $orderItem */
$orderItem = $order->getItemsCollection()->getFirstItem();
$actualResult = current($orderItem->getBuyRequest()->getOptions());
$this->assertIsArray($actualResult);
$this->assertEquals($expectedResult, $actualResult);
}
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture current_website customer/create_account/confirm 0
* @magentoConfigFixture current_store customer/create_account/default_group 1
* @magentoConfigFixture current_store customer/create_account/generate_human_friendly_id 0
*
* @return void
*/
public function testNoConfirmCreatePostAction(): void
{
$this->fillRequestWithAccountData('test1@email.com');
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringEndsWith('customer/account/'));
$this->assertSessionMessages(
$this->containsEqual(
(string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName())
),
MessageInterface::TYPE_SUCCESS
);
$customer = $this->customerRegistry->retrieveByEmail('test1@email.com');
//Assert customer group
$this->assertEquals(1, $customer->getDataModel()->getGroupId());
//Assert customer increment id generation
$this->assertNull($customer->getData('increment_id'));
}
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture current_website customer/create_account/confirm 0
* @magentoConfigFixture current_store customer/create_account/default_group 2
* @magentoConfigFixture current_store customer/create_account/generate_human_friendly_id 1
* @return void
*/
public function testCreatePostWithCustomConfiguration(): void
{
$this->fillRequestWithAccountData('test@email.com');
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringEndsWith('customer/account/'));
$this->assertSessionMessages(
$this->containsEqual(
(string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName())
),
MessageInterface::TYPE_SUCCESS
);
$customer = $this->customerRegistry->retrieveByEmail('test@email.com');
//Assert customer group
$this->assertEquals(2, $customer->getDataModel()->getGroupId());
//Assert customer increment id generation
$this->assertNotNull($customer->getData('increment_id'));
$this->assertMatchesRegularExpression('/\d{8}/', $customer->getData('increment_id'));
}
/**
* @magentoDbIsolation enabled
* @magentoAppIsolation enabled
* @magentoConfigFixture current_website customer/create_account/confirm 1
*
* @return void
*/
public function testWithConfirmCreatePostAction(): void
{
$email = 'test2@email.com';
$this->fillRequestWithAccountData($email);
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringContains('customer/account/index/'));
$message = 'You must confirm your account.'
. ' Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.';
$url = $this->urlBuilder->getUrl('customer/account/confirmation', ['_query' => ['email' => $email]]);
$this->assertSessionMessages(
$this->containsEqual((string)__($message, $url)),
MessageInterface::TYPE_SUCCESS
);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @return void
*/
public function testExistingEmailCreatePostAction(): void
{
$this->fillRequestWithAccountData('customer@example.com');
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringContains('customer/account/create/'));
$message = 'There is already an account with this email address.'
. ' If you are sure that it is your email address, <a href="%1">click here</a> '
. 'to get your password and access your account.';
$url = $this->urlBuilder->getUrl('customer/account/forgotpassword');
$this->assertSessionMessages($this->containsEqual((string)__($message, $url)), MessageInterface::TYPE_ERROR);
}
/**
* Register Customer with email confirmation.
*
* @magentoAppArea frontend
* @magentoConfigFixture current_website customer/create_account/confirm 1
*
* @return void
*/
public function testRegisterCustomerWithEmailConfirmation(): void
{
$email = 'test_example@email.com';
$this->fillRequestWithAccountData($email);
$this->dispatch('customer/account/createPost');
$this->assertRedirect($this->stringContains('customer/account/index/'));
$message = 'You must confirm your account.'
. ' Please check your email for the confirmation link or <a href="%1">click here</a> for a new link.';
$url = $this->urlBuilder->getUrl('customer/account/confirmation', ['_query' => ['email' => $email]]);
$this->assertSessionMessages($this->containsEqual((string)__($message, $url)), MessageInterface::TYPE_SUCCESS);
/** @var CustomerInterface $customer */
$customer = $this->customerRepository->get($email);
$confirmation = $customer->getConfirmation();
$sendMessage = $this->transportBuilderMock->getSentMessage();
$this->assertNotNull($sendMessage);
$rawMessage = $sendMessage->getBody()->getParts()[0]->getRawContent();
$this->assertStringContainsString(
(string)__(
'You must confirm your %customer_email email before you can sign in (link is only valid once):',
['customer_email' => $email]
),
$rawMessage
);
$this->assertStringContainsString(
sprintf('customer/account/confirm/?id=%s&amp;key=%s', $customer->getId(), $confirmation),
$rawMessage
);
$this->resetRequest();
$this->getRequest()
->setParam('id', $customer->getId())
->setParam('key', $confirmation);
$this->dispatch('customer/account/confirm');
$this->assertRedirect($this->stringContains('customer/account/index/'));
$this->assertSessionMessages(
$this->containsEqual(
(string)__('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName())
),
MessageInterface::TYPE_SUCCESS
);
$this->assertEmpty($this->customerRepository->get($email)->getConfirmation());
}
/**
* Fills request with customer data.
*
* @param string $email
* @return void
*/
private function fillRequestWithAccountData(string $email): void
{
$this->getRequest()
->setMethod(HttpRequest::METHOD_POST)
->setParam(CustomerInterface::FIRSTNAME, 'firstname1')
->setParam(CustomerInterface::LASTNAME, 'lastname1')
->setParam(CustomerInterface::EMAIL, $email)
->setParam('password', '_Password1')
->setParam('password_confirmation', '_Password1')
->setParam('telephone', '5123334444')
->setParam('street', ['1234 fake street', ''])
->setParam('city', 'Austin')
->setParam('postcode', '78701')
->setParam('country_id', 'US')
->setParam('default_billing', '1')
->setParam('default_shipping', '1')
->setParam('is_subscribed', '0')
->setPostValue('create_address', true);
}
/**
* Asserts that customer does not exists.
*
* @param string $email
* @return void
*/
private function assertCustomerNotExists(string $email): void
{
$this->expectException(NoSuchEntityException::class);
$this->expectExceptionMessage(
(string)__(
'No such entity with %fieldName = %fieldValue, %field2Name = %field2Value',
[
'fieldName' => 'email',
'fieldValue' => $email,
'field2Name' => 'websiteId',
'field2Value' => 1
]
)
);
$this->assertNull($this->customerRepository->get($email));
}
/**
* Clears request.
*
* @return void
*/
protected function resetRequest(): void
{
parent::resetRequest();
$this->cookieManager->deleteCookie(MessagePlugin::MESSAGES_COOKIES_NAME);
$this->_objectManager->removeSharedInstance(Http::class);
$this->_objectManager->removeSharedInstance(Request::class);
}
}
@@ -0,0 +1,204 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Customer\Controller\Account;
use Magento\Customer\Model\Session;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Data\Form\FormKey;
use Magento\Framework\Mail\EmailMessage;
use Magento\Framework\Message\MessageInterface;
use Magento\TestFramework\Mail\Template\TransportBuilderMock;
use Magento\TestFramework\TestCase\AbstractController;
/**
* Set of tests to verify e-mail templates delivered to Customers
*
* @magentoAppArea frontend
*/
class EmailTemplateTest extends AbstractController
{
private const FIXTURE_CUSTOMER_EMAIL = 'customer@example.com';
private const FIXTURE_CUSTOMER_FIRSTNAME = 'John';
private const FIXTURE_CUSTOMER_LASTNAME = 'Smith';
private const FIXTURE_CUSTOMER_ID = 1;
private const FIXTURE_CUSTOMER_PASSWORD = 'password';
private const EXPECTED_GREETING = self::FIXTURE_CUSTOMER_FIRSTNAME . ' ' . self::FIXTURE_CUSTOMER_LASTNAME . ',';
/**
* @var TransportBuilderMock
*/
private $transportBuilderMock;
/**
* @var Session
*/
private $session;
/**
* @var FormKey
*/
private $formKey;
protected function setUp(): void
{
parent::setUp();
$this->transportBuilderMock = $this->_objectManager->get(TransportBuilderMock::class);
$this->session = $this->_objectManager->get(Session::class);
$this->formKey = $this->_objectManager->get(FormKey::class);
}
/**
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoConfigFixture current_store customer/captcha/enable 0
*/
public function testForgotPasswordEmailTemplateGreeting()
{
$this->getRequest()->setMethod(HttpRequest::METHOD_POST)
->setPostValue(['email' => self::FIXTURE_CUSTOMER_EMAIL]);
$this->dispatch('customer/account/forgotPasswordPost');
$this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage());
}
/**
* Covers Magento_Customer::view/frontend/email/change_email.html
*
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoConfigFixture current_store customer/captcha/enable 0
*/
public function testCustomerEmailChangeNotificationTemplateGreeting()
{
$this->loginByCustomerId(self::FIXTURE_CUSTOMER_ID);
$this->sendAccountEditRequest([
'email' => 'new.email@example.com',
'change_email' => 1,
]);
$this->assertRedirect($this->stringContains('customer/account/'));
$this->assertSessionMessages(
$this->equalTo(['You saved the account information.']),
MessageInterface::TYPE_SUCCESS
);
$this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage());
}
/**
* Covers Magento_Customer::view/frontend/email/change_email_and_password.html
*
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoConfigFixture current_store customer/captcha/enable 0
*/
public function testCustomerEmailAndPasswordChangeNotificationTemplateGreeting()
{
$this->loginByCustomerId(self::FIXTURE_CUSTOMER_ID);
$this->sendAccountEditRequest([
'email' => 'new.email@example.com',
'change_email' => 1,
'change_password' => 1,
'password' => 'new-Password1',
'password_confirmation' => 'new-Password1',
]);
$this->assertRedirect($this->stringContains('customer/account/'));
$this->assertSessionMessages(
$this->equalTo(['You saved the account information.']),
MessageInterface::TYPE_SUCCESS
);
$this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage());
}
/**
* Covers Magento_Customer::view/frontend/email/change_password.html
*
* @magentoDataFixture Magento/Customer/_files/customer.php
* @magentoConfigFixture current_store customer/captcha/enable 0
*/
public function testCustomerPasswordChangeNotificationTemplateGreeting()
{
$this->loginByCustomerId(self::FIXTURE_CUSTOMER_ID);
$this->sendAccountEditRequest([
'change_password' => 1,
'password' => 'new-Password1',
'password_confirmation' => 'new-Password1',
]);
$this->assertRedirect($this->stringContains('customer/account/'));
$this->assertSessionMessages(
$this->equalTo(['You saved the account information.']),
MessageInterface::TYPE_SUCCESS
);
$this->assertSameGreeting(self::EXPECTED_GREETING, $this->transportBuilderMock->getSentMessage());
}
/**
* Wraps Customer Edit POST request
*
* @param array $customData
*/
private function sendAccountEditRequest(array $customData): void
{
$basicData = [
'form_key' => $this->formKey->getFormKey(),
'firstname' => self::FIXTURE_CUSTOMER_FIRSTNAME,
'lastname' => self::FIXTURE_CUSTOMER_LASTNAME,
'current_password' => self::FIXTURE_CUSTOMER_PASSWORD
];
$this->getRequest()->setMethod(HttpRequest::METHOD_POST)
->setPostValue(array_merge($basicData, $customData));
$this->dispatch('customer/account/editPost');
}
/**
* Verifies if `<p class="greeting"/>` text contents equals the expected one.
*
* @param string $expectedGreeting
* @param EmailMessage $message
*/
private function assertSameGreeting(string $expectedGreeting, EmailMessage $message)
{
$messageContent = $this->getMessageRawContent($message);
$emailDom = new \DOMDocument();
$emailDom->loadHTML($messageContent);
$emailXpath = new \DOMXPath($emailDom);
$greeting = $emailXpath->query('//p[@class="greeting"]');
$this->assertSame(1, $greeting->length);
$this->assertSame($expectedGreeting, $greeting->item(0)->textContent);
}
/**
* Returns raw content of provided message
*
* @param EmailMessage $message
* @return string
*/
private function getMessageRawContent(EmailMessage $message): string
{
$emailParts = $message->getBody()->getParts();
return current($emailParts)->getRawContent();
}
/**
* Performs Customer log in
*
* @param int $customerId
*/
private function loginByCustomerId(int $customerId): void
{
$this->session->loginById($customerId);
}
}
@@ -0,0 +1,240 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\Customer\Controller\Account;
use Magento\Customer\Model\Session;
use Magento\Customer\Model\Url;
use Magento\Framework\App\Request\Http as HttpRequest;
use Magento\Framework\Message\MessageInterface;
use Magento\Framework\Phrase;
use Magento\Framework\Url\EncoderInterface;
use Magento\TestFramework\TestCase\AbstractController;
/**
* Class checks customer login action
*
* @see \Magento\Customer\Controller\Account\LoginPost
*/
class LoginPostTest extends AbstractController
{
/** @var Session */
private $session;
/** @var EncoderInterface */
private $urlEncoder;
/**
* @var Url
*/
private $customerUrl;
/**
* @inheritdoc
*/
protected function setUp(): void
{
parent::setUp();
$this->session = $this->_objectManager->get(Session::class);
$this->urlEncoder = $this->_objectManager->get(EncoderInterface::class);
$this->customerUrl = $this->_objectManager->get(Url::class);
}
/**
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @dataProvider missingParametersDataProvider
*
* @param string|null $email
* @param string|null $password
* @param string $expectedErrorMessage
* @return void
*/
public function testLoginIncorrectParameters(?string $email, ?string $password, string $expectedErrorMessage): void
{
$this->prepareRequest($email, $password);
$this->dispatch('customer/account/loginPost');
$this->assertSessionMessages(
$this->equalTo([(string)__($expectedErrorMessage)]),
MessageInterface::TYPE_ERROR
);
}
/**
* @return array
*/
public function missingParametersDataProvider(): array
{
return [
'missing_email' => [
'email' => null,
'password' => 'password',
'expected_error_message' => 'A login and a password are required.',
],
'missing_password' => [
'email' => 'customer@example.com',
'password' => null,
'expected_error_message' => 'A login and a password are required.',
],
'missing_both_parameters' => [
'email' => null,
'password' => null,
'expected_error_message' => 'A login and a password are required.',
],
'wrong_email' => [
'email' => 'wrongemail@example.com',
'password' => 'password',
'expected_error_message' => 'The account sign-in was incorrect or your account is disabled temporarily.'
. ' Please wait and try again later.',
],
'wrong_password' => [
'email' => 'customer@example.com',
'password' => 'wrongpassword',
'expected_error_message' => 'The account sign-in was incorrect or your account is disabled temporarily.'
. ' Please wait and try again later.',
],
];
}
/**
* @magentoDataFixture Magento/Customer/_files/customer_confirmation_config_enable.php
* @magentoDataFixture Magento/Customer/_files/unconfirmed_customer.php
*
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @return void
*/
public function testLoginWithUnconfirmedPassword(): void
{
$email = 'unconfirmedcustomer@example.com';
$this->prepareRequest($email, 'Qwert12345');
$this->dispatch('customer/account/loginPost');
$this->assertEquals($email, $this->session->getUsername());
$message = __(
'This account is not confirmed. <a href="%1">Click here</a> to resend confirmation email.',
$this->customerUrl->getEmailConfirmationUrl($this->session->getUsername())
);
$this->assertSessionMessages(
$this->equalTo([(string)$message]),
MessageInterface::TYPE_ERROR
);
}
/**
* @magentoConfigFixture current_store customer/startup/redirect_dashboard 0
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @return void
*/
public function testLoginWithRedirectToDashboardDisabled(): void
{
$this->prepareRequest('customer@example.com', 'password');
$this->getRequest()->setParam(Url::REFERER_QUERY_PARAM_NAME, $this->urlEncoder->encode('test_redirect'));
$this->dispatch('customer/account/loginPost');
$this->assertTrue($this->session->isLoggedIn());
$this->assertRedirect($this->stringContains('test_redirect'));
}
/**
* @magentoConfigFixture current_store customer/startup/redirect_dashboard 0
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @return void
*/
public function testLoginFailureWithRedirectToDashboardDisabled(): void
{
$this->prepareRequest('customer@example.com', 'incorrect');
$this->dispatch('customer/account/loginPost');
$this->assertFalse($this->session->isLoggedIn());
$this->assertRedirect($this->logicalAnd(
$this->stringContains('customer/account/login'),
$this->logicalnot($this->stringContains('referer'))
));
}
/**
* @magentoConfigFixture current_store customer/startup/redirect_dashboard 0
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @return void
*/
public function testLoginToDashboardWithIncorrectReferrer(): void
{
$redirectUrl = 'https:support.magento.com';
$this->prepareRequest('customer@example.com', 'password');
$this->getRequest()->setParam(Url::REFERER_QUERY_PARAM_NAME, $this->urlEncoder->encode($redirectUrl));
$this->dispatch('customer/account/loginPost');
$this->assertTrue($this->session->isLoggedIn());
$this->assertRedirect($this->stringContains('customer/account/'));
}
/**
* @magentoConfigFixture current_store customer/startup/redirect_dashboard 1
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @return void
*/
public function testLoginWithRedirectToDashboard(): void
{
$this->prepareRequest('customer@example.com', 'password');
$this->getRequest()->setParam(Url::REFERER_QUERY_PARAM_NAME, $this->urlEncoder->encode('test_redirect'));
$this->dispatch('customer/account/loginPost');
$this->assertTrue($this->session->isLoggedIn());
$this->assertRedirect($this->stringContains('customer/account/'));
}
/**
* @magentoConfigFixture current_store customer/startup/redirect_dashboard 1
* @magentoConfigFixture current_store customer/captcha/enable 0
*
* @magentoDataFixture Magento/Customer/_files/customer.php
*
* @return void
*/
public function testNoFormKeyLoginPostAction(): void
{
$this->prepareRequest('customer@example.com', 'password');
$this->getRequest()->setPostValue('form_key', null);
$this->getRequest()->setParam(Url::REFERER_QUERY_PARAM_NAME, $this->urlEncoder->encode('test_redirect'));
$this->dispatch('customer/account/loginPost');
$this->assertFalse($this->session->isLoggedIn());
$this->assertRedirect($this->stringContains('customer/account/'));
$this->assertSessionMessages(
$this->equalTo([new Phrase('Invalid Form Key. Please refresh the page.')]),
MessageInterface::TYPE_ERROR
);
}
/**
* Prepare request
*
* @param string|null $email
* @param string|null $password
* @return void
*/
private function prepareRequest(?string $email, ?string $password): void
{
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
$this->getRequest()->setPostValue([
'login' => [
'username' => $email,
'password' => $password,
],
]);
}
}