function FieldItemListTest::providerTestEquals
Same name in other branches
- 9 core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php \Drupal\Tests\Core\Field\FieldItemListTest::providerTestEquals()
- 8.9.x core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php \Drupal\Tests\Core\Field\FieldItemListTest::providerTestEquals()
- 10 core/tests/Drupal/Tests/Core/Field/FieldItemListTest.php \Drupal\Tests\Core\Field\FieldItemListTest::providerTestEquals()
Data provider for testEquals.
File
-
core/
tests/ Drupal/ Tests/ Core/ Field/ FieldItemListTest.php, line 81
Class
- FieldItemListTest
- @coversDefaultClass \Drupal\Core\Field\FieldItemList @group Field
Namespace
Drupal\Tests\Core\FieldCode
public static function providerTestEquals() {
// Tests field item lists with no values.
$datasets[] = [
TRUE,
];
/** @var \Drupal\Core\Field\FieldItemBase $field_item_a */
$field_item_a = new FieldItemTestClass();
$field_item_a->setValue([
1,
]);
// Tests field item lists where one has a value and one does not.
$datasets[] = [
FALSE,
$field_item_a,
];
// Tests field item lists where both have the same value.
$datasets[] = [
TRUE,
$field_item_a,
$field_item_a,
];
/** @var \Drupal\Core\Field\FieldItemBase $fv */
$field_item_b = new FieldItemTestClass();
$field_item_b->setValue([
2,
]);
// Tests field item lists where both have the different values.
$datasets[] = [
FALSE,
$field_item_a,
$field_item_b,
];
/** @var \Drupal\Core\Field\FieldItemBase $fv */
$field_item_c = new FieldItemTestClass();
$field_item_c->setValue([
'0' => 1,
'1' => 2,
]);
$field_item_d = new FieldItemTestClass();
$field_item_d->setValue([
'1' => 2,
'0' => 1,
]);
// Tests field item lists where both have the differently ordered values.
$datasets[] = [
TRUE,
$field_item_c,
$field_item_d,
];
/** @var \Drupal\Core\Field\FieldItemBase $field_item_e */
$field_item_e = new FieldItemTestClass();
$field_item_e->setValue([
'2',
]);
// Tests field item lists where both have same values but different data
// types.
$datasets[] = [
TRUE,
$field_item_b,
$field_item_e,
];
/** @var \Drupal\Core\Field\FieldItemBase $field_item_f */
$field_item_f = new FieldItemTestClass();
$field_item_f->setValue([
'0' => 1,
'1' => 2,
'2' => 3,
]);
/** @var \Drupal\Core\Field\FieldItemBase $field_item_g */
$field_item_g = new FieldItemTestClass();
$field_item_g->setValue([
'0' => 1,
'1' => 2,
'2' => 4,
]);
// Tests field item lists where both have same values for the non-computed
// properties ('0' and '1') and a different value for the computed one
// ('2').
$datasets[] = [
TRUE,
$field_item_f,
$field_item_g,
];
/** @var \Drupal\Core\Field\FieldItemBase $field_item_h */
$field_item_h = new FieldItemTestClass();
$field_item_h->setValue([
'0' => 1,
'1' => 2,
'3' => 3,
]);
/** @var \Drupal\Core\Field\FieldItemBase $field_item_i */
$field_item_i = new FieldItemTestClass();
$field_item_i->setValue([
'0' => 1,
'1' => 2,
'3' => 4,
]);
// Tests field item lists where both have same values for the non-computed
// properties ('0' and '1') and a different value for a property that does
// not exist ('3').
$datasets[] = [
TRUE,
$field_item_h,
$field_item_i,
];
/** @var \Drupal\Core\Field\FieldItemBase $field_item_j */
$field_item_j = new FieldItemTestClass();
$field_item_j->setValue([
'0' => 1,
]);
/** @var \Drupal\Core\Field\FieldItemBase $field_item_k */
$field_item_k = new FieldItemTestClass();
$field_item_k->setValue([
'0' => 1,
'1' => NULL,
]);
/** @var \Drupal\Core\Field\FieldItemBase $field_item_l */
$field_item_l = new FieldItemTestClass();
$field_item_l->setValue([
'0' => 1,
'1' => FALSE,
]);
/** @var \Drupal\Core\Field\FieldItemBase $field_item_m */
$field_item_m = new FieldItemTestClass();
$field_item_m->setValue([
'0' => 1,
'1' => '',
]);
// Tests filter properties with a NULL value. Empty strings or other false-y
// values are not filtered.
$datasets[] = [
TRUE,
$field_item_j,
$field_item_k,
];
$datasets[] = [
FALSE,
$field_item_j,
$field_item_l,
];
$datasets[] = [
FALSE,
$field_item_j,
$field_item_m,
];
return $datasets;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.