Skip to content
Snippets Groups Projects
Commit b5a5c681 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #2944215 by jeqq, alexpott: Aliases generated by...

Issue #2944215 by jeqq, alexpott: Aliases generated by PathItem::generateSampleValue() should start with a slash
parent a819fdbb
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -89,7 +89,7 @@ public function postSave($update) {
*/
public static function generateSampleValue(FieldDefinitionInterface $field_definition) {
$random = new Random();
$values['alias'] = str_replace(' ', '-', strtolower($random->sentences(3)));
$values['alias'] = '/' . str_replace(' ', '-', strtolower($random->sentences(3)));
return $values;
}
......
......@@ -189,6 +189,18 @@ public function testPathItem() {
// Change the alias for the second node to a different one and try again.
$second_node->get('path')->alias = '/foobar';
$this->assertFalse($node->get('path')->equals($second_node->get('path')));
// Test the generateSampleValue() method.
$node = Node::create([
'title' => $this->randomString(),
'type' => 'foo',
'path' => ['alias' => '/foo'],
]);
$node->save();
$path_field = $node->get('path');
$path_field->generateSampleItems();
$node->save();
$this->assertStringStartsWith('/', $node->get('path')->alias);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment