diff --git a/core/modules/node/tests/src/Functional/NodeTypePluralLabelsTranslationTest.php b/core/modules/node/tests/src/Functional/NodeTypePluralLabelsTranslationTest.php index ed091b4..b369a4f 100644 --- a/core/modules/node/tests/src/Functional/NodeTypePluralLabelsTranslationTest.php +++ b/core/modules/node/tests/src/Functional/NodeTypePluralLabelsTranslationTest.php @@ -3,6 +3,7 @@ namespace Drupal\Tests\node\Functional; use Drupal\Component\Gettext\PoHeader; +use Drupal\Core\StringTranslation\PluralTranslatableMarkup; use Drupal\language\Entity\ConfigurableLanguage; use Drupal\node\Entity\NodeType; use Drupal\Tests\BrowserTestBase; @@ -69,7 +70,7 @@ public function testNodeTypeTranslation() { $this->drupalGet('admin/structure/types/add'); - // Romanian language has 3 plural variants + // Check that 3 plural variants are exposed for the Romanian language. $this->assertSession()->fieldExists('label_count[0]'); $this->assertSession()->fieldExists('label_count[1]'); $this->assertSession()->fieldExists('label_count[2]'); @@ -98,7 +99,7 @@ public function testNodeTypeTranslation() { /** @var \Drupal\node\Entity\NodeType $node_type */ $node_type = NodeType::load('child'); - // Test the default language (Romanian) original labels. + // Check that the default language (Romanian) original labels were stored. self::assertEquals($node_type->label(), 'Copil'); self::assertEquals($node_type->getSingularLabel(), 'copil'); self::assertEquals($node_type->getPluralLabel(), 'copii'); @@ -113,13 +114,25 @@ public function testNodeTypeTranslation() { $node_type = NodeType::load('child'); $language_manager->setConfigOverrideLanguage($original_language); - // Test the additional language (English) translated labels. + // Check that the English translated labels were stored. self::assertEquals($node_type->label(), 'Child'); self::assertEquals($node_type->getSingularLabel(), 'child'); self::assertEquals($node_type->getPluralLabel(), 'children'); self::assertEquals($node_type->getCountLabel(1), '1 child'); self::assertEquals($node_type->getCountLabel(5), '5 children'); self::assertEquals($node_type->getCountLabel(20), '20 children'); + + // Clear the count label second variant to test variant delta preserving. + $edit = ['label_count[1]' => '']; + $this->drupalPostForm($node_type->urlInfo('edit-form'), $edit, t('Save content type')); + + $node_type = NodeType::load('child'); + + // Check that the variants delta has been preserved. + $variants = explode(PluralTranslatableMarkup::DELIMITER, $node_type->get('label_count')); + self::assertEquals($variants[0], '1 copil'); + self::assertEquals($variants[1], ''); + self::assertEquals($variants[2], '@count de copii'); } }