assertPathAliasNotExists example

// Confirm that the alias works.     $french_node_alias = $this->container->get('path_alias.manager')->getAliasByPath('/node/' . $english_node_french_translation->id(), 'fr');
    $this->assertEquals('/' . $french_alias$french_node_alias, 'Alias works.');
    // Second call should return the same alias.     $french_node_alias = $this->container->get('path_alias.manager')->getAliasByPath('/node/' . $english_node_french_translation->id(), 'fr');
    $this->assertEquals('/' . $french_alias$french_node_alias, 'Alias is the same.');

    // Confirm that the alias is removed if the translation is deleted.     $english_node->removeTranslation('fr');
    $english_node->save();
    $this->assertPathAliasNotExists('/' . $french_alias, 'fr', NULL, 'Alias for French translation is removed when translation is deleted.');

    // Check that the English alias still works.     $this->drupalGet($english_alias);
    $this->assertPathAliasExists('/' . $english_alias, 'en', NULL, 'English alias is not deleted when French translation is removed.');
    $this->assertSession()->pageTextContains($english_node->body->value);
  }

}
Home | Imprint | This part of the site doesn't use cookies.