class NameUnicodeExtrasTest in Name Field 8
Tests the unicode additional functions.
@group name
Hierarchy
- class \Drupal\Tests\UnitTestCase extends \PHPUnit\Framework\TestCase uses PhpunitCompatibilityTrait
- class \Drupal\Tests\name\Unit\NameUnicodeExtrasTest
Expanded class hierarchy of NameUnicodeExtrasTest
File
- tests/
src/ Unit/ NameUnicodeExtrasTest.php, line 13
Namespace
Drupal\Tests\name\UnitView source
class NameUnicodeExtrasTest extends UnitTestCase {
/**
* {@inheritdoc}
*/
public static function getInfo() {
return [
'name' => 'NameUnicodeExtras Test',
'description' => 'Test NameUnicodeExtras additional functions',
'group' => 'Name',
];
}
/**
* Convert names() to PHPUnit compatible format.
*
* @return array
* An array of names.
*/
public function patternDataProvider() {
$data = [];
foreach ($this
->languageStrings() as $language => $info) {
$data[] = [
$language,
$info['string'],
$info['count'],
$info['initials'],
];
}
return $data;
}
/**
* Test NameUnicodeExtras functions.
*
* @dataProvider patternDataProvider
*/
public function testNameUnicodeExtras($language, $text, $count, $expected_initials) {
$parts = NameUnicodeExtras::explode($text);
$initials = NameUnicodeExtras::initials($text);
$this
->assertEquals(count($parts), $count, 'Count parts for ' . $language . ' explode match.');
$this
->assertEquals($initials, $expected_initials, 'Initials for ' . $language . ' explode match. ' . $initials . ' ');
}
/**
* Helper function to provide data for the tests.
*
* @return array
* A keyed array of test data in misc languages.
*/
protected function languageStrings() {
return [
'english' => [
'string' => 'A fat cat sat on the mat',
'count' => 7,
'initials' => 'AFCSOTM',
],
'greek' => [
'string' => 'Σὲ γνωρίζω ἀπὸ τὴν κόψη',
'count' => 5,
'initials' => 'ΣΓἈΤΚ',
],
'georgian' => [
'string' => 'გთხოვთ ახლავე გაიაროთ რეგისტრაცია',
'count' => 4,
'initials' => 'გაგრ',
],
'russian' => [
'string' => 'Зарегистрируйтесь сейчас на Десятую Международную Конференцию',
'count' => 6,
'initials' => 'ЗСНДМК',
],
'ethiopian' => [
'string' => 'ሰማይ አይታረስ ንጉሥ አይከሰስ',
'count' => 4,
'initials' => 'ሰአንአ',
],
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NameUnicodeExtrasTest:: |
public static | function | ||
NameUnicodeExtrasTest:: |
protected | function | Helper function to provide data for the tests. | |
NameUnicodeExtrasTest:: |
public | function | Convert names() to PHPUnit compatible format. | |
NameUnicodeExtrasTest:: |
public | function | Test NameUnicodeExtras functions. | |
PhpunitCompatibilityTrait:: |
public | function | Returns a mock object for the specified class using the available method. | |
PhpunitCompatibilityTrait:: |
public | function | Compatibility layer for PHPUnit 6 to support PHPUnit 4 code. | |
UnitTestCase:: |
protected | property | The random generator. | |
UnitTestCase:: |
protected | property | The app root. | 1 |
UnitTestCase:: |
protected | function | Asserts if two arrays are equal by sorting them first. | |
UnitTestCase:: |
protected | function | Mocks a block with a block plugin. | 1 |
UnitTestCase:: |
protected | function | Returns a stub class resolver. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
protected | function | Sets up a container with a cache tags invalidator. | |
UnitTestCase:: |
protected | function | Gets the random generator for the utility methods. | |
UnitTestCase:: |
public | function | Returns a stub translation manager that just returns the passed string. | |
UnitTestCase:: |
public | function | Generates a unique random string containing letters and numbers. | |
UnitTestCase:: |
protected | function | 340 |