function EntityTypeTest::testGetCountLabel
Same name in other branches
- 8.9.x core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testGetCountLabel()
- 10 core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testGetCountLabel()
- 11.x core/tests/Drupal/Tests/Core/Entity/EntityTypeTest.php \Drupal\Tests\Core\Entity\EntityTypeTest::testGetCountLabel()
@covers ::getCountLabel
File
-
core/
tests/ Drupal/ Tests/ Core/ Entity/ EntityTypeTest.php, line 393
Class
- EntityTypeTest
- @coversDefaultClass \Drupal\Core\Entity\EntityType @group Entity
Namespace
Drupal\Tests\Core\EntityCode
public function testGetCountLabel() {
$entity_type = $this->setUpEntityType([
'label_count' => [
'singular' => 'one entity test',
'plural' => '@count entity test',
],
]);
$entity_type->setStringTranslation($this->getStringTranslationStub());
$this->assertEquals('one entity test', $entity_type->getCountLabel(1));
$this->assertEquals('2 entity test', $entity_type->getCountLabel(2));
$this->assertEquals('200 entity test', $entity_type->getCountLabel(200));
$this->assertArrayNotHasKey('context', $entity_type->getCountLabel(1)
->getOptions());
// Test a custom context.
$entity_type = $this->setUpEntityType([
'label_count' => [
'singular' => 'one entity test',
'plural' => '@count entity test',
'context' => 'custom context',
],
]);
$entity_type->setStringTranslation($this->getStringTranslationStub());
$this->assertSame('custom context', $entity_type->getCountLabel(1)
->getOption('context'));
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.