function PasswordItemTest::testPreSaveExceptionNew

Tests pre save exception new.

@legacy-covers ::preSave

File

core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php, line 189

Class

PasswordItemTest
Tests Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem.

Namespace

Drupal\KernelTests\Core\Field\FieldType

Code

public function testPreSaveExceptionNew() : void {
  $entity = EntityTest::create();
  $entity->test_field = str_repeat('a', PasswordInterface::PASSWORD_MAX_LENGTH + 1);
  $this->expectException(EntityStorageException::class);
  $this->expectExceptionMessage('Failed to hash the Test entity password.');
  $entity->save();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.