class PluralTranslationTest

Same name and namespace in other branches
  1. 11.x core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
  2. 10 core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
  3. 9 core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
  4. 8.9.x core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest

Tests Drupal\Core\Annotation\PluralTranslation.

Attributes

#[CoversClass(PluralTranslation::class)] #[Group('Annotation')]

Hierarchy

Expanded class hierarchy of PluralTranslationTest

File

core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php, line 17

Namespace

Drupal\Tests\Core\Annotation
View source
class PluralTranslationTest extends UnitTestCase {
  
  /**
   * Tests get.
   */
  public function testGet(array $values) : void {
    $annotation = new PluralTranslation($values);
    $default_values = [
      'context' => NULL,
    ];
    $this->assertEquals($values + $default_values, $annotation->get());
  }
  
  /**
   * Provides data to self::testGet().
   */
  public static function providerTestGet() : array {
    $data = [];
    $data[] = [
      [
        'singular' => Random::machineName(),
        'plural' => Random::machineName(),
        'context' => Random::machineName(),
      ],
    ];
    $data[] = [
      [
        'singular' => Random::machineName(),
        'plural' => Random::machineName(),
      ],
    ];
    return $data;
  }
  
  /**
   * Tests missing data.
   */
  public function testMissingData($data) : void {
    $this->expectException(\InvalidArgumentException::class);
    new PluralTranslation($data);
  }
  public static function providerTestMissingData() : array {
    $data = [];
    $data['all-missing'] = [
      [],
    ];
    $data['singular-missing'] = [
      [
        'plural' => 'muh',
      ],
    ];
    $data['plural-missing'] = [
      [
        'singular' => 'muh',
      ],
    ];
    return $data;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.