public function FieldRawValueTest::providerTestRawValues in Twig Field Value 8
Same name and namespace in other branches
- 2.0.x tests/src/Unit/FieldValue/FieldRawValueTest.php \Drupal\Tests\twig_field_value\Unit\FieldValue\FieldRawValueTest::providerTestRawValues()
Provides data and expected results for the test method.
Return value
array Data and expected results.
File
- tests/
src/ Unit/ FieldValue/ FieldRawValueTest.php, line 69
Class
- FieldRawValueTest
- @coversDefaultClass \Drupal\twig_field_value\Twig\Extension\FieldValueExtension @group twig_field_value
Namespace
Drupal\Tests\twig_field_value\Unit\FieldValueCode
public function providerTestRawValues() {
return [
// Invalid render arrays.
[
NULL,
NULL,
'',
],
[
NULL,
[],
'',
],
[
NULL,
[
'#theme' => 'field',
'#no_items' => [],
],
'',
],
[
NULL,
[
'#theme' => 'field',
'#items' => [],
],
'',
],
[
NULL,
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem(NULL),
],
'',
],
// Request all values, field with single value.
[
[
'value' => 'text_value',
],
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem([
[
'value' => 'text_value',
],
]),
],
'',
],
// Request all values, field with multiple values.
[
[
'alt' => 'alt_value',
'title' => 'title_value',
],
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem([
[
'alt' => 'alt_value',
'title' => 'title_value',
],
]),
],
'',
],
// Request 'foo', but value not exist.
[
NULL,
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem([
[
'alt' => 'alt_value',
'title' => 'title_value',
],
]),
],
'foo',
],
// Request 'alt' value, field cardinality = 1.
[
'alt_value',
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem([
[
'alt' => 'alt_value',
'title' => 'title_value',
],
]),
],
'alt',
],
// Request all values, field cardinality = 2.
[
[
[
'alt' => 'alt_value_1',
'title' => 'title_value_1',
],
[
'alt' => 'alt_value_2',
'title' => 'title_value_2',
],
],
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem([
[
'alt' => 'alt_value_1',
'title' => 'title_value_1',
],
[
'alt' => 'alt_value_2',
'title' => 'title_value_2',
],
]),
],
'',
],
// Request 'alt' value, field cardinality = 2.
[
[
'alt_value_1',
'alt_value_2',
],
[
'#theme' => 'field',
'#items' => $this
->mockFieldItem([
[
'alt' => 'alt_value_1',
'title' => 'title_value_1',
],
[
'alt' => 'alt_value_2',
'title' => 'title_value_2',
],
]),
],
'alt',
],
];
}