function PasswordItemTest::testPreSaveNewEmptyString
Same name and namespace in other branches
- 10 core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php \Drupal\KernelTests\Core\Field\FieldType\PasswordItemTest::testPreSaveNewEmptyString()
- 9 core/tests/Drupal/KernelTests/Core/Field/FieldType/PasswordItemTest.php \Drupal\KernelTests\Core\Field\FieldType\PasswordItemTest::testPreSaveNewEmptyString()
Tests pre save new empty string.
File
-
core/
tests/ Drupal/ KernelTests/ Core/ Field/ FieldType/ PasswordItemTest.php, line 92
Class
Namespace
Drupal\KernelTests\Core\Field\FieldTypeCode
public function testPreSaveNewEmptyString() : void {
$entity = EntityTest::create([
'name' => $this->randomString(),
]);
$entity->test_field = '';
$entity->save();
// The string starts with the portable password string and is a hash of an
// empty string.
$this->assertStringStartsWith('$2y$', $entity->test_field->value);
$this->assertTrue($this->container
->get('password')
->check('', $entity->test_field->value));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.