Skip to content
Snippets Groups Projects
Verified Commit 2f70dd81 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3497407 by quietone: Fix DrupalPractice.Objects.GlobalFunction in Functional tests

parent b041cd99
No related branches found
No related tags found
7 merge requests!11197Issue #3506427 by eduardo morales alberti: Remove responsive_image.ajax from hook,!5423Draft: Resolve #3329907 "Test2",!3478Issue #3337882: Deleted menus are not removed from content type config,!2964Issue #2865710 : Dependencies from only one instance of a widget are used in display modes,!10223132456: Fix issue where views instances are emptied before an ajax request is complete,!579Issue #2230909: Simple decimals fail to pass validation,!213Issue #2906496: Give Media a menu item under Content
Pipeline #410216 passed with warnings
Pipeline: drupal

#410229

    Pipeline: drupal

    #410223

      Pipeline: drupal

      #410217

        Showing
        with 66 additions and 39 deletions
        ......@@ -7,6 +7,7 @@
        use Drupal\Core\Database\Database;
        use Drupal\Core\File\FileExists;
        use Drupal\Core\Language\LanguageInterface;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\Core\Url;
        use Drupal\Tests\BrowserTestBase;
        ......@@ -20,6 +21,8 @@
        */
        class LocaleImportFunctionalTest extends BrowserTestBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -266,8 +269,8 @@ public function testLanguageContext(): void {
        // We cast the return value of t() to string so as to retrieve the
        // translated value, rendered as a string.
        $this->assertSame('Svibanj', (string) t('May', [], ['langcode' => 'hr', 'context' => 'Long month name']), 'Long month name context is working.');
        $this->assertSame('Svi.', (string) t('May', [], ['langcode' => 'hr']), 'Default context is working.');
        $this->assertSame('Svibanj', (string) $this->t('May', [], ['langcode' => 'hr', 'context' => 'Long month name']), 'Long month name context is working.');
        $this->assertSame('Svi.', (string) $this->t('May', [], ['langcode' => 'hr']), 'Default context is working.');
        }
        /**
        ......@@ -282,7 +285,7 @@ public function testEmptyMsgstr(): void {
        ]);
        $this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
        $this->assertSame('Műveletek', (string) t('Operations', [], ['langcode' => $langcode]), 'String imported and translated.');
        $this->assertSame('Műveletek', (string) $this->t('Operations', [], ['langcode' => $langcode]), 'String imported and translated.');
        // Try importing a .po file.
        $this->importPoFile($this->getPoFileWithEmptyMsgstr(), [
        ......
        ......@@ -5,6 +5,7 @@
        namespace Drupal\Tests\locale\Functional;
        use Drupal\Core\Site\Settings;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\Core\Url;
        use Drupal\Core\Database\Database;
        use Drupal\language\Entity\ConfigurableLanguage;
        ......@@ -20,6 +21,8 @@
        */
        class LocaleTranslationUiTest extends BrowserTestBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -83,7 +86,7 @@ public function testStringTranslation(): void {
        $this->drupalGet('admin/config/regional/language/add');
        $this->submitForm($edit, 'Add custom language');
        // Add string.
        t($name, [], ['langcode' => $langcode])->render();
        $this->t($name, [], ['langcode' => $langcode])->render();
        // Reset locale cache.
        $this->container->get('string_translation')->reset();
        $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
        ......@@ -165,15 +168,15 @@ public function testStringTranslation(): void {
        $this->assertSession()->pageTextContains($translation_to_en);
        $this->assertNotEquals($translation, $name);
        $this->assertEquals($translation, t($name, [], ['langcode' => $langcode]), 't() works for non-English.');
        $this->assertEquals($translation, $this->t($name, [], ['langcode' => $langcode]), 't() works for non-English.');
        // Refresh the locale() cache to get fresh data from t() below. We are in
        // the same HTTP request and therefore t() is not refreshed by saving the
        // translation above.
        $this->container->get('string_translation')->reset();
        // Now we should get the proper fresh translation from t().
        $this->assertNotEquals($translation_to_en, $name);
        $this->assertEquals($translation_to_en, t($name, [], ['langcode' => 'en']), 't() works for English.');
        $this->assertTrue(t($name, [], ['langcode' => LanguageInterface::LANGCODE_SYSTEM]) == $name, 't() works for LanguageInterface::LANGCODE_SYSTEM.');
        $this->assertEquals($translation_to_en, $this->t($name, [], ['langcode' => 'en']), 't() works for English.');
        $this->assertTrue($this->t($name, [], ['langcode' => LanguageInterface::LANGCODE_SYSTEM]) == $name, 't() works for LanguageInterface::LANGCODE_SYSTEM.');
        $search = [
        'string' => $name,
        ......@@ -367,7 +370,7 @@ public function testStringValidation(): void {
        $this->drupalGet('admin/config/regional/language/add');
        $this->submitForm($edit, 'Add custom language');
        // Add string.
        t($name, [], ['langcode' => $langcode])->render();
        $this->t($name, [], ['langcode' => $langcode])->render();
        // Reset locale cache.
        $search = [
        'string' => $name,
        ......@@ -436,7 +439,7 @@ public function testStringSearch(): void {
        $this->submitForm($edit, 'Add custom language');
        // Add string.
        t($name, [], ['langcode' => $langcode])->render();
        $this->t($name, [], ['langcode' => $langcode])->render();
        // Reset locale cache.
        $this->container->get('string_translation')->reset();
        $this->drupalLogout();
        ......
        ......@@ -6,6 +6,7 @@
        use Drupal\Core\Database\Database;
        use Drupal\Core\Language\LanguageInterface;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        // cspell:ignore extraday lundi
        ......@@ -16,6 +17,8 @@
        */
        class LocaleUpdateTest extends LocaleUpdateBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -169,13 +172,13 @@ public function testUpdateImportSourceRemote(): void {
        // Check whether existing translations have (not) been overwritten.
        // cSpell:disable
        $this->assertEquals('Januar_1', t('January', [], ['langcode' => 'de']), 'Translation of January');
        $this->assertEquals('Februar_2', t('February', [], ['langcode' => 'de']), 'Translation of February');
        $this->assertEquals('Marz_2', t('March', [], ['langcode' => 'de']), 'Translation of March');
        $this->assertEquals('April_2', t('April', [], ['langcode' => 'de']), 'Translation of April');
        $this->assertEquals('Mai_customized', t('May', [], ['langcode' => 'de']), 'Translation of May');
        $this->assertEquals('Juni', t('June', [], ['langcode' => 'de']), 'Translation of June');
        $this->assertEquals('Montag', t('Monday', [], ['langcode' => 'de']), 'Translation of Monday');
        $this->assertEquals('Januar_1', $this->t('January', [], ['langcode' => 'de']), 'Translation of January');
        $this->assertEquals('Februar_2', $this->t('February', [], ['langcode' => 'de']), 'Translation of February');
        $this->assertEquals('Marz_2', $this->t('March', [], ['langcode' => 'de']), 'Translation of March');
        $this->assertEquals('April_2', $this->t('April', [], ['langcode' => 'de']), 'Translation of April');
        $this->assertEquals('Mai_customized', $this->t('May', [], ['langcode' => 'de']), 'Translation of May');
        $this->assertEquals('Juni', $this->t('June', [], ['langcode' => 'de']), 'Translation of June');
        $this->assertEquals('Montag', $this->t('Monday', [], ['langcode' => 'de']), 'Translation of Monday');
        // cSpell:enable
        }
        ......@@ -229,13 +232,13 @@ public function testUpdateImportSourceLocal(): void {
        // Check whether existing translations have (not) been overwritten.
        // cSpell:disable
        $this->assertEquals('Januar_customized', t('January', [], ['langcode' => 'de']), 'Translation of January');
        $this->assertEquals('Februar_2', t('February', [], ['langcode' => 'de']), 'Translation of February');
        $this->assertEquals('Marz_2', t('March', [], ['langcode' => 'de']), 'Translation of March');
        $this->assertEquals('April_2', t('April', [], ['langcode' => 'de']), 'Translation of April');
        $this->assertEquals('Mai_customized', t('May', [], ['langcode' => 'de']), 'Translation of May');
        $this->assertEquals('Juni', t('June', [], ['langcode' => 'de']), 'Translation of June');
        $this->assertEquals('Montag', t('Monday', [], ['langcode' => 'de']), 'Translation of Monday');
        $this->assertEquals('Januar_customized', $this->t('January', [], ['langcode' => 'de']), 'Translation of January');
        $this->assertEquals('Februar_2', $this->t('February', [], ['langcode' => 'de']), 'Translation of February');
        $this->assertEquals('Marz_2', $this->t('March', [], ['langcode' => 'de']), 'Translation of March');
        $this->assertEquals('April_2', $this->t('April', [], ['langcode' => 'de']), 'Translation of April');
        $this->assertEquals('Mai_customized', $this->t('May', [], ['langcode' => 'de']), 'Translation of May');
        $this->assertEquals('Juni', $this->t('June', [], ['langcode' => 'de']), 'Translation of June');
        $this->assertEquals('Montag', $this->t('Monday', [], ['langcode' => 'de']), 'Translation of Monday');
        // cSpell:enable
        }
        ......@@ -269,13 +272,13 @@ public function testUpdateImportModeNonCustomized(): void {
        // Check whether existing translations have (not) been overwritten.
        // cSpell:disable
        $this->assertEquals('Januar_customized', t('January', [], ['langcode' => 'de']), 'Translation of January');
        $this->assertEquals('Februar_customized', t('February', [], ['langcode' => 'de']), 'Translation of February');
        $this->assertEquals('Marz_2', t('March', [], ['langcode' => 'de']), 'Translation of March');
        $this->assertEquals('April_2', t('April', [], ['langcode' => 'de']), 'Translation of April');
        $this->assertEquals('Mai_customized', t('May', [], ['langcode' => 'de']), 'Translation of May');
        $this->assertEquals('Juni', t('June', [], ['langcode' => 'de']), 'Translation of June');
        $this->assertEquals('Montag', t('Monday', [], ['langcode' => 'de']), 'Translation of Monday');
        $this->assertEquals('Januar_customized', $this->t('January', [], ['langcode' => 'de']), 'Translation of January');
        $this->assertEquals('Februar_customized', $this->t('February', [], ['langcode' => 'de']), 'Translation of February');
        $this->assertEquals('Marz_2', $this->t('March', [], ['langcode' => 'de']), 'Translation of March');
        $this->assertEquals('April_2', $this->t('April', [], ['langcode' => 'de']), 'Translation of April');
        $this->assertEquals('Mai_customized', $this->t('May', [], ['langcode' => 'de']), 'Translation of May');
        $this->assertEquals('Juni', $this->t('June', [], ['langcode' => 'de']), 'Translation of June');
        $this->assertEquals('Montag', $this->t('Monday', [], ['langcode' => 'de']), 'Translation of Monday');
        // cSpell:enable
        }
        ......
        ......@@ -4,6 +4,7 @@
        namespace Drupal\Tests\navigation\Functional;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\file\Entity\File;
        use Drupal\Tests\BrowserTestBase;
        use Drupal\Tests\TestFileCreationTrait;
        ......@@ -15,6 +16,7 @@
        */
        class NavigationLogoTest extends BrowserTestBase {
        use StringTranslationTrait;
        use TestFileCreationTrait;
        /**
        ......@@ -91,7 +93,7 @@ public function testSettingsLogoOptionsForm(): void {
        'logo_provider' => 'custom',
        'logo_path' => $logo_file->getFileUri(),
        ];
        $this->submitForm($edit, t('Save configuration'));
        $this->submitForm($edit, $this->t('Save configuration'));
        // Refresh the page to verify custom logo is placed.
        $this->drupalGet('/admin/config/user-interface/navigation/settings');
        $this->assertSession()->elementExists('css', 'a.admin-toolbar__logo > img');
        ......@@ -102,7 +104,7 @@ public function testSettingsLogoOptionsForm(): void {
        'logo_provider' => 'custom',
        'logo_path' => 'core/misc/logo/drupal-logo.svg',
        ];
        $this->submitForm($edit, t('Save configuration'));
        $this->submitForm($edit, $this->t('Save configuration'));
        // Refresh the page to verify custom logo is placed.
        $this->drupalGet('/admin/config/user-interface/navigation/settings');
        $this->assertSession()->elementExists('css', 'a.admin-toolbar__logo > img');
        ......@@ -114,7 +116,7 @@ public function testSettingsLogoOptionsForm(): void {
        'logo_provider' => 'custom',
        'files[logo_upload]' => $this->fileSystem->realpath($file->uri),
        ];
        $this->submitForm($edit, t('Save configuration'));
        $this->submitForm($edit, $this->t('Save configuration'));
        $this->assertSession()->statusMessageContains('The image was resized to fit within the navigation logo expected dimensions of 40x40 pixels. The new dimensions of the resized image are 40x27 pixels.');
        // Refresh the page to verify custom logo is placed.
        $this->drupalGet('/admin/config/user-interface/navigation/settings');
        ......
        ......@@ -4,6 +4,7 @@
        namespace Drupal\Tests\node\Functional;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\language\Entity\ConfigurableLanguage;
        use Drupal\Tests\BrowserTestBase;
        ......@@ -18,6 +19,8 @@
        */
        class NodeTypeTranslationTest extends BrowserTestBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -125,7 +128,7 @@ public function testNodeTypeTranslation(): void {
        $this->drupalGet("$langcode/node/add/$type");
        // This is a Spanish page, so ensure the text asserted is translated in
        // Spanish and not French by adding the langcode option.
        $this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
        $this->assertSession()->responseContains($this->t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
        // Check the name is translated with admin theme for editing.
        $this->drupalGet('admin/appearance');
        ......@@ -133,7 +136,7 @@ public function testNodeTypeTranslation(): void {
        $this->drupalGet("$langcode/node/add/$type");
        // This is a Spanish page, so ensure the text asserted is translated in
        // Spanish and not French by adding the langcode option.
        $this->assertSession()->responseContains(t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
        $this->assertSession()->responseContains($this->t('Create @name', ['@name' => $translated_name], ['langcode' => $langcode]));
        }
        /**
        ......
        ......@@ -4,6 +4,7 @@
        namespace Drupal\Tests\shortcut\Functional\Rest;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\shortcut\Entity\Shortcut;
        use Drupal\shortcut\Entity\ShortcutSet;
        use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
        ......@@ -13,6 +14,8 @@
        */
        abstract class ShortcutResourceTestBase extends EntityResourceTestBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -56,7 +59,7 @@ protected function createEntity() {
        // Create shortcut.
        $shortcut = Shortcut::create([
        'shortcut_set' => 'default',
        'title' => t('Comments'),
        'title' => $this->t('Comments'),
        'weight' => -20,
        'link' => [
        'uri' => 'internal:/admin/content/comment',
        ......
        ......@@ -4,12 +4,15 @@
        namespace Drupal\Tests\system\Functional\Rest;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\Tests\rest\Functional\EntityResource\ConfigEntityResourceTestBase;
        use Drupal\system\Entity\Action;
        use Drupal\user\RoleInterface;
        abstract class ActionResourceTestBase extends ConfigEntityResourceTestBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -39,7 +42,7 @@ protected function createEntity() {
        $action = Action::create([
        'id' => 'user_add_role_action.' . RoleInterface::ANONYMOUS_ID,
        'type' => 'user',
        'label' => t('Add the anonymous role to the selected users'),
        'label' => $this->t('Add the anonymous role to the selected users'),
        'configuration' => [
        'rid' => RoleInterface::ANONYMOUS_ID,
        ],
        ......
        ......@@ -6,6 +6,7 @@
        use Drupal\Core\EventSubscriber\MainContentViewSubscriber;
        use Drupal\Core\Language\LanguageInterface;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\Core\Url;
        use Drupal\language\Entity\ConfigurableLanguage;
        use Drupal\Tests\BrowserTestBase;
        ......@@ -31,6 +32,8 @@
        */
        class ToolbarAdminMenuTest extends BrowserTestBase {
        use StringTranslationTrait;
        /**
        * A user with permission to access the administrative toolbar.
        *
        ......@@ -309,7 +312,7 @@ public function testLocaleTranslationSubtreesHashCacheClear(): void {
        $this->drupalGet('admin/config/regional/language/add');
        $this->submitForm($edit, 'Add custom language');
        // phpcs:ignore Drupal.Semantics.FunctionT.NotLiteralString
        t($name, [], ['langcode' => $langcode]);
        $this->t($name, [], ['langcode' => $langcode]);
        // Reset locale cache.
        $this->container->get('string_translation')->reset();
        $this->assertSession()->responseContains('"edit-languages-' . $langcode . '-weight"');
        ......
        ......@@ -192,6 +192,7 @@
        <include-pattern>*/tests/*/Form/*</include-pattern>
        <include-pattern>*/modules/system/tests/modules/*</include-pattern>
        <include-pattern>*/Kernel*/*</include-pattern>
        <include-pattern>*/tests/*/Functional*/*</include-pattern>
        </rule>
        <!-- Generic sniffs -->
        ......
        ......@@ -4,6 +4,7 @@
        namespace Drupal\FunctionalTests\Installer;
        use Drupal\Core\StringTranslation\StringTranslationTrait;
        use Drupal\Tests\BrowserTestBase;
        // cspell:ignore montag
        ......@@ -15,6 +16,8 @@
        */
        class InstallerTranslationMultipleLanguageNonInteractiveTest extends BrowserTestBase {
        use StringTranslationTrait;
        /**
        * {@inheritdoc}
        */
        ......@@ -124,7 +127,7 @@ public function testTranslationsLoaded(): void {
        $this->assertEquals('Anonymous es', $override_es->get('anonymous'));
        // Test translation from locale_test module.
        $this->assertEquals('Montag', t('Monday', [], ['langcode' => 'de']));
        $this->assertEquals('Montag', $this->t('Monday', [], ['langcode' => 'de']));
        }
        /**
        ......
        0% Loading or .
        You are about to add 0 people to the discussion. Proceed with caution.
        Please register or to comment