assertTranslation example

$this->setUpTranslation('locale_test.translation', 'test', 'English test', 'German test', 'de');
    $this->setUpTranslation('locale_test.translation_multiple', 'test', 'English test', 'German test', 'de');
  }

  /** * Tests creating translations of shipped configuration. */
  public function testCreateTranslation() {
    $config_name = 'locale_test.no_translation';

    $this->saveLanguageOverride($config_name, 'test', 'Test (German)', 'de');
    $this->assertTranslation($config_name, 'Test (German)', 'de');
  }

  /** * Tests creating translations configuration with multi value settings. */
  public function testCreateTranslationMultiValue() {
    $config_name = 'locale_test.translation_multiple';

    $this->saveLanguageOverride($config_name, 'test_multiple', ['string' => 'String (German)', 'another_string' => 'Another string (German)'], 'de');
    $this->saveLanguageOverride($config_name, 'test_after_multiple', ['string' => 'After string (German)', 'another_string' => 'After another string (German)'], 'de');
    $strings = $this->stringStorage->getTranslations([
      

    $this->drupalGet('admin/config/regional/translate/settings');
    $this->submitForm($edit, 'Save configuration');

    // Execute translation update.     $this->drupalGet('admin/reports/translations/check');
    $this->drupalGet('admin/reports/translations');
    $this->submitForm([], 'Update translations');

    // Check whether existing translations have (not) been overwritten.     // cSpell:disable     $this->assertTranslation('January', 'Januar_customized', 'de');
    $this->assertTranslation('February', 'Februar_customized', 'de');
    $this->assertTranslation('March', 'Marz', 'de');
    $this->assertTranslation('April', 'April_2', 'de');
    $this->assertTranslation('May', 'Mai_customized', 'de');
    $this->assertTranslation('June', 'Juni', 'de');
    $this->assertTranslation('Monday', 'Montag', 'de');
    // cSpell:enable   }

  /** * Tests automatic translation import when a module is enabled. */

class TranslationTest extends TestCase
{
    use AdminFunctionalTestBehaviour;

    public function testNoOverride(): void
    {
        $langId = Uuid::randomHex();
        $this->createLanguage($langId);

        $this->assertTranslation(
            ['name' => 'not translated', 'translated' => ['name' => 'not translated']],
            [
                'translations' => [
                    Defaults::LANGUAGE_SYSTEM => ['name' => 'not translated'],
                    $langId => ['name' => 'translated'],
                ],
            ]
        );
    }

    public function testDefault(): void
    {
$this->assertEquals('hu', $this->configFactory->getEditable('locale_test.no_translation')->get('langcode'));
    $this->assertEquals('hu', $this->configFactory->getEditable('locale_test.translation')->get('langcode'));
    $this->assertEquals('Hungarian test', $this->configFactory->getEditable('locale_test.translation')->get('test'));
  }

  /** * Tests creating translations of shipped configuration. */
  public function testCreateActiveTranslation() {
    $config_name = 'locale_test.no_translation';
    $this->saveLanguageActive($config_name, 'test', 'Test (Hungarian)', 'hu');
    $this->assertTranslation($config_name, 'Test (Hungarian)', 'hu');
  }

  /** * Tests importing community translations of shipped configuration. */
  public function testLocaleCreateActiveTranslation() {
    $config_name = 'locale_test.no_translation';
    $this->saveLocaleTranslationData($config_name, 'test', 'Test', 'Test (Hungarian)', 'hu', TRUE);
    $this->assertTranslation($config_name, 'Test (Hungarian)', 'hu', FALSE);
  }

  
static::assertEquals('foo', $this->getBrowser()->getRequest()->headers->get('sw-custom-header'));
        static::assertArrayNotHasKey('sw-custom-header', $this->getBrowser()->getResponse()->headers->all());
    }

    public function testDifferentLanguage(): void
    {
        $langId = Uuid::randomHex();
        $salesChannel = $this->createSalesChannel();
        $this->createLanguage($langId$salesChannel['id']);

        $this->assertTranslation(
            ['name' => 'not translated', 'translated' => ['name' => 'not translated']],
            [
                'translations' => [
                    Defaults::LANGUAGE_SYSTEM => ['name' => 'not translated'],
                    $langId => ['name' => 'translated'],
                ],
            ],
            $salesChannel['id'],
            Defaults::LANGUAGE_SYSTEM
        );

        
Home | Imprint | This part of the site doesn't use cookies.