ResetpasswordTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Customer\Test\Unit\Block\Account;
  7. use Magento\Customer\Model\AccountManagement;
  8. /**
  9. * Test class for \Magento\Customer\Block\Account\Resetpassword
  10. */
  11. class ResetpasswordTest extends \PHPUnit\Framework\TestCase
  12. {
  13. /**
  14. * @var \Magento\Framework\App\Config\ScopeConfigInterface | \PHPUnit_Framework_MockObject_MockObject
  15. */
  16. protected $scopeConfigMock;
  17. /**
  18. * @var \Magento\Customer\Block\Account\Resetpassword
  19. */
  20. protected $block;
  21. /**
  22. * Init mocks for tests
  23. * @return void
  24. */
  25. public function setUp()
  26. {
  27. $this->scopeConfigMock = $this->createPartialMock(\Magento\Framework\App\Config::class, ['getValue']);
  28. /** @var \Magento\Framework\View\Element\Template\Context | \PHPUnit_Framework_MockObject_MockObject $context */
  29. $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
  30. $context->expects($this->any())
  31. ->method('getScopeConfig')
  32. ->willReturn($this->scopeConfigMock);
  33. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  34. $this->block = $objectManager->getObject(
  35. \Magento\Customer\Block\Account\Resetpassword::class,
  36. ['context' => $context]
  37. );
  38. }
  39. /**
  40. * @return void
  41. */
  42. public function testGetMinimumPasswordLength()
  43. {
  44. $minimumPasswordLength = '8';
  45. $this->scopeConfigMock->expects($this->once())
  46. ->method('getValue')
  47. ->with(AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH)
  48. ->willReturn($minimumPasswordLength);
  49. $this->assertEquals($minimumPasswordLength, $this->block->getMinimumPasswordLength());
  50. }
  51. /**
  52. * @return void
  53. */
  54. public function testGetRequiredCharacterClassesNumber()
  55. {
  56. $requiredCharacterClassesNumber = '4';
  57. $this->scopeConfigMock->expects($this->once())
  58. ->method('getValue')
  59. ->with(AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER)
  60. ->willReturn($requiredCharacterClassesNumber);
  61. $this->assertEquals($requiredCharacterClassesNumber, $this->block->getRequiredCharacterClassesNumber());
  62. }
  63. }