updated core from 8.4 to 8.5 : bug with login_destination
This commit is contained in:
@@ -188,7 +188,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||
/**
|
||||
* Tests legacy text asserts.
|
||||
*/
|
||||
public function testLegacyTextAsserts() {
|
||||
public function testTextAsserts() {
|
||||
$this->drupalGet('test-encoded');
|
||||
$dangerous = 'Bad html <script>alert(123);</script>';
|
||||
$sanitized = Html::escape($dangerous);
|
||||
@@ -202,7 +202,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||
/**
|
||||
* Tests legacy field asserts which use xpath directly.
|
||||
*/
|
||||
public function testLegacyXpathAsserts() {
|
||||
public function testXpathAsserts() {
|
||||
$this->drupalGet('test-field-xpath');
|
||||
$this->assertFieldsByValue($this->xpath("//h1[@class = 'page-title']"), NULL);
|
||||
$this->assertFieldsByValue($this->xpath('//table/tbody/tr[2]/td[1]'), 'one');
|
||||
@@ -245,7 +245,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||
/**
|
||||
* Tests legacy field asserts using textfields.
|
||||
*/
|
||||
public function testLegacyFieldAssertsForTextfields() {
|
||||
public function testFieldAssertsForTextfields() {
|
||||
$this->drupalGet('test-field-xpath');
|
||||
|
||||
// *** 1. assertNoField().
|
||||
@@ -387,7 +387,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||
/**
|
||||
* Tests legacy field asserts for options field type.
|
||||
*/
|
||||
public function testLegacyFieldAssertsForOptions() {
|
||||
public function testFieldAssertsForOptions() {
|
||||
$this->drupalGet('test-field-xpath');
|
||||
|
||||
// Option field type.
|
||||
@@ -443,7 +443,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||
/**
|
||||
* Tests legacy field asserts for button field type.
|
||||
*/
|
||||
public function testLegacyFieldAssertsForButton() {
|
||||
public function testFieldAssertsForButton() {
|
||||
$this->drupalGet('test-field-xpath');
|
||||
|
||||
$this->assertFieldById('edit-save', NULL);
|
||||
@@ -485,7 +485,7 @@ class BrowserTestBaseTest extends BrowserTestBase {
|
||||
/**
|
||||
* Tests legacy field asserts for checkbox field type.
|
||||
*/
|
||||
public function testLegacyFieldAssertsForCheckbox() {
|
||||
public function testFieldAssertsForCheckbox() {
|
||||
$this->drupalGet('test-field-xpath');
|
||||
|
||||
// Part 1 - Test by name.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\FunctionalTests\Core\Test;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests Drupal's integration with Symfony PHPUnit Bridge.
|
||||
*
|
||||
* @group Test
|
||||
* @group legacy
|
||||
*/
|
||||
class PhpUnitBridgeTest extends BrowserTestBase {
|
||||
|
||||
protected static $modules = ['deprecation_test'];
|
||||
|
||||
/**
|
||||
* @expectedDeprecation This is the deprecation message for deprecation_test_function().
|
||||
*/
|
||||
public function testSilencedError() {
|
||||
$this->assertEquals('known_return_value', deprecation_test_function());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedDeprecation This is the deprecation message for deprecation_test_function().
|
||||
*/
|
||||
public function testErrorOnSiteUnderTest() {
|
||||
$this->drupalGet(Url::fromRoute('deprecation_test.route'));
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -138,7 +138,7 @@ class ContentEntityFormFieldValidationFilteringTest extends BrowserTestBase {
|
||||
// \Drupal\file\Plugin\Field\FieldWidget\FileWidget::process().
|
||||
$text_file = current($this->getTestFiles('text'));
|
||||
$edit = [
|
||||
'files[test_file_0]' => drupal_realpath($text_file->uri)
|
||||
'files[test_file_0]' => \Drupal::service('file_system')->realpath($text_file->uri)
|
||||
];
|
||||
$assert_session->elementNotExists('css', 'input#edit-test-file-0-remove-button');
|
||||
$this->drupalPostForm(NULL, $edit, 'Upload');
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\FunctionalTests\Routing;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\link\LinkItemInterface;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests that route lookup is cached by the current language.
|
||||
*
|
||||
* @group routing
|
||||
*/
|
||||
class RouteCachingLanguageTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['path', 'node', 'content_translation', 'link', 'block'];
|
||||
|
||||
/**
|
||||
* An user with permissions to administer content types.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $webUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->createContentType(['type' => 'page']);
|
||||
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
|
||||
$permissions = [
|
||||
'access administration pages',
|
||||
'administer content translation',
|
||||
'administer content types',
|
||||
'administer languages',
|
||||
'administer url aliases',
|
||||
'create content translations',
|
||||
'create page content',
|
||||
'create url aliases',
|
||||
'edit any page content',
|
||||
'translate any entity',
|
||||
];
|
||||
// Create and log in user.
|
||||
$this->webUser = $this->drupalCreateUser($permissions);
|
||||
$this->drupalLogin($this->webUser);
|
||||
|
||||
// Enable French language.
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
|
||||
// Enable translation for page node.
|
||||
$edit = [
|
||||
'entity_types[node]' => 1,
|
||||
'settings[node][page][translatable]' => 1,
|
||||
'settings[node][page][fields][path]' => 1,
|
||||
'settings[node][page][fields][body]' => 1,
|
||||
'settings[node][page][settings][language][language_alterable]' => 1,
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
|
||||
|
||||
// Create a field with settings to validate.
|
||||
$field_storage = FieldStorageConfig::create([
|
||||
'field_name' => 'field_link',
|
||||
'entity_type' => 'node',
|
||||
'type' => 'link',
|
||||
]);
|
||||
$field_storage->save();
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $field_storage,
|
||||
'bundle' => 'page',
|
||||
'settings' => [
|
||||
'title' => DRUPAL_OPTIONAL,
|
||||
'link_type' => LinkItemInterface::LINK_GENERIC,
|
||||
],
|
||||
]);
|
||||
$field->save();
|
||||
|
||||
entity_get_form_display('node', 'page', 'default')
|
||||
->setComponent('field_link', [
|
||||
'type' => 'link_default',
|
||||
])
|
||||
->save();
|
||||
entity_get_display('node', 'page', 'full')
|
||||
->setComponent('field_link', [
|
||||
'type' => 'link',
|
||||
])
|
||||
->save();
|
||||
|
||||
// Enable URL language detection and selection and set a prefix for both
|
||||
// languages.
|
||||
$edit = ['language_interface[enabled][language-url]' => 1];
|
||||
$this->drupalPostForm('admin/config/regional/language/detection', $edit, 'Save settings');
|
||||
$edit = ['prefix[en]' => 'en'];
|
||||
$this->drupalPostForm('admin/config/regional/language/detection/url', $edit, 'Save configuration');
|
||||
|
||||
// Reset the cache after changing the negotiation settings as that changes
|
||||
// how links are built.
|
||||
$this->resetAll();
|
||||
|
||||
$definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions('node', 'page');
|
||||
$this->assertTrue($definitions['path']->isTranslatable(), 'Node path is translatable.');
|
||||
$this->assertTrue($definitions['body']->isTranslatable(), 'Node body is translatable.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates content with a link field pointing to an alias of another language.
|
||||
*
|
||||
* @dataProvider providerLanguage
|
||||
*/
|
||||
public function testLinkTranslationWithAlias($source_langcode) {
|
||||
$source_url_options = [
|
||||
'language' => ConfigurableLanguage::load($source_langcode),
|
||||
];
|
||||
|
||||
// Create a target node in the source language that is the link target.
|
||||
$edit = [
|
||||
'langcode[0][value]' => $source_langcode,
|
||||
'title[0][value]' => 'Target page',
|
||||
'path[0][alias]' => '/target-page',
|
||||
];
|
||||
$this->drupalPostForm('node/add/page', $edit, t('Save'), $source_url_options);
|
||||
|
||||
// Confirm that the alias works.
|
||||
$assert_session = $this->assertSession();
|
||||
$assert_session->addressEquals($source_langcode . '/target-page');
|
||||
$assert_session->statusCodeEquals(200);
|
||||
$assert_session->pageTextContains('Target page');
|
||||
|
||||
// Create a second node that links to the first through the link field.
|
||||
$edit = [
|
||||
'langcode[0][value]' => $source_langcode,
|
||||
'title[0][value]' => 'Link page',
|
||||
'field_link[0][uri]' => '/target-page',
|
||||
'field_link[0][title]' => 'Target page',
|
||||
'path[0][alias]' => '/link-page',
|
||||
];
|
||||
$this->drupalPostForm('node/add/page', $edit, t('Save'), $source_url_options);
|
||||
|
||||
// Make sure the link node is displayed with a working link.
|
||||
$assert_session->pageTextContains('Link page');
|
||||
$this->clickLink('Target page');
|
||||
$assert_session->addressEquals($source_langcode . '/target-page');
|
||||
$assert_session->statusCodeEquals(200);
|
||||
$assert_session->pageTextContains('Target page');
|
||||
|
||||
// Clear all caches, then add a translation for the link node.
|
||||
$this->resetAll();
|
||||
|
||||
$this->drupalGet('link-page', $source_url_options);
|
||||
$this->clickLink('Translate');
|
||||
$this->clickLink(t('Add'));
|
||||
|
||||
// Do not change the link field.
|
||||
$edit = [
|
||||
'title[0][value]' => 'Translated link page',
|
||||
'path[0][alias]' => '/translated-link-page',
|
||||
];
|
||||
$this->drupalPostForm(NULL, $edit, 'Save (this translation)');
|
||||
|
||||
$assert_session->pageTextContains('Translated link page');
|
||||
|
||||
// @todo Clicking on the link does not include the language prefix.
|
||||
$this->drupalGet('target-page', $source_url_options);
|
||||
$assert_session->statusCodeEquals(200);
|
||||
$assert_session->pageTextContains('Target page');
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for testFromUri().
|
||||
*/
|
||||
public function providerLanguage() {
|
||||
return [
|
||||
['en'],
|
||||
['fr'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\FunctionalTests\Routing;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* Tests the route cache when the language is not in the path.
|
||||
*
|
||||
* @group language
|
||||
*/
|
||||
class RouteCachingNonPathLanguageNegotiationTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['language', 'block'];
|
||||
|
||||
/**
|
||||
* The admin user.
|
||||
*
|
||||
* @var \Drupal\user\UserInterface
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create and log in user.
|
||||
$this->adminUser = $this->drupalCreateUser(['administer blocks', 'administer languages', 'access administration pages']);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
|
||||
// Add language.
|
||||
ConfigurableLanguage::createFromLangcode('fr')->save();
|
||||
|
||||
// Enable session language detection and selection.
|
||||
$edit = [
|
||||
'language_interface[enabled][language-url]' => FALSE,
|
||||
'language_interface[enabled][language-session]' => TRUE,
|
||||
];
|
||||
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
|
||||
|
||||
// A more common scenario is domain-based negotiation but that can not be
|
||||
// tested. Session negotiation by default is not considered by the URL
|
||||
// language type that is used to resolve the alias. Explicitly enable
|
||||
// that to be able to test this scenario.
|
||||
// @todo Improve in https://www.drupal.org/project/drupal/issues/1125428.
|
||||
$this->config('language.types')
|
||||
->set('negotiation.language_url.enabled', ['language-session' => 0])
|
||||
->save();
|
||||
|
||||
// Enable the language switching block.
|
||||
$this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, [
|
||||
'id' => 'test_language_block',
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests aliases when the negotiated language is not in the path.
|
||||
*/
|
||||
public function testAliases() {
|
||||
// Switch to French and try to access the now inaccessible block.
|
||||
$this->drupalGet('');
|
||||
|
||||
// Create an alias for user/UID just for en, make sure that this is a 404
|
||||
// on the french page exist in english, no matter which language is
|
||||
// checked first. Create the alias after visiting frontpage to make sure
|
||||
// there is no existing cache entry for this that affects the tests.
|
||||
\Drupal::service('path.alias_storage')->save('/user/' . $this->adminUser->id(), '/user-page', 'en');
|
||||
|
||||
$this->clickLink('French');
|
||||
$this->drupalGet('user-page');
|
||||
$this->assertSession()->statusCodeEquals(404);
|
||||
|
||||
// Switch to english, make sure it works now.
|
||||
$this->clickLink('English');
|
||||
$this->drupalGet('user-page');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
// Clear cache and repeat the check, this time with english first.
|
||||
$this->resetAll();
|
||||
$this->drupalGet('user-page');
|
||||
$this->assertSession()->statusCodeEquals(200);
|
||||
|
||||
$this->clickLink('French');
|
||||
$this->drupalGet('user-page');
|
||||
$this->assertSession()->statusCodeEquals(404);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -374,7 +374,6 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
|
||||
|
||||
// Ensure that the update hooks updated all entity schema.
|
||||
$needs_updates = \Drupal::entityDefinitionUpdateManager()->needsUpdates();
|
||||
$this->assertFalse($needs_updates, 'After all updates ran, entity schema is up to date.');
|
||||
if ($needs_updates) {
|
||||
foreach (\Drupal::entityDefinitionUpdateManager()
|
||||
->getChangeSummary() as $entity_type_id => $summary) {
|
||||
@@ -382,6 +381,9 @@ abstract class UpdatePathTestBase extends BrowserTestBase {
|
||||
$this->fail($message);
|
||||
}
|
||||
}
|
||||
// The above calls to `fail()` should prevent this from ever being
|
||||
// called, but it is here in case something goes really wrong.
|
||||
$this->assertFalse($needs_updates, 'After all updates ran, entity schema is up to date.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user