objectManager = Bootstrap::getObjectManager(); $this->share = $this->objectManager->get(Share::class); $this->websiteRepository = $this->objectManager->create(WebsiteRepositoryInterface::class); } /** * @return void */ public function testGetSharedWebsiteIds(): void { $websiteIds = $this->share->getSharedWebsiteIds(42); $this->assertEquals([42], $websiteIds); } /** * @magentoDataFixture Magento/Store/_files/core_second_third_fixturestore.php * @magentoConfigFixture current_store customer/account_share/scope 0 * * @return void */ public function testGetSharedWebsiteIdsMultipleSites(): void { $expectedIds[] = $this->websiteRepository->get('base')->getId(); $expectedIds[] = $this->websiteRepository->get('secondwebsite')->getId(); $expectedIds[] = $this->websiteRepository->get('thirdwebsite')->getId(); $websiteIds = $this->share->getSharedWebsiteIds(42); $this->assertEquals($expectedIds, $websiteIds); } /** * @magentoConfigFixture current_store customer/account_share/scope 1 * @magentoDataFixture Magento/Customer/_files/customer.php * @magentoDataFixture Magento/Customer/_files/customer_for_second_website.php * @magentoDbIsolation enabled * * @return void */ public function testEnableGlobalAccountShareScope(): void { $message = 'We can\'t share customer accounts globally when the accounts share' . ' identical email addresses on more than one website.'; $this->expectExceptionObject(new LocalizedException(__($message))); $this->share->setPath(Share::XML_PATH_CUSTOMER_ACCOUNT_SHARE)->setValue((string)Share::SHARE_GLOBAL) ->beforeSave(); } }