AdjustmentComparator.php in Commerce Core 8.2
File
modules/order/src/Comparator/AdjustmentComparator.php
View source
<?php
namespace Drupal\commerce_order\Comparator;
use Drupal\commerce_order\Adjustment;
use SebastianBergmann\Comparator\Comparator;
use SebastianBergmann\Comparator\ComparisonFailure;
class AdjustmentComparator extends Comparator {
public function accepts($expected, $actual) {
return $expected instanceof Adjustment && $actual instanceof Adjustment;
}
public function assertEquals($expected, $actual, $delta = 0.0, $canonicalize = FALSE, $ignoreCase = FALSE) {
assert($expected instanceof Adjustment);
assert($actual instanceof Adjustment);
$expected_array = $expected
->toArray();
$actual_array = $actual
->toArray();
unset($expected_array['amount'], $actual_array['amount']);
if (!$actual
->getAmount()
->equals($expected
->getAmount()) || $expected_array !== $actual_array) {
throw new ComparisonFailure($expected, $actual, var_export($expected, TRUE), var_export($actual, TRUE), FALSE, sprintf('Failed asserting that Adjustment "%s" matches expected "%s".', $actual
->getLabel(), $expected
->getLabel()));
}
}
}