function JsonApiSpecTest::providerTestIsValidMemberName
Same name in other branches
- 8.9.x core/modules/jsonapi/tests/src/Unit/JsonApiSpecTest.php \Drupal\Tests\jsonapi\Unit\JsonApiSpecTest::providerTestIsValidMemberName()
- 10 core/modules/jsonapi/tests/src/Unit/JsonApiSpecTest.php \Drupal\Tests\jsonapi\Unit\JsonApiSpecTest::providerTestIsValidMemberName()
- 11.x core/modules/jsonapi/tests/src/Unit/JsonApiSpecTest.php \Drupal\Tests\jsonapi\Unit\JsonApiSpecTest::providerTestIsValidMemberName()
Data provider for testIsValidMemberName.
1 call to JsonApiSpecTest::providerTestIsValidMemberName()
- JsonApiSpecTest::providerTestIsValidCustomQueryParameter in core/
modules/ jsonapi/ tests/ src/ Unit/ JsonApiSpecTest.php - Data provider for testIsValidCustomQueryParameter.
File
-
core/
modules/ jsonapi/ tests/ src/ Unit/ JsonApiSpecTest.php, line 29
Class
- JsonApiSpecTest
- @coversDefaultClass \Drupal\jsonapi\JsonApiSpec @group jsonapi
Namespace
Drupal\Tests\jsonapi\UnitCode
public function providerTestIsValidMemberName() {
// Copied from http://jsonapi.org/format/upcoming/#document-member-names.
$data = [];
$data['alphanumeric-lowercase'] = [
'12kittens',
TRUE,
];
$data['alphanumeric-uppercase'] = [
'12KITTENS',
TRUE,
];
$data['alphanumeric-mixed'] = [
'12KiTtEnS',
TRUE,
];
$data['unicode-above-u+0080'] = [
'12🐱🐱',
TRUE,
];
$data['hyphen-start'] = [
'-kittens',
FALSE,
];
$data['hyphen-middle'] = [
'kitt-ens',
TRUE,
];
$data['hyphen-end'] = [
'kittens-',
FALSE,
];
$data['lowline-start'] = [
'_kittens',
FALSE,
];
$data['lowline-middle'] = [
'kitt_ens',
TRUE,
];
$data['lowline-end'] = [
'kittens_',
FALSE,
];
$data['space-start'] = [
' kittens',
FALSE,
];
$data['space-middle'] = [
'kitt ens',
TRUE,
];
$data['space-end'] = [
'kittens ',
FALSE,
];
// Additional test cases.
// @todo When D8 requires PHP >= 7, convert to \u{10FFFF}.
$data['unicode-above-u+0080-highest-allowed'] = [
"12",
TRUE,
];
$data['single-character'] = [
'a',
TRUE,
];
$unsafe_chars = [
'+',
',',
'.',
'[',
']',
'!',
'"',
'#',
'$',
'%',
'&',
'\'',
'(',
')',
'*',
'/',
':',
';',
'<',
'=',
'>',
'?',
'@',
'\\',
'^',
'`',
'{',
'|',
'}',
'~',
];
foreach ($unsafe_chars as $unsafe_char) {
$data['unsafe-' . $unsafe_char] = [
'kitt' . $unsafe_char . 'ens',
FALSE,
];
}
// The ASCII control characters are in the range 0x00 to 0x1F plus 0x7F.
for ($ascii = 0; $ascii <= 0x1f; $ascii++) {
$data['unsafe-ascii-control-' . $ascii] = [
'kitt' . chr($ascii) . 'ens',
FALSE,
];
}
$data['unsafe-ascii-control-' . 0x7f] = [
'kitt' . chr(0x7f) . 'ens',
FALSE,
];
return $data;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.