EditTest.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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\Form;
  7. use Magento\Customer\Model\AccountManagement;
  8. use Magento\Framework\App\Config\ScopeConfigInterface;
  9. /**
  10. * Test class for \Magento\Customer\Block\Form\Edit
  11. */
  12. class EditTest extends \PHPUnit\Framework\TestCase
  13. {
  14. /**
  15. * @var ScopeConfigInterface
  16. */
  17. protected $scopeConfigMock;
  18. /**
  19. * @var \Magento\Customer\Block\Form\Edit
  20. */
  21. protected $block;
  22. /**
  23. * Init mocks for tests
  24. * @return void
  25. */
  26. public function setUp()
  27. {
  28. $this->scopeConfigMock = $this->getMockBuilder(ScopeConfigInterface::class)
  29. ->disableOriginalConstructor()
  30. ->getMock();
  31. /** @var \Magento\Framework\View\Element\Template\Context | \PHPUnit_Framework_MockObject_MockObject $context */
  32. $context = $this->createMock(\Magento\Framework\View\Element\Template\Context::class);
  33. $context->expects($this->any())
  34. ->method('getScopeConfig')
  35. ->willReturn($this->scopeConfigMock);
  36. $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
  37. $this->block = $objectManager->getObject(
  38. \Magento\Customer\Block\Form\Edit::class,
  39. ['context' => $context]
  40. );
  41. }
  42. /**
  43. * @return void
  44. */
  45. public function testGetMinimumPasswordLength()
  46. {
  47. $minimumPasswordLength = '8';
  48. $this->scopeConfigMock->expects($this->once())
  49. ->method('getValue')
  50. ->with(AccountManagement::XML_PATH_MINIMUM_PASSWORD_LENGTH)
  51. ->willReturn($minimumPasswordLength);
  52. $this->assertEquals($minimumPasswordLength, $this->block->getMinimumPasswordLength());
  53. }
  54. /**
  55. * @return void
  56. */
  57. public function testGetRequiredCharacterClassesNumber()
  58. {
  59. $requiredCharacterClassesNumber = '4';
  60. $this->scopeConfigMock->expects($this->once())
  61. ->method('getValue')
  62. ->with(AccountManagement::XML_PATH_REQUIRED_CHARACTER_CLASSES_NUMBER)
  63. ->willReturn($requiredCharacterClassesNumber);
  64. $this->assertEquals($requiredCharacterClassesNumber, $this->block->getRequiredCharacterClassesNumber());
  65. }
  66. }