function PasswordItemTest::testPreSaveExistingEmptyString

Same name in other branches
  1. 10 core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php \Drupal\KernelTests\Core\Field\FieldType\PasswordItemTest::testPreSaveExistingEmptyString()
  2. 11.x core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php \Drupal\KernelTests\Core\Field\FieldType\PasswordItemTest::testPreSaveExistingEmptyString()

@covers ::preSave

File

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

Class

PasswordItemTest
@coversDefaultClass \Drupal\Core\Field\Plugin\Field\FieldType\PasswordItem @group Field

Namespace

Drupal\KernelTests\Core\Field\FieldType

Code

public function testPreSaveExistingEmptyString() {
    $entity = EntityTest::create();
    $entity->test_field = $this->randomString();
    $entity->save();
    $hashed_password = $entity->test_field->value;
    $entity->test_field = '';
    $entity->save();
    $this->assertSame($hashed_password, $entity->test_field->value);
}

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