Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -63,8 +63,8 @@ class CaseInsensitivePathTest extends BrowserTestBase {
|
|||
|
||||
$this->drupalGet('admin/content', [
|
||||
'query' => [
|
||||
'title' => 'FooBarBaz'
|
||||
]
|
||||
'title' => 'FooBarBaz',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSession()->linkExists('FooBarBaz');
|
||||
|
@ -74,8 +74,8 @@ class CaseInsensitivePathTest extends BrowserTestBase {
|
|||
|
||||
$this->drupalGet('Admin/Content', [
|
||||
'query' => [
|
||||
'title' => 'FooBarBaz'
|
||||
]
|
||||
'title' => 'FooBarBaz',
|
||||
],
|
||||
]);
|
||||
|
||||
$this->assertSession()->linkExists('FooBarBaz');
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\FunctionalTests\Routing;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* @group routing
|
||||
*/
|
||||
class DefaultFormatTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['system', 'default_format_test'];
|
||||
|
||||
public function testFoo() {
|
||||
$this->drupalGet('/default_format_test/human');
|
||||
$this->assertSame('format:html', $this->getSession()->getPage()->getContent());
|
||||
$this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
|
||||
|
||||
$this->drupalGet('/default_format_test/machine');
|
||||
$this->assertSame('format:json', $this->getSession()->getPage()->getContent());
|
||||
$this->assertSame('MISS', $this->drupalGetHeader('X-Drupal-Cache'));
|
||||
}
|
||||
|
||||
public function testMultipleRoutesWithSameSingleFormat() {
|
||||
$this->drupalGet('/default_format_test/machine');
|
||||
$this->assertSame('format:json', $this->getSession()->getPage()->getContent());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\FunctionalTests\Routing;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
|
||||
/**
|
||||
* @group routing
|
||||
*/
|
||||
class LazyRouteProviderInstallTest extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = ['lazy_route_provider_install_test'];
|
||||
|
||||
/**
|
||||
* Tests that the lazy route provider is used during a module install.
|
||||
*/
|
||||
public function testInstallation() {
|
||||
$this->container->get('module_installer')->install(['router_test']);
|
||||
// Note that on DrupalCI the test site is installed in a sub directory so
|
||||
// we cannot use ::assertEquals().
|
||||
$this->assertStringEndsWith('/admin', \Drupal::state()->get('Drupal\lazy_route_provider_install_test\PluginManager'));
|
||||
$this->assertStringEndsWith('/router_test/test1', \Drupal::state()->get('router_test_install'));
|
||||
// If there is an exception thrown in rebuilding a route then the state
|
||||
// 'lazy_route_provider_install_test_menu_links_discovered_alter' will be
|
||||
// set.
|
||||
// @see lazy_route_provider_install_test_menu_links_discovered_alter().
|
||||
$this->assertEquals('success', \Drupal::state()->get('lazy_route_provider_install_test_menu_links_discovered_alter', NULL));
|
||||
}
|
||||
|
||||
}
|
|
@ -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'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue