diff --git a/tests/src/Functional/PathautoBulkUpdateTest.php b/tests/src/Functional/PathautoBulkUpdateTest.php index ecf70db..95e8d3e 100644 --- a/tests/src/Functional/PathautoBulkUpdateTest.php +++ b/tests/src/Functional/PathautoBulkUpdateTest.php @@ -98,7 +98,7 @@ class PathautoBulkUpdateTest extends BrowserTestBase { } $this->assertEntityAliasExists($this->adminUser); // This is the default "General discussion" forum. - $this->assertAliasExists(['source' => '/taxonomy/term/1']); + $this->assertAliasExists(['path' => '/taxonomy/term/1']); // Add a new node. $new_node = $this->drupalCreateNode(['path' => ['alias' => '', 'pathauto' => PathautoState::SKIP]]); diff --git a/tests/src/Functional/PathautoTestHelperTrait.php b/tests/src/Functional/PathautoTestHelperTrait.php index e4748af..3f91caa 100644 --- a/tests/src/Functional/PathautoTestHelperTrait.php +++ b/tests/src/Functional/PathautoTestHelperTrait.php @@ -77,8 +77,9 @@ trait PathautoTestHelperTrait { } public function saveAlias($source, $alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) { - \Drupal::service('path.alias_storage')->delete(['source' => $source, 'langcode' => $langcode]); - return \Drupal::service('path.alias_storage')->save($source, $alias, $langcode); + $alias_to_delete = \Drupal::service('entity_type.manager')->getStorage('path_alias')->loadByProperties(['path' => $source, 'langcode' => $langcode]); + \Drupal::service('entity_type.manager')->getStorage('path_alias')->delete($alias_to_delete); + return \Drupal::service('entity_type.manager')->getStorage('path_alias')->create(['path' => $source, 'alias' => $alias, 'langcode' => $langcode])->save(); } public function saveEntityAlias(EntityInterface $entity, $alias, $langcode = NULL) { @@ -98,7 +99,7 @@ trait PathautoTestHelperTrait { } public function assertEntityAliasExists(EntityInterface $entity) { - return $this->assertAliasExists(['source' => '/' . $entity->toUrl()->getInternalPath()]); + return $this->assertAliasExists(['path' => '/' . $entity->toUrl()->getInternalPath()]); } public function assertNoEntityAlias(EntityInterface $entity, $langcode = NULL) { @@ -110,7 +111,7 @@ trait PathautoTestHelperTrait { } public function assertNoEntityAliasExists(EntityInterface $entity, $alias = NULL) { - $path = ['source' => '/' . $entity->toUrl()->getInternalPath()]; + $path = ['path' => '/' . $entity->toUrl()->getInternalPath()]; if (!empty($alias)) { $path['alias'] = $alias; } @@ -118,29 +119,29 @@ trait PathautoTestHelperTrait { } public function assertAlias($source, $expected_alias, $langcode = Language::LANGCODE_NOT_SPECIFIED) { - \Drupal::service('path.alias_manager')->cacheClear($source); + \Drupal::service('path_alias.manager')->cacheClear($source); $entity_type_manager = \Drupal::entityTypeManager(); if ($entity_type_manager->hasDefinition('path_alias')) { $entity_type_manager->getStorage('path_alias')->resetCache(); } - $this->assertEquals($expected_alias, \Drupal::service('path.alias_manager')->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.", + $this->assertEquals($expected_alias, \Drupal::service('path_alias.manager')->getAliasByPath($source, $langcode), t("Alias for %source with language '@language' is correct.", ['%source' => $source, '@language' => $langcode])); } public function assertAliasExists($conditions) { - $path = \Drupal::service('path.alias_storage')->load($conditions); + $path = \Drupal::service('entity_type.manager')->getStorage('path_alias')->loadByProperties($conditions); $this->assertNotEmpty($path, t('Alias with conditions @conditions found.', ['@conditions' => var_export($conditions, TRUE)])); return $path; } public function assertNoAliasExists($conditions) { - $alias = \Drupal::service('path.alias_storage')->load($conditions); + $alias = \Drupal::service('entity_type.manager')->getStorage('path_alias')->loadByProperties($conditions); $this->assertFalse($alias, t('Alias with conditions @conditions not found.', ['@conditions' => var_export($conditions, TRUE)])); } public function deleteAllAliases() { \Drupal::service('pathauto.alias_storage_helper')->deleteAll(); - \Drupal::service('path.alias_manager')->cacheClear(); + \Drupal::service('path_alias.manager')->cacheClear(); } /** diff --git a/tests/src/FunctionalJavascript/PathautoLocaleTest.php b/tests/src/FunctionalJavascript/PathautoLocaleTest.php index a860684..21d9275 100644 --- a/tests/src/FunctionalJavascript/PathautoLocaleTest.php +++ b/tests/src/FunctionalJavascript/PathautoLocaleTest.php @@ -60,8 +60,8 @@ class PathautoLocaleTest extends WebDriverTestBase { ]], ]; $node = $this->drupalCreateNode($node); - $english_alias = \Drupal::service('path.alias_storage')->load(['alias' => '/english-node', 'langcode' => 'en']); - $this->assertTrue($english_alias, 'Alias created with proper language.'); + $english_alias = \Drupal::service('entity_type.manager')->getStorage('path_alias')->loadByProperties(['alias' => '/english-node', 'langcode' => 'en']); + $this->assertNotEmpty($english_alias, 'Alias created with proper language.'); // Also save a French alias that should not be left alone, even though // it is the newer alias. diff --git a/tests/src/FunctionalJavascript/PathautoUiTest.php b/tests/src/FunctionalJavascript/PathautoUiTest.php index c809326..722508c 100644 --- a/tests/src/FunctionalJavascript/PathautoUiTest.php +++ b/tests/src/FunctionalJavascript/PathautoUiTest.php @@ -199,7 +199,7 @@ class PathautoUiTest extends WebDriverTestBase { $this->drupalPostForm(NULL, [], t('Delete')); $this->assertSession()->pageTextContains('The pathauto pattern Test has been deleted.'); - $this->assertFalse(PathautoPattern::load('page_pattern')); + $this->assertEmpty(PathautoPattern::load('page_pattern')); } } diff --git a/tests/src/Kernel/PathautoKernelTest.php b/tests/src/Kernel/PathautoKernelTest.php index c7e9308..430256b 100644 --- a/tests/src/Kernel/PathautoKernelTest.php +++ b/tests/src/Kernel/PathautoKernelTest.php @@ -258,10 +258,10 @@ class PathautoKernelTest extends KernelTestBase { $this->saveAlias('/node/10', '/node-10-alias'); \Drupal::service('pathauto.alias_storage_helper')->deleteBySourcePrefix('/node/1'); - $this->assertNoAliasExists(['source' => "/node/1"]); - $this->assertNoAliasExists(['source' => "/node/1/view"]); - $this->assertAliasExists(['source' => "/node/2"]); - $this->assertAliasExists(['source' => "/node/10"]); + $this->assertNoAliasExists(['path' => "/node/1"]); + $this->assertNoAliasExists(['path' => "/node/1/view"]); + $this->assertAliasExists(['path' => "/node/2"]); + $this->assertAliasExists(['path' => "/node/10"]); } /** @@ -292,7 +292,7 @@ class PathautoKernelTest extends KernelTestBase { $node->setTitle('Third title'); $node->save(); $this->assertEntityAlias($node, '/content/third-title'); - $this->assertAliasExists(['source' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); + $this->assertAliasExists(['path' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); $config->set('update_action', PathautoGeneratorInterface::UPDATE_ACTION_DELETE); $config->save(); @@ -301,8 +301,8 @@ class PathautoKernelTest extends KernelTestBase { $this->assertEntityAlias($node, '/content/fourth-title'); $this->assertNoAliasExists(['alias' => '/content/third-title']); // The older second alias is not deleted yet. - $older_path = $this->assertAliasExists(['source' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); - \Drupal::service('path.alias_storage')->delete($older_path); + $older_path = $this->assertAliasExists(['path' => '/' . $node->toUrl()->getInternalPath(), 'alias' => '/content/second-title']); + \Drupal::service('entity_type.manager')->getStorage('path_alias')->delete($older_path); $config->set('update_action', PathautoGeneratorInterface::UPDATE_ACTION_NO_NEW); $config->save();