You are here

public function ShipmentWeightTest::testEvaluate in Commerce Shipping 8.2

::covers evaluate.

@dataProvider totalWeightProvider

File

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

Class

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

Namespace

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

Code

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