Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -9,6 +9,7 @@ namespace Drupal\language\Tests;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Plugin\LanguageNegotiation\LanguageNegotiationUrl;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\Core\Language\LanguageInterface;
use Drupal\simpletest\WebTestBase;
@ -24,7 +25,7 @@ class LanguageSwitchingTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('locale', 'language', 'block', 'language_test');
public static $modules = array('locale', 'locale_test', 'language', 'block', 'language_test', 'menu_ui');
protected function setUp() {
parent::setUp();
@ -205,20 +206,20 @@ class LanguageSwitchingTest extends WebTestBase {
/** @var \Drupal\Core\Routing\UrlGenerator $generator */
$generator = $this->container->get('url_generator');
// Verfify the English URL is correct
// Verify the English URL is correct
list($english_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
':id' => 'block-test-language-block',
':hreflang' => 'en',
));
$english_url = $generator->generateFromPath('user/2', array('language' => $languages['en']));
$english_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['en']));
$this->assertEqual($english_url, (string) $english_link['href']);
// Verfify the Italian URL is correct
// Verify the Italian URL is correct
list($italian_link) = $this->xpath('//div[@id=:id]/ul/li/a[@hreflang=:hreflang]', array(
':id' => 'block-test-language-block',
':hreflang' => 'it',
));
$italian_url = $generator->generateFromPath('user/2', array('language' => $languages['it']));
$italian_url = $generator->generateFromRoute('entity.user.canonical', array('user' => 2), array('language' => $languages['it']));
$this->assertEqual($italian_url, (string) $italian_link['href']);
}
@ -292,7 +293,7 @@ class LanguageSwitchingTest extends WebTestBase {
$function_name = '#type link';
$path = 'language_test/type-link-active-class';
// Test links generated by _l() on an English page.
// Test links generated by the link generator on an English page.
$current_language = 'English';
$this->drupalGet($path);
@ -317,7 +318,7 @@ class LanguageSwitchingTest extends WebTestBase {
$this->assertIdentical($settings['path']['isFront'], FALSE, 'drupalSettings.path.isFront is set correctly to allow drupal.active-link to mark the correct links as active.');
$this->assertIdentical($settings['path']['currentLanguage'], 'en', 'drupalSettings.path.currentLanguage is set correctly to allow drupal.active-link to mark the correct links as active.');
// Test links generated by _l() on a French page.
// Test links generated by the link generator on a French page.
$current_language = 'French';
$this->drupalGet('fr/language_test/type-link-active-class');
@ -353,7 +354,7 @@ class LanguageSwitchingTest extends WebTestBase {
$this->drupalLogout();
// Test links generated by _l() on an English page.
// Test links generated by the link generator on an English page.
$current_language = 'English';
$this->drupalGet('language_test/type-link-active-class');
@ -372,7 +373,7 @@ class LanguageSwitchingTest extends WebTestBase {
$links = $this->xpath('//a[@id = :id and not(contains(@class, :class))]', array(':id' => 'fr_link', ':class' => 'is-active'));
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is NOT marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
// Test links generated by _l() on a French page.
// Test links generated by the link generator on a French page.
$current_language = 'French';
$this->drupalGet('fr/language_test/type-link-active-class');
@ -392,6 +393,58 @@ class LanguageSwitchingTest extends WebTestBase {
$this->assertTrue(isset($links[0]), t('A link generated by :function to the current :language page with langcode :langcode is marked active.', array(':function' => $function_name, ':language' => $current_language, ':langcode' => $langcode)));
}
/**
* Test language switcher links for session based negotiation.
*/
function testLanguageSessionSwitchLinks() {
// Add language.
$edit = array(
'predefined_langcode' => 'fr',
);
$this->drupalPostForm('admin/config/regional/language/add', $edit, t('Add language'));
// Enable session language detection and selection.
$edit = array(
'language_interface[enabled][language-url]' => FALSE,
'language_interface[enabled][language-session]' => TRUE,
);
$this->drupalPostForm('admin/config/regional/language/detection', $edit, t('Save settings'));
// Enable the language switching block.
$this->drupalPlaceBlock('language_block:' . LanguageInterface::TYPE_INTERFACE, array(
'id' => 'test_language_block',
));
// Enable the main menu block.
$this->drupalPlaceBlock('system_menu_block:main', array(
'id' => 'test_menu',
));
// Add a link to the homepage.
$link = MenuLinkContent::create([
'title' => 'Home',
'menu_name' => 'main',
'bundle' => 'menu_link_content',
'link' => [['uri' => 'entity:user/2']],
]);
$link->save();
// Go to the homepage.
$this->drupalGet('');
// Click on the French link.
$this->clickLink(t('French'));
// There should be a query parameter to set the session language.
$this->assertUrl('user/2', ['query' => ['language' => 'fr']]);
// Click on the 'Home' Link.
$this->clickLink(t('Home'));
// There should be no query parameter.
$this->assertUrl('user/2');
// Click on the French link.
$this->clickLink(t('French'));
// There should be no query parameter.
$this->assertUrl('user/2');
}
/**
* Saves the native name of a language entity in configuration as a label.
*