Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
AccountConfirmationTest.php
Go to the documentation of this file.
1 <?php
7 
12 
16 class AccountConfirmationTest extends \PHPUnit\Framework\TestCase
17 {
21  private $accountConfirmation;
22 
26  private $scopeConfig;
27 
31  private $registry;
32 
33  protected function setUp()
34  {
35  $this->scopeConfig = $this->createMock(ScopeConfigInterface::class);
36  $this->registry = $this->createMock(Registry::class);
37 
38  $this->accountConfirmation = new AccountConfirmation(
39  $this->scopeConfig,
40  $this->registry
41  );
42  }
43 
52  public function testIsConfirmationRequired(
55  $skipConfirmationIfEmail,
56  $isConfirmationEnabled,
57  $expected
58  ) {
59  $websiteId = 1;
60 
61  $this->scopeConfig->expects($this->any())
62  ->method('getValue')
63  ->with(
64  $this->accountConfirmation::XML_PATH_IS_CONFIRM,
65  ScopeInterface::SCOPE_WEBSITES,
67  )->willReturn($isConfirmationEnabled);
68 
69  $this->registry->expects($this->any())
70  ->method('registry')
71  ->with('skip_confirmation_if_email')
72  ->willReturn($skipConfirmationIfEmail);
73 
74  self::assertEquals(
75  $expected,
76  $this->accountConfirmation->isConfirmationRequired($websiteId, $customerId, $customerEmail)
77  );
78  }
79 
84  {
85  return [
86  [null, '[email protected]', null, true, true],
87  [null, '[email protected]', null, false, false],
88  [1, '[email protected]', '[email protected]', true, false],
89  [1, '[email protected]', '[email protected]', false, false],
90  [1, '[email protected]', '[email protected]', true, true],
91  ];
92  }
93 }
testIsConfirmationRequired( $customerId, $customerEmail, $skipConfirmationIfEmail, $isConfirmationEnabled, $expected)