public function testCheckPasswordChangeValid()
 {
     /** @var $validatorMock \Magento\Framework\Validator\DataObject|\PHPUnit_Framework_MockObject_MockObject */
     $validatorMock = $this->getMockBuilder('Magento\\Framework\\Validator\\DataObject')->disableOriginalConstructor()->setMethods([])->getMock();
     $this->validatorObjectFactoryMock->expects($this->once())->method('create')->willReturn($validatorMock);
     $this->validationRulesMock->expects($this->once())->method('addUserInfoRules')->with($validatorMock);
     $validatorMock->expects($this->once())->method('isValid')->willReturn(true);
     $newPassword = "******";
     $oldPassword = "******";
     $this->model->setPassword($newPassword)->setId(1)->setOrigData('password', $oldPassword);
     $this->encryptorMock->expects($this->atLeastOnce())->method('isValidHash')->will($this->onConsecutiveCalls(false, false, false));
     $this->resourceMock->expects($this->once())->method('getOldPasswords')->willReturn(['hash1', 'hash2']);
     $result = $this->model->validate();
     $this->assertTrue($result);
 }
Exemplo n.º 2
0
 /**
  * @dataProvider beforeSavePasswordInsecureDataProvider
  * @expectedException \Magento\Framework\Exception\LocalizedException
  * @expectedExceptionMessage Your password must include both numeric and alphabetic characters.
  * @magentoDbIsolation enabled
  * @param string $password
  */
 public function testBeforeSavePasswordInsecure($password)
 {
     $this->_model->setPassword($password);
     $this->_model->save();
 }