class MeasurementComparator in Physical Fields 8
Provides a PHPUnit comparator for measurements.
Hierarchy
- class \Drupal\physical\Comparator\MeasurementComparator extends \SebastianBergmann\Comparator\Comparator
Expanded class hierarchy of MeasurementComparator
2 files declare their use of MeasurementComparator
- DimensionsItemTest.php in tests/
src/ Kernel/ DimensionsItemTest.php - MeasurementItemTest.php in tests/
src/ Kernel/ MeasurementItemTest.php
File
- src/
Comparator/ MeasurementComparator.php, line 12
Namespace
Drupal\physical\ComparatorView source
class MeasurementComparator extends Comparator {
/**
* {@inheritdoc}
*/
public function accepts($expected, $actual) {
return $expected instanceof Measurement && $actual instanceof Measurement;
}
/**
* {@inheritdoc}
*/
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = FALSE, $ignoreCase = FALSE) {
assert($expected instanceof Measurement);
assert($actual instanceof Measurement);
if (!$actual
->equals($expected)) {
throw new ComparisonFailure($expected, $actual, (string) $expected, (string) $actual, FALSE, sprintf('Failed asserting that Measurement %s matches expected %s.', $actual, $expected));
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MeasurementComparator:: |
public | function | Returns whether the comparator can compare two values. | |
MeasurementComparator:: |
public | function | Asserts that two values are equal. |