File tree Expand file tree Collapse file tree 2 files changed +77
-0
lines changed
app/code/Magento/CustomerGraphQl/etc/graphql
dev/tests/api-functional/testsuite/Magento/GraphQl/Customer Expand file tree Collapse file tree 2 files changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" ?>
2
+ <!--
3
+ /**
4
+ * Copyright © Magento, Inc. All rights reserved.
5
+ * See COPYING.txt for license details.
6
+ */
7
+ -->
8
+ <config xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance" xsi : noNamespaceSchemaLocation =" urn:magento:framework:Event/etc/events.xsd" >
9
+ <event name =" customer_login" >
10
+ <observer name =" customer_log_login" instance =" Magento\Customer\Observer\LogLastLoginAtObserver" />
11
+ </event >
12
+ </config >
Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * Copyright © Magento, Inc. All rights reserved.
4
+ * See COPYING.txt for license details.
5
+ */
6
+ declare (strict_types=1 );
7
+
8
+ namespace Magento \GraphQl \Customer ;
9
+
10
+ use Magento \Customer \Model \Logger ;
11
+ use Magento \Customer \Model \LogFactory ;
12
+ use Magento \TestFramework \Helper \Bootstrap ;
13
+ use Magento \TestFramework \TestCase \GraphQlAbstract ;
14
+
15
+ /**
16
+ * Customer log data logger test.
17
+ */
18
+ class LoggerTest extends GraphQlAbstract
19
+ {
20
+ /**
21
+ * Customer log data logger.
22
+ *
23
+ * @var Logger
24
+ */
25
+ protected $ logger ;
26
+
27
+ protected function setUp (): void
28
+ {
29
+ $ this ->logger = Bootstrap::getObjectManager ()->get (Logger::class);
30
+ }
31
+
32
+ /**
33
+ * Verify customer log after generate customer token
34
+ *
35
+ * @magentoApiDataFixture Magento/Customer/_files/customer.php
36
+ */
37
+ public function testGenerateCustomerValidToken ()
38
+ {
39
+ $ response = $ this ->graphQlMutation ($ this ->getQuery ());
40
+ $ this ->assertArrayHasKey ('generateCustomerToken ' , $ response );
41
+ $ this ->assertIsArray ($ response ['generateCustomerToken ' ]);
42
+
43
+ $ log = $ this ->logger ->get (1 );
44
+ $ this ->assertNotEmpty ($ log ->getLastLoginAt ());
45
+ }
46
+
47
+ /**
48
+ * @param string $email
49
+ * @param string $password
50
+ * @return string
51
+ */
52
+ private function getQuery (
string $ email =
'[email protected] ' ,
string $ password =
'password ' ) :
string
53
+ {
54
+ return <<<MUTATION
55
+ mutation {
56
+ generateCustomerToken(
57
+ email: " {$ email }"
58
+ password: " {$ password }"
59
+ ) {
60
+ token
61
+ }
62
+ }
63
+ MUTATION ;
64
+ }
65
+ }
You can’t perform that action at this time.
0 commit comments