You are here

public function ShipmentWeightTest::testMismatchedUnits in Commerce Shipping 8.2

::covers evaluate.

File

tests/src/Unit/Plugin/Commerce/Condition/ShipmentWeightTest.php, line 19

Class

ShipmentWeightTest
@coversDefaultClass \Drupal\commerce_shipping\Plugin\Commerce\Condition\ShipmentWeight @group commerce

Namespace

Drupal\Tests\commerce_shipping\Unit\Plugin\Commerce\Condition

Code

public function testMismatchedUnits() {
  $condition = new ShipmentWeight([
    'operator' => '==',
    'weight' => [
      'number' => '1000.00',
      'unit' => 'g',
    ],
  ], 'shipment_weight', [
    'entity_type' => 'commerce_shipment',
  ]);
  $shipment = $this
    ->prophesize(ShipmentInterface::class);
  $shipment
    ->getEntityTypeId()
    ->willReturn('commerce_shipment');
  $shipment
    ->getWeight()
    ->willReturn(new Weight('1.00', 'kg'));
  $shipment = $shipment
    ->reveal();
  $this
    ->assertTrue($condition
    ->evaluate($shipment));
}