public function RadioactivityFunctionTestTrait::assertFieldEnergyValue in Radioactivity 8.3
Same name and namespace in other branches
- 4.0.x tests/src/Traits/RadioactivityFunctionTestTrait.php \Drupal\Tests\radioactivity\Traits\RadioactivityFunctionTestTrait::assertFieldEnergyValue()
Assert the energy values from a field.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The host entity of the field.
string $fieldName: The field to be asserted.
array|string|int $expectedValues: The expected field values.
string $operator: The operator to be used to compare. Allowed values: '>', '>=', '<', '<=', '=='. The actual value on the left, the expected on the right.
string $message: The assertion message.
1 call to RadioactivityFunctionTestTrait::assertFieldEnergyValue()
- EmitTest::testCount in tests/
src/ FunctionalJavascript/ EmitTest.php - Tests Radioactivity count functionality.
File
- tests/
src/ Traits/ RadioactivityFunctionTestTrait.php, line 307
Class
- RadioactivityFunctionTestTrait
- Radioactivity functional test trait.
Namespace
Drupal\Tests\radioactivity\TraitsCode
public function assertFieldEnergyValue(EntityInterface $entity, $fieldName, $expectedValues, $operator = '==', $message = '') {
$expectedValues = is_array($expectedValues) ? $expectedValues : [
$expectedValues,
];
$actualValues = array_map(function ($item) {
return $item['energy'];
}, $entity
->get($fieldName)
->getValue());
$this
->assertEnergyValues($fieldName, $actualValues, $expectedValues, $operator, $message);
}