Updated all the contrib modules to their latest versions.
[yaffs-website] / web / modules / contrib / pathauto / tests / src / Kernel / PathautoKernelTest.php
index b69d4373c956f602c92fa9aa353908f7b4b6a91e..1fffa4d081654ad911a77540b5b91ba9a536b9f4 100644 (file)
@@ -3,7 +3,6 @@
 namespace Drupal\Tests\pathauto\Kernel;
 
 use Drupal\Component\Utility\Html;
-use Drupal\Component\Utility\Unicode;
 use Drupal\Core\Language\Language;
 use Drupal\Core\Language\LanguageInterface;
 use Drupal\language\Entity\ConfigurableLanguage;
@@ -285,7 +284,7 @@ class PathautoKernelTest extends KernelTestBase {
     $this->assertEntityAlias($node, '/content/second-title');
     $this->assertNoAliasExists(array('alias' => '/content/first-title'));
 
-    // Test PATHAUTO_UPDATE_ACTION_LEAVE
+    // Test PATHAUTO_UPDATE_ACTION_LEAVE.
     $config->set('update_action', PathautoGeneratorInterface::UPDATE_ACTION_LEAVE);
     $config->save();
     $node->setTitle('Third title');
@@ -323,8 +322,8 @@ class PathautoKernelTest extends KernelTestBase {
   }
 
   /**
-   * Test that \Drupal::service('pathauto.generator')->createEntityAlias() will not create an alias for a pattern
-   * that does not get any tokens replaced.
+   * Test that \Drupal::service('pathauto.generator')->createEntityAlias() will
+   * not create an alias for a pattern that does not get any tokens replaced.
    */
   public function testNoTokensNoAlias() {
     $this->installConfig(['filter']);
@@ -365,12 +364,11 @@ class PathautoKernelTest extends KernelTestBase {
   function testParentChildPathTokens() {
     // First create a field which will be used to create the path. It must
     // begin with a letter.
-
     $this->installEntitySchema('taxonomy_term');
 
     Vocabulary::create(['vid' => 'tags'])->save();
 
-    $fieldname = 'a' . Unicode::strtolower($this->randomMachineName());
+    $fieldname = 'a' . mb_strtolower($this->randomMachineName());
     $field_storage = FieldStorageConfig::create(['entity_type' => 'taxonomy_term', 'field_name' => $fieldname, 'type' => 'string']);
     $field_storage->save();
     $field = FieldConfig::create(['field_storage' => $field_storage, 'bundle' => 'tags']);
@@ -391,11 +389,11 @@ class PathautoKernelTest extends KernelTestBase {
     // Create the child term.
     $child = Term::create(['vid' => 'tags', $fieldname => $this->randomMachineName(), 'parent' => $parent, 'name' => $this->randomMachineName()]);
     $child->save();
-    $this->assertEntityAlias($child, '/' . Unicode::strtolower($parent->getName() . '/' . $child->$fieldname->value));
+    $this->assertEntityAlias($child, '/' . mb_strtolower($parent->getName() . '/' . $child->$fieldname->value));
 
     // Re-saving the parent term should not modify the child term's alias.
     $parent->save();
-    $this->assertEntityAlias($child, '/' . Unicode::strtolower($parent->getName() . '/' . $child->$fieldname->value));
+    $this->assertEntityAlias($child, '/' . mb_strtolower($parent->getName() . '/' . $child->$fieldname->value));
   }
 
   /**
@@ -506,7 +504,7 @@ class PathautoKernelTest extends KernelTestBase {
   }
 
   /**
-   * Tests that enabled entity types genrates the necessary fields and plugins.
+   * Tests that enabled entity types generates the necessary fields and plugins.
    */
   public function testSettingChangeInvalidatesCache() {
 
@@ -547,6 +545,22 @@ class PathautoKernelTest extends KernelTestBase {
     $this->assertEntityAlias($node1, '/content/default-revision');
   }
 
+  /**
+   * Tests that the pathauto state property gets set to CREATED for new nodes.
+   *
+   * In some cases, this can trigger $node->path to be set up with no default
+   * value for the pathauto property.
+   */
+  public function testCreateNodeWhileAccessingPath() {
+    $node = Node::create([
+      'type' => 'article',
+      'title' => 'TestAlias',
+    ]);
+    $node->path->langcode;
+    $node->save();
+    $this->assertEntityAlias($node, '/content/testalias');
+  }
+
   /**
    * Creates a node programmatically.
    *