updated core from 8.4 to 8.5 : bug with login_destination

This commit is contained in:
Bachir Soussi Chiadmi
2018-03-13 14:01:21 +01:00
parent 0d78da249b
commit e668535a4e
3486 changed files with 89604 additions and 33283 deletions
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- taxonomy
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -8,8 +8,8 @@ dependencies:
- taxonomy
- migrate
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -7,8 +7,8 @@ package: Testing
dependencies:
- taxonomy
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -8,8 +8,8 @@ dependencies:
- taxonomy
- views
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -6,8 +6,8 @@ package: Testing
dependencies:
- taxonomy
# Information added by Drupal.org packaging script on 2018-01-03
version: '8.4.4'
# Information added by Drupal.org packaging script on 2018-03-07
version: '8.5.0'
core: '8.x'
project: 'drupal'
datestamp: 1515021228
datestamp: 1520457825
@@ -11,7 +11,7 @@ use Drupal\taxonomy\Entity\Vocabulary;
*
* @group taxonomy
*/
class LegacyTest extends TaxonomyTestBase {
class EarlyDateTest extends TaxonomyTestBase {
/**
* Modules to enable.
@@ -51,7 +51,7 @@ class LegacyTest extends TaxonomyTestBase {
/**
* Test taxonomy functionality with nodes prior to 1970.
*/
public function testTaxonomyLegacyNode() {
public function testTaxonomyEarlyDateNode() {
// Posts an article with a taxonomy term and a date prior to 1970.
$date = new DrupalDateTime('1969-01-01 00:00:00');
$edit = [];
@@ -80,7 +80,7 @@ class TaxonomyImageTest extends TaxonomyTestBase {
$files = $this->drupalGetTestFiles('image');
$image = array_pop($files);
$edit['name[0][value]'] = $this->randomMachineName();
$edit['files[field_test_0]'] = drupal_realpath($image->uri);
$edit['files[field_test_0]'] = \Drupal::service('file_system')->realpath($image->uri);
$this->drupalPostForm('admin/structure/taxonomy/manage/' . $this->vocabulary->id() . '/add', $edit, t('Save'));
$this->drupalPostForm(NULL, ['field_test[0][alt]' => $this->randomMachineName()], t('Save'));
$terms = entity_load_multiple_by_properties('taxonomy_term', ['name' => $edit['name[0][value]']]);
@@ -0,0 +1,36 @@
<?php
namespace Drupal\Tests\taxonomy\Functional;
/**
* Tests views contextual links on terms.
*
* @group taxonomy
*/
class TermContextualLinksTest extends TaxonomyTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'contextual',
];
/**
* Tests contextual links.
*/
public function testTermContextualLinks() {
$vocabulary = $this->createVocabulary();
$term = $this->createTerm($vocabulary);
$user = $this->drupalCreateUser([
'administer taxonomy',
'access contextual links',
]);
$this->drupalLogin($user);
$this->drupalGet('taxonomy/term/' . $term->id());
$this->assertSession()->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'taxonomy_term:taxonomy_term=' . $term->id() . ':');
}
}
@@ -2,6 +2,8 @@
namespace Drupal\Tests\taxonomy\Functional;
use Drupal\Component\Utility\Unicode;
/**
* Tests the taxonomy vocabulary permissions.
*
@@ -9,10 +11,204 @@ namespace Drupal\Tests\taxonomy\Functional;
*/
class VocabularyPermissionsTest extends TaxonomyTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['help'];
protected function setUp() {
parent::setUp();
$this->drupalPlaceBlock('page_title_block');
$this->drupalPlaceBlock('local_actions_block');
$this->drupalPlaceBlock('help_block');
}
/**
* Create, edit and delete a vocabulary via the user interface.
*/
public function testVocabularyPermissionsVocabulary() {
// VocabularyTest.php already tests for user with "administer taxonomy"
// permission.
// Test as user without proper permissions.
$authenticated_user = $this->drupalCreateUser([]);
$this->drupalLogin($authenticated_user);
$assert_session = $this->assertSession();
// Visit the main taxonomy administration page.
$this->drupalGet('admin/structure/taxonomy');
$assert_session->statusCodeEquals(403);
// Test as user with "access taxonomy overview" permissions.
$proper_user = $this->drupalCreateUser(['access taxonomy overview']);
$this->drupalLogin($proper_user);
// Visit the main taxonomy administration page.
$this->drupalGet('admin/structure/taxonomy');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('Vocabulary name');
$assert_session->linkNotExists('Add vocabulary');
}
/**
* Test the vocabulary overview permission.
*/
public function testTaxonomyVocabularyOverviewPermissions() {
// Create two vocabularies, one with two terms, the other without any term.
/** @var \Drupal\taxonomy\Entity\Vocabulary $vocabulary1 , $vocabulary2 */
$vocabulary1 = $this->createVocabulary();
$vocabulary2 = $this->createVocabulary();
$vocabulary1_id = $vocabulary1->id();
$vocabulary2_id = $vocabulary2->id();
$this->createTerm($vocabulary1);
$this->createTerm($vocabulary1);
// Assert expected help texts on first vocabulary.
$edit_help_text = t('You can reorganize the terms in @capital_name using their drag-and-drop handles, and group terms under a parent term by sliding them under and to the right of the parent.', ['@capital_name' => Unicode::ucfirst($vocabulary1->label())]);
$no_edit_help_text = t('@capital_name contains the following terms.', ['@capital_name' => Unicode::ucfirst($vocabulary1->label())]);
$assert_session = $this->assertSession();
// Logged in as admin user with 'administer taxonomy' permission.
$admin_user = $this->drupalCreateUser(['administer taxonomy']);
$this->drupalLogin($admin_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->linkExists('Edit');
$assert_session->linkExists('Delete');
$assert_session->linkExists('Add term');
$assert_session->buttonExists('Save');
$assert_session->pageTextContains('Weight');
$assert_session->pageTextContains($edit_help_text);
// Visit vocabulary overview without terms. 'Add term' should be shown.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No terms available');
$assert_session->linkExists('Add term');
// Login as a user without any of the required permissions.
$no_permission_user = $this->drupalCreateUser();
$this->drupalLogin($no_permission_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(403);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(403);
// Log in as a user with only the overview permission, neither edit nor
// delete operations must be available and no Save button.
$overview_only_user = $this->drupalCreateUser(['access taxonomy overview']);
$this->drupalLogin($overview_only_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->linkNotExists('Edit');
$assert_session->linkNotExists('Delete');
$assert_session->buttonNotExists('Save');
$assert_session->pageTextNotContains('Weight');
$assert_session->linkNotExists('Add term');
$assert_session->pageTextContains($no_edit_help_text);
// Visit vocabulary overview without terms. 'Add term' should not be shown.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No terms available');
$assert_session->linkNotExists('Add term');
// Login as a user with permission to edit terms, only edit link should be
// visible.
$edit_user = $this->createUser([
'access taxonomy overview',
'edit terms in ' . $vocabulary1_id,
'edit terms in ' . $vocabulary2_id,
]);
$this->drupalLogin($edit_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->linkExists('Edit');
$assert_session->linkNotExists('Delete');
$assert_session->buttonExists('Save');
$assert_session->pageTextContains('Weight');
$assert_session->linkNotExists('Add term');
$assert_session->pageTextContains($edit_help_text);
// Visit vocabulary overview without terms. 'Add term' should not be shown.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No terms available');
$assert_session->linkNotExists('Add term');
// Login as a user with permission only to delete terms.
$edit_delete_user = $this->createUser([
'access taxonomy overview',
'delete terms in ' . $vocabulary1_id,
'delete terms in ' . $vocabulary2_id,
]);
$this->drupalLogin($edit_delete_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->linkNotExists('Edit');
$assert_session->linkExists('Delete');
$assert_session->linkNotExists('Add term');
$assert_session->buttonNotExists('Save');
$assert_session->pageTextNotContains('Weight');
$assert_session->pageTextContains($no_edit_help_text);
// Visit vocabulary overview without terms. 'Add term' should not be shown.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No terms available');
$assert_session->linkNotExists('Add term');
// Login as a user with permission to edit and delete terms.
$edit_delete_user = $this->createUser([
'access taxonomy overview',
'edit terms in ' . $vocabulary1_id,
'delete terms in ' . $vocabulary1_id,
'edit terms in ' . $vocabulary2_id,
'delete terms in ' . $vocabulary2_id,
]);
$this->drupalLogin($edit_delete_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->linkExists('Edit');
$assert_session->linkExists('Delete');
$assert_session->linkNotExists('Add term');
$assert_session->buttonExists('Save');
$assert_session->pageTextContains('Weight');
$assert_session->pageTextContains($edit_help_text);
// Visit vocabulary overview without terms. 'Add term' should not be shown.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No terms available');
$assert_session->linkNotExists('Add term');
// Login as a user with permission to create new terms, only add new term
// link should be visible.
$edit_user = $this->createUser([
'access taxonomy overview',
'create terms in ' . $vocabulary1_id,
'create terms in ' . $vocabulary2_id,
]);
$this->drupalLogin($edit_user);
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary1_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->linkNotExists('Edit');
$assert_session->linkNotExists('Delete');
$assert_session->linkExists('Add term');
$assert_session->buttonNotExists('Save');
$assert_session->pageTextNotContains('Weight');
$assert_session->pageTextContains($no_edit_help_text);
// Visit vocabulary overview without terms. 'Add term' should not be shown.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary2_id . '/overview');
$assert_session->statusCodeEquals(200);
$assert_session->pageTextContains('No terms available');
$assert_session->linkExists('Add term');
}
/**
@@ -42,7 +238,9 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'term/']);
$this->assert(isset($view_link), 'The message area contains a link to a term');
$terms = taxonomy_term_load_multiple_by_name($edit['name[0][value]']);
$terms = \Drupal::entityTypeManager()
->getStorage('taxonomy_term')
->loadByProperties(['name' => $edit['name[0][value]']]);
$term = reset($terms);
// Edit the term.
@@ -62,6 +260,35 @@ class VocabularyPermissionsTest extends TaxonomyTestBase {
$this->drupalPostForm(NULL, NULL, t('Delete'));
$this->assertRaw(t('Deleted term %name.', ['%name' => $edit['name[0][value]']]), 'Term deleted.');
// Test as user with "create" permissions.
$user = $this->drupalCreateUser(["create terms in {$vocabulary->id()}"]);
$this->drupalLogin($user);
$assert_session = $this->assertSession();
// Create a new term.
$this->drupalGet('admin/structure/taxonomy/manage/' . $vocabulary->id() . '/add');
$assert_session->statusCodeEquals(200);
$assert_session->fieldExists('name[0][value]');
// Submit the term.
$edit = [];
$edit['name[0][value]'] = $this->randomMachineName();
$this->drupalPostForm(NULL, $edit, t('Save'));
$assert_session->pageTextContains(t('Created new term @name.', ['@name' => $edit['name[0][value]']]));
$terms = \Drupal::entityTypeManager()
->getStorage('taxonomy_term')
->loadByProperties(['name' => $edit['name[0][value]']]);
$term = reset($terms);
// Ensure that edit and delete access is denied.
$this->drupalGet('taxonomy/term/' . $term->id() . '/edit');
$assert_session->statusCodeEquals(403);
$this->drupalGet('taxonomy/term/' . $term->id() . '/delete');
$assert_session->statusCodeEquals(403);
// Test as user with "edit" permissions.
$user = $this->drupalCreateUser(["edit terms in {$vocabulary->id()}"]);
$this->drupalLogin($user);