1010use Magento \Backend \Model \Session ;
1111use Magento \Customer \Api \CustomerNameGenerationInterface ;
1212use Magento \Customer \Api \CustomerRepositoryInterface ;
13+ use Magento \Customer \Api \Data \CustomerInterface ;
1314use Magento \Customer \Model \Data \Customer as CustomerData ;
1415use Magento \Customer \Model \EmailNotification ;
1516use Magento \Framework \App \Area ;
1617use Magento \Framework \App \Request \Http as HttpRequest ;
18+ use Magento \Framework \Locale \ResolverInterface ;
1719use Magento \Framework \Mail \Template \TransportBuilder ;
1820use Magento \Framework \Mail \TransportInterface ;
1921use Magento \Framework \Message \MessageInterface ;
@@ -54,6 +56,12 @@ class SaveTest extends AbstractBackendController
5456 /** @var StoreManagerInterface */
5557 private $ storeManager ;
5658
59+ /** @var ResolverInterface */
60+ private $ localeResolver ;
61+
62+ /** @var CustomerInterface */
63+ private $ customer ;
64+
5765 /**
5866 * @inheritdoc
5967 */
@@ -65,6 +73,19 @@ protected function setUp(): void
6573 $ this ->subscriberFactory = $ this ->_objectManager ->get (SubscriberFactory::class);
6674 $ this ->session = $ this ->_objectManager ->get (Session::class);
6775 $ this ->storeManager = $ this ->_objectManager ->get (StoreManagerInterface::class);
76+ $ this ->localeResolver = $ this ->_objectManager ->get (ResolverInterface::class);
77+ }
78+
79+ /**
80+ * @inheritdoc
81+ */
82+ protected function tearDown (): void
83+ {
84+ if ($ this ->customer instanceof CustomerInterface) {
85+ $ this ->customerRepository ->delete ($ this ->customer );
86+ }
87+
88+ parent ::tearDown ();
6889 }
6990
7091 /**
@@ -418,6 +439,43 @@ public function testCreateSameEmailFormatDateError(): void
418439 $ this ->assertRedirect ($ this ->stringContains ($ this ->baseControllerUrl . 'new/key/ ' ));
419440 }
420441
442+ /**
443+ * @return void
444+ */
445+ public function testCreateCustomerByAdminWithLocaleGB (): void
446+ {
447+ $ this ->localeResolver ->setLocale ('en_GB ' );
448+ $ postData = array_replace_recursive (
449+ $ this ->getDefaultCustomerData (),
450+ [
451+ 'customer ' => [
452+ CustomerData::DOB => '24/10/1990 ' ,
453+ ],
454+ ]
455+ );
456+ $ expectedData = array_replace_recursive (
457+ $ postData ,
458+ [
459+ 'customer ' => [
460+ CustomerData::DOB => '1990-10-24 ' ,
461+ CustomerData::GENDER => '0 ' ,
462+ ],
463+ ]
464+ );
465+ unset($ expectedData ['customer ' ]['sendemail_store_id ' ]);
466+ $ this ->dispatchCustomerSave ($ postData );
467+ $ this ->assertSessionMessages (
468+ $ this ->equalTo ([(string )__ ('You saved the customer. ' )]),
469+ MessageInterface::TYPE_SUCCESS
470+ );
471+ $ this ->assertRedirect ($ this ->stringContains ($ this ->baseControllerUrl . 'index/key/ ' ));
472+ $ this ->assertCustomerData (
473+ $ postData ['customer ' ][CustomerData::EMAIL ],
474+ (int )$ postData ['customer ' ][CustomerData::WEBSITE_ID ],
475+ $ expectedData
476+ );
477+ }
478+
421479 /**
422480 * Default values for customer creation
423481 *
@@ -496,9 +554,8 @@ private function assertCustomerData(
496554 int $ customerWebsiteId ,
497555 array $ expectedData
498556 ): void {
499- /** @var CustomerData $customerData */
500- $ customerData = $ this ->customerRepository ->get ($ customerEmail , $ customerWebsiteId );
501- $ actualCustomerArray = $ customerData ->__toArray ();
557+ $ this ->customer = $ this ->customerRepository ->get ($ customerEmail , $ customerWebsiteId );
558+ $ actualCustomerArray = $ this ->customer ->__toArray ();
502559 foreach ($ expectedData ['customer ' ] as $ key => $ expectedValue ) {
503560 $ this ->assertEquals (
504561 $ expectedValue ,
0 commit comments