public function EntityTypeTest::testGetCountLabel in Drupal 8
Same name and namespace in other branches
- 9 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 394
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'));
}