function PasswordItemTest::testPreSaveExceptionExisting
Same name in other branches
- 9 core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php \Drupal\KernelTests\Core\Field\FieldType\PasswordItemTest::testPreSaveExceptionExisting()
- 10 core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php \Drupal\KernelTests\Core\Field\FieldType\PasswordItemTest::testPreSaveExceptionExisting()
@covers ::preSave
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldType/ PasswordItemTest.php, line 178
Class
- PasswordItemTest
- @coversDefaultClass \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem @group Field
Namespace
Drupal\KernelTests\Core\Field\FieldTypeCode
public function testPreSaveExceptionExisting() : void {
$entity = EntityTest::create();
$entity->test_field = 'will_be_hashed';
$entity->save();
$this->assertNotEquals('will_be_hashed', $entity->test_field->value);
$this->expectException(EntityStorageException::class);
$this->expectExceptionMessage('Failed to hash the Test entity password.');
$entity->test_field = str_repeat('a', PasswordInterface::PASSWORD_MAX_LENGTH + 1);
$entity->save();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.