Commit 13b9c4df authored by amateescu's avatar amateescu Committed by Berdir
Browse files

Issue #2946273 by rbayliss, amateescu, cgmonroe, seanB: Alias is not generated...

Issue #2946273 by rbayliss, amateescu, cgmonroe, seanB: Alias is not generated when Pathauto widget is hidden
parent 1b3a1c92
......@@ -42,7 +42,7 @@ class PathautoItem extends PathItem {
public function isEmpty() {
// Make sure that the pathauto state flag does not get lost if just that is
// changed.
return !$this->alias && !$this->get('pathauto')->hasValue();
return parent::isEmpty() && !$this->get('pathauto')->hasValue();
}
}
......@@ -443,10 +443,18 @@ class PathautoKernelTest extends KernelTestBase {
* Test programmatic entity creation for aliases.
*/
function testProgrammaticEntityCreation() {
$this->createPattern('taxonomy_term', '/[term:vocabulary]/[term:name]');
$node = $this->drupalCreateNode(['title' => 'Test node', 'path' => ['pathauto' => TRUE]]);
$this->assertEntityAlias($node, '/content/test-node');
// Check the case when the pathauto widget is hidden, so it can not populate
// the 'pathauto' property, and
// \Drupal\path\Plugin\Field\FieldType\PathFieldItemList::computeValue()
// populates the 'path' field with a 'langcode' property, for example during
// an AJAX call on the entity form.
$node = $this->drupalCreateNode(['title' => 'Test node 2', 'path' => ['langcode' => 'en']]);
$this->assertEntityAlias($node, '/content/test-node-2');
$this->createPattern('taxonomy_term', '/[term:vocabulary]/[term:name]');
$vocabulary = $this->addVocabulary(['name' => 'Tags']);
$term = $this->addTerm($vocabulary, ['name' => 'Test term', 'path' => ['pathauto' => TRUE]]);
$this->assertEntityAlias($term, '/tags/test-term');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment