Commit 5b29a5f8 authored by CeraRose's avatar CeraRose Committed by Berdir

Issue #2989310 by JKerschner: Adjust comments and whitespace to more closely match coding standards

parent 2705954f
...@@ -133,7 +133,7 @@ function hook_pathauto_pattern_alter(&$pattern, array $context) { ...@@ -133,7 +133,7 @@ function hook_pathauto_pattern_alter(&$pattern, array $context) {
* - 'pattern': A string of the pattern used for aliasing the object. * - 'pattern': A string of the pattern used for aliasing the object.
*/ */
function hook_pathauto_alias_alter(&$alias, array &$context) { function hook_pathauto_alias_alter(&$alias, array &$context) {
// Add a suffix so that all aliases get saved as 'content/my-title.html' // Add a suffix so that all aliases get saved as 'content/my-title.html'.
$alias .= '.html'; $alias .= '.html';
// Force all aliases to be saved as language neutral. // Force all aliases to be saved as language neutral.
...@@ -143,7 +143,7 @@ function hook_pathauto_alias_alter(&$alias, array &$context) { ...@@ -143,7 +143,7 @@ function hook_pathauto_alias_alter(&$alias, array &$context) {
/** /**
* Alter the list of punctuation characters for Pathauto control. * Alter the list of punctuation characters for Pathauto control.
* *
* @param $punctuation * @param array $punctuation
* An array of punctuation to be controlled by Pathauto during replacement * An array of punctuation to be controlled by Pathauto during replacement
* keyed by punctuation name. Each punctuation record should be an array * keyed by punctuation name. Each punctuation record should be an array
* with the following key/value pairs: * with the following key/value pairs:
......
...@@ -14,7 +14,7 @@ use Drupal\pathauto\Entity\PathautoPattern; ...@@ -14,7 +14,7 @@ use Drupal\pathauto\Entity\PathautoPattern;
* Implements hook_install(). * Implements hook_install().
*/ */
function pathauto_install() { function pathauto_install() {
// Set the weight to 1 // Set the weight to 1.
module_set_weight('pathauto', 1); module_set_weight('pathauto', 1);
// Ensure the url_alias table exists. // Ensure the url_alias table exists.
...@@ -168,7 +168,8 @@ function pathauto_update_8100() { ...@@ -168,7 +168,8 @@ function pathauto_update_8100() {
continue; continue;
} }
// This is a pattern for a bundle and a language, such as "node_article_es". // This is a pattern for a bundle and a language, such as
// "node_article_es".
$pattern = PathautoPattern::create([ $pattern = PathautoPattern::create([
'id' => $entity_type . '_' . $extracted_bundle . '_' . str_replace('-', '_', $langcode), 'id' => $entity_type . '_' . $extracted_bundle . '_' . str_replace('-', '_', $langcode),
'label' => $entity_label . ' ' . $bundle_info[$extracted_bundle]['label'] . ' ' . $language->getName(), 'label' => $entity_label . ' ' . $bundle_info[$extracted_bundle]['label'] . ' ' . $language->getName(),
......
...@@ -3,4 +3,3 @@ entity.pathauto_pattern.add_form: ...@@ -3,4 +3,3 @@ entity.pathauto_pattern.add_form:
title: 'Add Pathauto pattern' title: 'Add Pathauto pattern'
appears_on: appears_on:
- entity.pathauto_pattern.collection - entity.pathauto_pattern.collection
...@@ -104,7 +104,7 @@ class AliasCleaner implements AliasCleanerInterface { ...@@ -104,7 +104,7 @@ class AliasCleaner implements AliasCleanerInterface {
// Trim duplicate, leading, and trailing separators. Do this before cleaning // Trim duplicate, leading, and trailing separators. Do this before cleaning
// backslashes since a pattern like "[token1]/[token2]-[token3]/[token4]" // backslashes since a pattern like "[token1]/[token2]-[token3]/[token4]"
// could end up like "value1/-/value2" and if backslashes were cleaned first // could end up like "value1/-/value2" and if backslashes were cleaned first
// this would result in a duplicate blackslash. // this would result in a duplicate backslash.
$output = $this->getCleanSeparators($output); $output = $this->getCleanSeparators($output);
// Trim duplicate, leading, and trailing backslashes. // Trim duplicate, leading, and trailing backslashes.
......
...@@ -72,8 +72,8 @@ interface AliasCleanerInterface { ...@@ -72,8 +72,8 @@ interface AliasCleanerInterface {
/** /**
* Return an array of arrays for punctuation values. * Return an array of arrays for punctuation values.
* *
* Returns an array of arrays for punctuation values keyed by a name, including * Returns an array of arrays for punctuation values keyed by a name,
* the value and a textual description. * including the value and a textual description.
* Can and should be expanded to include "all" non text punctuation values. * Can and should be expanded to include "all" non text punctuation values.
* *
* @return array * @return array
......
<?php <?php
namespace Drupal\pathauto; namespace Drupal\pathauto;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
...@@ -94,7 +95,6 @@ interface AliasStorageHelperInterface { ...@@ -94,7 +95,6 @@ interface AliasStorageHelperInterface {
*/ */
public function loadBySourcePrefix($source); public function loadBySourcePrefix($source);
/** /**
* Returns the count of url aliases for the source. * Returns the count of url aliases for the source.
* *
......
...@@ -13,7 +13,8 @@ interface AliasTypeBatchUpdateInterface extends AliasTypeInterface { ...@@ -13,7 +13,8 @@ interface AliasTypeBatchUpdateInterface extends AliasTypeInterface {
* @param string $action * @param string $action
* One of: * One of:
* - 'create' to generate a URL alias for paths having none. * - 'create' to generate a URL alias for paths having none.
* - 'update' to recreate the URL alias for paths already having one, useful if the pattern changed. * - 'update' to recreate the URL alias for paths already having one, useful
* if the pattern changed.
* - 'all' to do both actions above at the same time. * - 'all' to do both actions above at the same time.
* @param array $context * @param array $context
* Batch context. * Batch context.
......
...@@ -38,7 +38,7 @@ class AliasUniquifier implements AliasUniquifierInterface { ...@@ -38,7 +38,7 @@ class AliasUniquifier implements AliasUniquifierInterface {
/** /**
* The route provider service. * The route provider service.
* *
* @var \Drupal\Core\Routing\RouteProviderInterface. * @var \Drupal\Core\Routing\RouteProviderInterface
*/ */
protected $routeProvider; protected $routeProvider;
...@@ -60,6 +60,8 @@ class AliasUniquifier implements AliasUniquifierInterface { ...@@ -60,6 +60,8 @@ class AliasUniquifier implements AliasUniquifierInterface {
* The module handler. * The module handler.
* @param \Drupal\Core\Routing\RouteProviderInterface $route_provider * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
* The route provider service. * The route provider service.
* @param \Drupal\Core\Path\AliasManagerInterface $alias_manager
* The alias manager.
*/ */
public function __construct(ConfigFactoryInterface $config_factory, AliasStorageHelperInterface $alias_storage_helper, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, AliasManagerInterface $alias_manager) { public function __construct(ConfigFactoryInterface $config_factory, AliasStorageHelperInterface $alias_storage_helper, ModuleHandlerInterface $module_handler, RouteProviderInterface $route_provider, AliasManagerInterface $alias_manager) {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
......
<?php <?php
namespace Drupal\pathauto; namespace Drupal\pathauto;
use Drupal\Core\Language\LanguageInterface; use Drupal\Core\Language\LanguageInterface;
/** /**
......
...@@ -21,9 +21,9 @@ class AliasType extends Plugin { ...@@ -21,9 +21,9 @@ class AliasType extends Plugin {
/** /**
* The human-readable name of the action plugin. * The human-readable name of the action plugin.
* *
* @ingroup plugin_translatable
*
* @var \Drupal\Core\Annotation\Translation * @var \Drupal\Core\Annotation\Translation
*
* @ingroup plugin_translatable
*/ */
public $label; public $label;
......
...@@ -13,11 +13,25 @@ use Drupal\pathauto\AliasTypeManager; ...@@ -13,11 +13,25 @@ use Drupal\pathauto\AliasTypeManager;
*/ */
class PathautoSettingsCacheTag implements EventSubscriberInterface { class PathautoSettingsCacheTag implements EventSubscriberInterface {
/**
* @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/
protected $entityFieldManager; protected $entityFieldManager;
/**
* The alias type manager.
*
* @var \Drupal\pathauto\AliasTypeManager
*/
protected $aliasTypeManager; protected $aliasTypeManager;
/** /**
* Constructs a PathautoSettingsCacheTag object. * Constructs a PathautoSettingsCacheTag object.
*
* @param \Drupal\Core\Entity\EntityFieldManagerInterface $entity_field_manager
* The entity field manager.
* @param \Drupal\pathauto\AliasTypeManager $alias_type_manager
* The alias type manager.
*/ */
public function __construct(EntityFieldManagerInterface $entity_field_manager, AliasTypeManager $alias_type_manager) { public function __construct(EntityFieldManagerInterface $entity_field_manager, AliasTypeManager $alias_type_manager) {
$this->entityFieldManager = $entity_field_manager; $this->entityFieldManager = $entity_field_manager;
......
...@@ -35,7 +35,7 @@ class PathautoSettingsForm extends ConfigFormBase { ...@@ -35,7 +35,7 @@ class PathautoSettingsForm extends ConfigFormBase {
protected $aliasTypeManager; protected $aliasTypeManager;
/** /**
* {@inheritDoc} * {@inheritdoc}
*/ */
public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, AliasTypeManager $alias_type_manager) { public function __construct(ConfigFactoryInterface $config_factory, EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, AliasTypeManager $alias_type_manager) {
parent::__construct($config_factory); parent::__construct($config_factory);
...@@ -45,7 +45,7 @@ class PathautoSettingsForm extends ConfigFormBase { ...@@ -45,7 +45,7 @@ class PathautoSettingsForm extends ConfigFormBase {
} }
/** /**
* {@inheritDoc} * {@inheritdoc}
*/ */
public static function create(ContainerInterface $container) { public static function create(ContainerInterface $container) {
return new static( return new static(
......
...@@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface; ...@@ -16,6 +16,8 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
class PatternEditForm extends EntityForm { class PatternEditForm extends EntityForm {
/** /**
* The alias type manager.
*
* @var \Drupal\pathauto\AliasTypeManager * @var \Drupal\pathauto\AliasTypeManager
*/ */
protected $manager; protected $manager;
...@@ -33,11 +35,15 @@ class PatternEditForm extends EntityForm { ...@@ -33,11 +35,15 @@ class PatternEditForm extends EntityForm {
protected $entityTypeBundleInfo; protected $entityTypeBundleInfo;
/** /**
* The entity manager service.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface * @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/ */
protected $entityTypeManager; protected $entityTypeManager;
/** /**
* The language manager service.
*
* @var \Drupal\Core\Language\LanguageManagerInterface * @var \Drupal\Core\Language\LanguageManagerInterface
*/ */
protected $languageManager; protected $languageManager;
...@@ -58,9 +64,13 @@ class PatternEditForm extends EntityForm { ...@@ -58,9 +64,13 @@ class PatternEditForm extends EntityForm {
* PatternEditForm constructor. * PatternEditForm constructor.
* *
* @param \Drupal\pathauto\AliasTypeManager $manager * @param \Drupal\pathauto\AliasTypeManager $manager
* The alias type manager.
* @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info * @param \Drupal\Core\Entity\EntityTypeBundleInfoInterface $entity_type_bundle_info
* The entity type bundle info service.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager service.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager service.
*/ */
function __construct(AliasTypeManager $manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager) { function __construct(AliasTypeManager $manager, EntityTypeBundleInfoInterface $entity_type_bundle_info, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager) {
$this->manager = $manager; $this->manager = $manager;
...@@ -70,7 +80,7 @@ class PatternEditForm extends EntityForm { ...@@ -70,7 +80,7 @@ class PatternEditForm extends EntityForm {
} }
/** /**
* {@inheritDoc} * {@inheritdoc}
*/ */
public function buildForm(array $form, FormStateInterface $form_state) { public function buildForm(array $form, FormStateInterface $form_state) {
...@@ -199,7 +209,7 @@ class PatternEditForm extends EntityForm { ...@@ -199,7 +209,7 @@ class PatternEditForm extends EntityForm {
} }
/** /**
* {@inheritDoc} * {@inheritdoc}
*/ */
public function buildEntity(array $form, FormStateInterface $form_state) { public function buildEntity(array $form, FormStateInterface $form_state) {
/** @var \Drupal\pathauto\PathautoPatternInterface $entity */ /** @var \Drupal\pathauto\PathautoPatternInterface $entity */
...@@ -259,7 +269,7 @@ class PatternEditForm extends EntityForm { ...@@ -259,7 +269,7 @@ class PatternEditForm extends EntityForm {
} }
/** /**
* {@inheritDoc} * {@inheritdoc}
*/ */
public function save(array $form, FormStateInterface $form_state) { public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state); parent::save($form, $form_state);
......
...@@ -7,7 +7,7 @@ use Drupal\path\Plugin\Field\FieldType\PathFieldItemList; ...@@ -7,7 +7,7 @@ use Drupal\path\Plugin\Field\FieldType\PathFieldItemList;
class PathautoFieldItemList extends PathFieldItemList { class PathautoFieldItemList extends PathFieldItemList {
/** /**
* @inheritDoc * @{inheritdoc}
*/ */
protected function delegateMethod($method) { protected function delegateMethod($method) {
// @todo Workaround until this is fixed, see // @todo Workaround until this is fixed, see
...@@ -27,7 +27,7 @@ class PathautoFieldItemList extends PathFieldItemList { ...@@ -27,7 +27,7 @@ class PathautoFieldItemList extends PathFieldItemList {
} }
/** /**
* @inheritDoc * @{inheritdoc}
*/ */
protected function computeValue() { protected function computeValue() {
parent::computeValue(); parent::computeValue();
......
...@@ -86,12 +86,16 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -86,12 +86,16 @@ class PathautoGenerator implements PathautoGeneratorInterface {
protected $messenger; protected $messenger;
/** /**
* The token entity mapper.
*
* @var \Drupal\token\TokenEntityMapperInterface * @var \Drupal\token\TokenEntityMapperInterface
*/ */
protected $tokenEntityMapper; protected $tokenEntityMapper;
/** /**
* @var Drupal\Core\Entity\EntityTypeManagerInterface * The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/ */
protected $entityTypeManager; protected $entityTypeManager;
...@@ -114,10 +118,12 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -114,10 +118,12 @@ class PathautoGenerator implements PathautoGeneratorInterface {
* The messenger service. * The messenger service.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service. * The string translation service.
* @param Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * @param \Drupal\token\TokenEntityMapperInterface $token_entity_mapper
* The entity type manager * The token entity mapper.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/ */
public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, Token $token, AliasCleanerInterface $alias_cleaner, AliasStorageHelperInterface $alias_storage_helper, AliasUniquifierInterface $alias_uniquifier, MessengerInterface $messenger, TranslationInterface $string_translation, TokenEntityMapperInterface $token_entity_mappper, EntityTypeManagerInterface $entity_type_manager) { public function __construct(ConfigFactoryInterface $config_factory, ModuleHandlerInterface $module_handler, Token $token, AliasCleanerInterface $alias_cleaner, AliasStorageHelperInterface $alias_storage_helper, AliasUniquifierInterface $alias_uniquifier, MessengerInterface $messenger, TranslationInterface $string_translation, TokenEntityMapperInterface $token_entity_mapper, EntityTypeManagerInterface $entity_type_manager) {
$this->configFactory = $config_factory; $this->configFactory = $config_factory;
$this->moduleHandler = $module_handler; $this->moduleHandler = $module_handler;
$this->token = $token; $this->token = $token;
...@@ -126,7 +132,7 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -126,7 +132,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
$this->aliasUniquifier = $alias_uniquifier; $this->aliasUniquifier = $alias_uniquifier;
$this->messenger = $messenger; $this->messenger = $messenger;
$this->stringTranslation = $string_translation; $this->stringTranslation = $string_translation;
$this->tokenEntityMapper = $token_entity_mappper; $this->tokenEntityMapper = $token_entity_mapper;
$this->entityTypeManager = $entity_type_manager; $this->entityTypeManager = $entity_type_manager;
} }
...@@ -239,7 +245,7 @@ class PathautoGenerator implements PathautoGeneratorInterface { ...@@ -239,7 +245,7 @@ class PathautoGenerator implements PathautoGeneratorInterface {
} }
/** /**
* Loads pathauto patterns for a given entity type ID * Loads pathauto patterns for a given entity type ID.
* *
* @param string $entity_type_id * @param string $entity_type_id
* An entity type ID. * An entity type ID.
......
...@@ -49,6 +49,7 @@ interface PathautoGeneratorInterface { ...@@ -49,6 +49,7 @@ interface PathautoGeneratorInterface {
* *
* @param \Drupal\Core\Entity\EntityInterface $entity * @param \Drupal\Core\Entity\EntityInterface $entity
* An entity. * An entity.
*
* @return \Drupal\pathauto\PathautoPatternInterface|null * @return \Drupal\pathauto\PathautoPatternInterface|null
*/ */
public function getPatternByEntity(EntityInterface $entity); public function getPatternByEntity(EntityInterface $entity);
......
...@@ -88,6 +88,7 @@ class PathautoState extends TypedData { ...@@ -88,6 +88,7 @@ class PathautoState extends TypedData {
/** /**
* Returns the key value collection that should be used for the given entity. * Returns the key value collection that should be used for the given entity.
*
* @return string * @return string
*/ */
protected function getCollection() { protected function getCollection() {
......
...@@ -26,6 +26,8 @@ class EntityAliasTypeDeriver extends DeriverBase implements ContainerDeriverInte ...@@ -26,6 +26,8 @@ class EntityAliasTypeDeriver extends DeriverBase implements ContainerDeriverInte
protected $entityTypeManager; protected $entityTypeManager;
/** /**
* The entity field manager.
*
* @var \Drupal\Core\Entity\EntityFieldManagerInterface * @var \Drupal\Core\Entity\EntityFieldManagerInterface
*/ */
protected $entityFieldManager; protected $entityFieldManager;
...@@ -44,7 +46,7 @@ class EntityAliasTypeDeriver extends DeriverBase implements ContainerDeriverInte ...@@ -44,7 +46,7 @@ class EntityAliasTypeDeriver extends DeriverBase implements ContainerDeriverInte
* The entity field manager. * The entity field manager.
* @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation
* The string translation service. * The string translation service.
* @apram \Drupal\Token\TokenEntityMapperInterface $token_entity_mapper * @param \Drupal\Token\TokenEntityMapperInterface $token_entity_mapper
* The token entity mapper. * The token entity mapper.
*/ */
public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, TranslationInterface $string_translation, TokenEntityMapperInterface $token_entity_mapper) { public function __construct(EntityTypeManagerInterface $entity_type_manager, EntityFieldManagerInterface $entity_field_manager, TranslationInterface $string_translation, TokenEntityMapperInterface $token_entity_mapper) {
......
...@@ -151,12 +151,15 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt ...@@ -151,12 +151,15 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt
case 'create': case 'create':
$query->isNull('ua.source'); $query->isNull('ua.source');
break; break;
case 'update': case 'update':
$query->isNotNull('ua.source'); $query->isNotNull('ua.source');
break; break;
case 'all': case 'all':
// Nothing to do. We want all paths. // Nothing to do. We want all paths.
break; break;
default: default:
// Unknown action. Abort! // Unknown action. Abort!
return; return;
...@@ -255,7 +258,7 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt ...@@ -255,7 +258,7 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt
* An optional array of additional options. * An optional array of additional options.
* *
* @return int * @return int
* The number of updated URL aliases. * The number of updated URL aliases.
*/ */
protected function bulkUpdate(array $ids, array $options = array()) { protected function bulkUpdate(array $ids, array $options = array()) {
$options += array('message' => FALSE); $options += array('message' => FALSE);
...@@ -330,5 +333,4 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt ...@@ -330,5 +333,4 @@ class EntityAliasTypeBase extends ContextAwarePluginBase implements AliasTypeInt
return $this; return $this;
} }
} }
...@@ -44,7 +44,7 @@ class PathautoBulkUpdateTest extends WebTestBase { ...@@ -44,7 +44,7 @@ class PathautoBulkUpdateTest extends WebTestBase {
protected $patterns; protected $patterns;
/** /**
* {inheritdoc} * {@inheritdoc}
*/ */
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
...@@ -103,7 +103,7 @@ class PathautoBulkUpdateTest extends WebTestBase { ...@@ -103,7 +103,7 @@ class PathautoBulkUpdateTest extends WebTestBase {
$this->assertText('No new URL aliases to generate.'); $this->assertText('No new URL aliases to generate.');
$this->assertNoEntityAliasExists($new_node); $this->assertNoEntityAliasExists($new_node);
// Make sure existing aliases can be overriden. // Make sure existing aliases can be overridden.
$this->drupalPostForm('admin/config/search/path/settings', ['update_action' => PathautoGeneratorInterface::UPDATE_ACTION_DELETE], t('Save configuration')); $this->drupalPostForm('admin/config/search/path/settings', ['update_action' => PathautoGeneratorInterface::UPDATE_ACTION_DELETE], t('Save configuration'));
// Patterns did not change, so no aliases should be regenerated. // Patterns did not change, so no aliases should be regenerated.
...@@ -111,16 +111,17 @@ class PathautoBulkUpdateTest extends WebTestBase { ...@@ -111,16 +111,17 @@ class PathautoBulkUpdateTest extends WebTestBase {
$this->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update')); $this->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this->assertText('No new URL aliases to generate.'); $this->assertText('No new URL aliases to generate.');
// Update the node pattern, and leave other patterns alone. Existing nodes should get a new alias, // Update the node pattern, and leave other patterns alone. Existing nodes
// except the node above whose alias is manually set. Other aliases must be left alone. // should get a new alias, except the node above whose alias is manually
// set. Other aliases must be left alone.
$this->patterns['node']->delete(); $this->patterns['node']->delete();
$this->patterns['node'] = $this->createPattern('node', '/archive/node-[node:nid]'); $this->patterns['node'] = $this->createPattern('node', '/archive/node-[node:nid]');
$this->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update')); $this->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this->assertText('Generated 5 URL aliases.'); $this->assertText('Generated 5 URL aliases.');
// Prevent existing aliases to be overriden. The bulk generate page should only offer // Prevent existing aliases to be overridden. The bulk generate page should
// to create an alias for paths which have none. // only offer to create an alias for paths which have none.
$this->drupalPostForm('admin/config/search/path/settings', ['update_action' => PathautoGeneratorInterface::UPDATE_ACTION_NO_NEW], t('Save configuration')); $this->drupalPostForm('admin/config/search/path/settings', ['update_action' => PathautoGeneratorInterface::UPDATE_ACTION_NO_NEW], t('Save configuration'));
$this->drupalGet('admin/config/search/path/update_bulk'); $this->drupalGet('admin/config/search/path/update_bulk');
......
...@@ -13,6 +13,7 @@ use Drupal\comment\Tests\CommentTestTrait; ...@@ -13,6 +13,7 @@ use Drupal\comment\Tests\CommentTestTrait;
class PathautoEnablingEntityTypesTest extends WebTestBase { class PathautoEnablingEntityTypesTest extends WebTestBase {
use PathautoTestHelperTrait; use PathautoTestHelperTrait;
use CommentTestTrait; use CommentTestTrait;
/** /**
...@@ -30,7 +31,7 @@ class PathautoEnablingEntityTypesTest extends WebTestBase { ...@@ -30,7 +31,7 @@ class PathautoEnablingEntityTypesTest extends WebTestBase {
protected $adminUser; protected $adminUser;
/** /**
* {inheritdoc} * {@inheritdoc}
*/ */
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
......
...@@ -49,9 +49,8 @@ class PathautoMassDeleteTest extends WebTestBase { ...@@ -49,9 +49,8 @@ class PathautoMassDeleteTest extends WebTestBase {
*/ */
protected $terms; protected $terms;
/** /**
* {inheritdoc} * {@inheritdoc}
*/ */
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
...@@ -136,14 +135,16 @@ class PathautoMassDeleteTest extends WebTestBase { ...@@ -136,14 +135,16 @@ class PathautoMassDeleteTest extends WebTestBase {
* Helper function to generate aliases. * Helper function to generate aliases.
*/ */
function generateAliases() { function generateAliases() {
// Delete all aliases to avoid duplicated aliases. They will be recreated below. // Delete all aliases to avoid duplicated aliases. They will be recreated
// below.
$this->deleteAllAliases(); $this->deleteAllAliases();
// We generate a bunch of aliases for nodes, users and taxonomy terms. If // We generate a bunch of aliases for nodes, users and taxonomy terms. If
// the entities are already created we just update them, otherwise we create // the entities are already created we just update them, otherwise we create
// them. // them.
if (empty($this->nodes)) { if (empty($this->nodes)) {
// Create a large number of nodes (100+) to make sure that the batch code works. // Create a large number of nodes (100+) to make sure that the batch code
// works.
for ($i = 1; $i <= 105; $i++) { for ($i = 1; $i <= 105; $i++) {
// Set the alias of two nodes manually. // Set the alias of two nodes manually.
$settings = ($i > 103) ? ['path' => ['alias' => "/custom_alias_$i", 'pathauto' => PathautoState::SKIP]] : []; $settings = ($i > 103) ? ['path' => ['alias' => "/custom_alias_$i", 'pathauto' => PathautoState::SKIP]] : [];
......
<?php <?php
namespace Drupal\pathauto\Tests; namespace Drupal\pathauto\Tests;
use Drupal\pathauto\Entity\PathautoPattern; use Drupal\pathauto\Entity\PathautoPattern;
use Drupal\node\Entity\Node; use Drupal\node\Entity\Node;
use Drupal\pathauto\PathautoState; use Drupal\pathauto\PathautoState;
...@@ -30,7 +31,7 @@ class PathautoNodeWebTest extends WebTestBase { ...@@ -30,7 +31,7 @@ class PathautoNodeWebTest extends WebTestBase {
protected $adminUser; protected $adminUser;
/** /**
* {inheritdoc} * {@inheritdoc}
*/ */
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
...@@ -56,7 +57,8 @@ class PathautoNodeWebTest extends WebTestBase { ...@@ -56,7 +57,8 @@ class PathautoNodeWebTest extends WebTestBase {
* Tests editing nodes with different settings. * Tests editing nodes with different settings.
*/ */
function testNodeEditing() { function testNodeEditing() {
// Ensure that the Pathauto checkbox is checked by default on the node add form. // Ensure that the Pathauto checkbox is checked by default on the node add
// form.
$this->drupalGet('node/add/page'); $this->drupalGet('node/add/page');
$this->assertFieldChecked('edit-path-0-pathauto'); $this->assertFieldChecked('edit-path-0-pathauto');
......
...@@ -85,7 +85,7 @@ class PathautoSettingsFormWebTest extends WebTestBase { ...@@ -85,7 +85,7 @@ class PathautoSettingsFormWebTest extends WebTestBase {
); );
/** /**
* {inheritdoc} * {@inheritdoc}
*/ */
function setUp() { function setUp() {