public function PathautoBulkUpdateTest::testBulkUpdate in Pathauto 8
File
- tests/src/Functional/PathautoBulkUpdateTest.php, line 73
Class
- PathautoBulkUpdateTest
- Bulk update functionality tests.
Namespace
Drupal\Tests\pathauto\Functional
Code
public function testBulkUpdate() {
$this->nodes = [];
for ($i = 1; $i <= 5; $i++) {
$node = $this
->drupalCreateNode();
$this->nodes[$node
->id()] = $node;
}
$this
->deleteAllAliases();
$edit = [
'update[canonical_entities:node]' => TRUE,
'update[canonical_entities:user]' => TRUE,
'update[forum]' => TRUE,
];
$this
->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this
->assertText('Generated 8 URL aliases.');
foreach ($this->nodes as $node) {
$this
->assertEntityAliasExists($node);
}
$this
->assertEntityAliasExists($this->adminUser);
$this
->assertAliasExists([
'path' => '/taxonomy/term/1',
]);
$new_node = $this
->drupalCreateNode([
'path' => [
'alias' => '',
'pathauto' => PathautoState::SKIP,
],
]);
$this
->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this
->assertText('No new URL aliases to generate.');
$this
->assertNoEntityAliasExists($new_node);
$this
->drupalPostForm('admin/config/search/path/settings', [
'update_action' => PathautoGeneratorInterface::UPDATE_ACTION_DELETE,
], t('Save configuration'));
$edit['action'] = 'all';
$this
->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this
->assertText('No new URL aliases to generate.');
$this->patterns['node']
->delete();
$this->patterns['node'] = $this
->createPattern('node', '/archive/node-[node:nid]');
$this
->drupalPostForm('admin/config/search/path/update_bulk', $edit, t('Update'));
$this
->assertText('Generated 5 URL aliases.');
$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
->assertFieldByName('action', 'create');
$this
->assertText('Pathauto settings are set to ignore paths which already have a URL alias.');
$this
->assertNoFieldByName('action', 'update');
$this
->assertNoFieldByName('action', 'all');
}