8
8
namespace Magento \Customer \Model \AccountManagement ;
9
9
10
10
use Magento \Customer \Api \AccountManagementInterface ;
11
+ use Magento \Customer \Api \CustomerRepositoryInterface ;
11
12
use Magento \Customer \Model \AccountManagement ;
12
13
use Magento \Framework \ObjectManagerInterface ;
13
14
use Magento \Store \Model \StoreManagerInterface ;
@@ -39,6 +40,9 @@ class ForgotPasswordTest extends TestCase
39
40
/** @var StoreManagerInterface */
40
41
private $ storeManager ;
41
42
43
+ /** @var CustomerRepositoryInterface */
44
+ private $ customerRepository ;
45
+
42
46
/**
43
47
* @inheritdoc
44
48
*/
@@ -50,6 +54,7 @@ protected function setUp(): void
50
54
$ this ->accountManagement = $ this ->objectManager ->get (AccountManagementInterface::class);
51
55
$ this ->transportBuilder = $ this ->objectManager ->get (TransportBuilderMock::class);
52
56
$ this ->storeManager = $ this ->objectManager ->get (StoreManagerInterface::class);
57
+ $ this ->customerRepository = $ this ->objectManager ->get (CustomerRepositoryInterface::class);
53
58
}
54
59
55
60
/**
@@ -76,6 +81,7 @@ public function testResetPasswordFlowStorefront(): void
76
81
{
77
82
// Forgot password section
78
83
$ email = 'customer@example.com ' ;
84
+ $ customerId = (int )$ this ->customerRepository ->get ($ email )->getId ();
79
85
$ result = $ this ->accountManagement ->initiatePasswordReset ($ email , AccountManagement::EMAIL_RESET );
80
86
$ message = $ this ->transportBuilder ->getSentMessage ();
81
87
$ messageContent = $ message ->getBody ()->getParts ()[0 ]->getRawContent ();
@@ -87,22 +93,20 @@ public function testResetPasswordFlowStorefront(): void
87
93
$ this ->accountManagement ->initiatePasswordReset ($ email , AccountManagement::EMAIL_RESET , $ websiteId );
88
94
89
95
// login with old credentials
90
- $ customer = $ this ->accountManagement ->authenticate ('customer@example.com ' , 'password ' );
91
-
92
96
$ this ->assertEquals (
93
- $ customer -> getId () ,
94
- $ this ->accountManagement ->authenticate (' customer@example.com ' , 'password ' )->getId ()
97
+ $ customerId ,
98
+ $ this ->accountManagement ->authenticate ($ email , 'password ' )->getId ()
95
99
);
96
100
97
101
// Change password
98
- $ this ->accountManagement ->changePassword (' customer@example.com ' , 'password ' , 'new_Password123 ' );
102
+ $ this ->accountManagement ->changePassword ($ email , 'password ' , 'new_Password123 ' );
99
103
100
104
// Login with new credentials
101
- $ this ->accountManagement ->authenticate (' customer@example.com ' , 'new_Password123 ' );
105
+ $ this ->accountManagement ->authenticate ($ email , 'new_Password123 ' );
102
106
103
107
$ this ->assertEquals (
104
- $ customer -> getId () ,
105
- $ this ->accountManagement ->authenticate (' customer@example.com ' , 'new_Password123 ' )->getId ()
108
+ $ customerId ,
109
+ $ this ->accountManagement ->authenticate ($ email , 'new_Password123 ' )->getId ()
106
110
);
107
111
}
108
112
}
0 commit comments