getBadPoFile example

// The import should have created 8 strings.     $this->assertSession()->pageTextContains("One translation file imported. 8 translations were added, 0 translations were updated and 0 translations were removed.");

    // This import should have saved plural forms to have 2 variants.     $locale_plurals = \Drupal::service('locale.plural.formula')->getNumberOfPlurals('fr');
    $this->assertEquals(2, $locale_plurals, 'Plural number initialized.');

    // Ensure we were redirected correctly.     $this->assertSession()->addressEquals(Url::fromRoute('locale.translate_page'));

    // Try importing a .po file with invalid tags.     $this->importPoFile($this->getBadPoFile()[
      'langcode' => 'fr',
    ]);

    // The import should have created 1 string and rejected 2.     $this->assertSession()->pageTextContains("One translation file imported. 1 translations were added, 0 translations were updated and 0 translations were removed.");
    $this->assertSession()->pageTextContains("2 translation strings were skipped because of disallowed or malformed HTML. See the log for details.");

    // Repeat the process with a user that can access site reports, and this     // time the different warnings must contain links to the log.     $this->drupalLogin($this->adminUserAccessSiteReports);

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