8
8
9
9
use Magento \Customer \Api \Data \CustomerInterface as Customer ;
10
10
use Magento \Customer \Model \AccountManagement ;
11
+ use Magento \Framework \App \Config \ScopeConfigInterface ;
12
+ use Magento \Framework \App \ObjectManager ;
11
13
use Magento \Framework \Exception \InputException ;
12
14
use Magento \Framework \Webapi \Exception as HTTPExceptionCodes ;
13
15
use Magento \Newsletter \Model \Subscriber ;
14
16
use Magento \Security \Model \Config ;
17
+ use Magento \Store \Model \ScopeInterface ;
15
18
use Magento \TestFramework \Helper \Bootstrap ;
16
19
use Magento \TestFramework \Helper \Customer as CustomerHelper ;
17
20
use Magento \TestFramework \TestCase \WebapiAbstract ;
23
26
*/
24
27
class AccountManagementTest extends WebapiAbstract
25
28
{
26
- const SERVICE_VERSION = 'V1 ' ;
27
- const SERVICE_NAME = 'customerAccountManagementV1 ' ;
28
- const RESOURCE_PATH = '/V1/customers ' ;
29
+ public const SERVICE_VERSION = 'V1 ' ;
30
+ public const SERVICE_NAME = 'customerAccountManagementV1 ' ;
31
+ public const RESOURCE_PATH = '/V1/customers ' ;
29
32
30
33
/**
31
34
* Sample values for testing
32
35
*/
33
- const ATTRIBUTE_CODE = 'attribute_code ' ;
34
- const ATTRIBUTE_VALUE = 'attribute_value ' ;
36
+ public const ATTRIBUTE_CODE = 'attribute_code ' ;
37
+ public const ATTRIBUTE_VALUE = 'attribute_value ' ;
38
+
39
+ /**
40
+ * @var ObjectManager
41
+ */
42
+ private $ objectManager ;
35
43
36
44
/**
37
45
* @var AccountManagementInterface
@@ -86,6 +94,8 @@ class AccountManagementTest extends WebapiAbstract
86
94
*/
87
95
protected function setUp (): void
88
96
{
97
+ $ this ->objectManager = Bootstrap::getObjectManager ();
98
+
89
99
$ this ->accountManagement = Bootstrap::getObjectManager ()->get (
90
100
\Magento \Customer \Api \AccountManagementInterface::class
91
101
);
@@ -645,6 +655,7 @@ public function testIsReadonly()
645
655
646
656
public function testEmailAvailable ()
647
657
{
658
+ $ config = $ this ->objectManager ->get (ScopeConfigInterface::class);
648
659
$ customerData = $ this ->_createCustomer ();
649
660
650
661
$ serviceInfo = [
@@ -662,7 +673,18 @@ public function testEmailAvailable()
662
673
'customerEmail ' => $ customerData [Customer::EMAIL ],
663
674
'websiteId ' => $ customerData [Customer::WEBSITE_ID ],
664
675
];
665
- $ this ->assertFalse ($ this ->_webApiCall ($ serviceInfo , $ requestData ));
676
+
677
+ $ emailSetting = $ config ->getValue (
678
+ AccountManagement::GUEST_CHECKOUT_LOGIN_OPTION_SYS_CONFIG ,
679
+ ScopeInterface::SCOPE_WEBSITE ,
680
+ $ customerData [Customer::WEBSITE_ID ]
681
+ );
682
+
683
+ if (!$ emailSetting ) {
684
+ $ this ->assertTrue ($ this ->_webApiCall ($ serviceInfo , $ requestData ));
685
+ } else {
686
+ $ this ->assertFalse ($ this ->_webApiCall ($ serviceInfo , $ requestData ));
687
+ }
666
688
}
667
689
668
690
public function testEmailAvailableInvalidEmail ()
0 commit comments