You are here

public function OrderTotalPriceTest::testEvaluate in Commerce Core 8.2

::covers evaluate.

@dataProvider totalPriceProvider

File

modules/order/tests/src/Unit/Plugin/Commerce/Condition/OrderTotalPriceTest.php, line 59

Class

OrderTotalPriceTest
@coversDefaultClass \Drupal\commerce_order\Plugin\Commerce\Condition\OrderTotalPrice @group commerce

Namespace

Drupal\Tests\commerce_order\Unit\Plugin\Commerce\Condition

Code

public function testEvaluate($operator, $total_price, $given_total_price, $result) {
  $condition = new OrderTotalPrice([
    'operator' => $operator,
    'amount' => [
      'number' => $total_price,
      'currency_code' => 'USD',
    ],
  ], 'order_total_price', [
    'entity_type' => 'commerce_order',
  ]);
  $order = $this
    ->prophesize(OrderInterface::class);
  $order
    ->getEntityTypeId()
    ->willReturn('commerce_order');
  $order
    ->getTotalPrice()
    ->willReturn(new Price($given_total_price, 'USD'));
  $order = $order
    ->reveal();
  $this
    ->assertEquals($result, $condition
    ->evaluate($order));
}