class PluralTranslationTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Annotation/PluralTranslationTest.php \Drupal\Tests\Core\Annotation\PluralTranslationTest
- 10 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
@coversDefaultClass \Drupal\Core\Annotation\PluralTranslation
@group Annotation
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Annotation\PluralTranslationTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of PluralTranslationTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Annotation/ PluralTranslationTest.php, line 12
Namespace
Drupal\Tests\Core\AnnotationView source
class PluralTranslationTest extends UnitTestCase {
/**
* @covers ::get
*
* @dataProvider providerTestGet
*/
public function testGet(array $values) {
$annotation = new PluralTranslation($values);
$default_values = [
'context' => NULL,
];
$this->assertEquals($values + $default_values, $annotation->get());
}
/**
* Provides data to self::testGet().
*/
public function providerTestGet() {
$data = [];
$data[] = [
[
'singular' => $this->randomMachineName(),
'plural' => $this->randomMachineName(),
'context' => $this->randomMachineName(),
],
];
$data[] = [
[
'singular' => $this->randomMachineName(),
'plural' => $this->randomMachineName(),
],
];
return $data;
}
/**
* @dataProvider providerTestMissingData
*/
public function testMissingData($data) {
$this->expectException(\InvalidArgumentException::class);
new PluralTranslation($data);
}
public function providerTestMissingData() {
$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.