class PluralTranslationTest
Same name and namespace in other branches
- 9 core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
- 8.9.x core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
- 11.x core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
@coversDefaultClass \Drupal\Core\Annotation\PluralTranslation
@group Annotation
Hierarchy
- class \Drupal\Tests\Core\Annotation\PluralTranslationTest
Expanded class hierarchy of PluralTranslationTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Annotation/ PluralTranslationTest.php, line 15
Namespace
Drupal\Tests\Core\AnnotationView source
class PluralTranslationTest extends UnitTestCase {
/**
* @covers ::get
*
* @dataProvider providerTestGet
*/
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() {
$data = [];
$data[] = [
[
'singular' => Random::machineName(),
'plural' => Random::machineName(),
'context' => Random::machineName(),
],
];
$data[] = [
[
'singular' => Random::machineName(),
'plural' => Random::machineName(),
],
];
return $data;
}
/**
* @dataProvider providerTestMissingData
*/
public function testMissingData($data) : void {
$this->expectException(\InvalidArgumentException::class);
new PluralTranslation($data);
}
public static function providerTestMissingData() {
$data = [];
$data['all-missing'] = [
[],
];
$data['singular-missing'] = [
[
'plural' => 'muh',
],
];
$data['plural-missing'] = [
[
'singular' => 'muh',
],
];
return $data;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
PluralTranslationTest::providerTestGet | public static | function | Provides data to self::testGet(). |
PluralTranslationTest::providerTestMissingData | public static | function | |
PluralTranslationTest::testGet | public | function | @covers ::get[[api-linebreak]] |
PluralTranslationTest::testMissingData | public | function | @dataProvider providerTestMissingData |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.