You are here

public function OrderTokensTest::testTokens in Commerce Core 8.2

Tests URL tokens for orders.

@dataProvider tokensTestData

File

modules/order/tests/src/Kernel/OrderTokensTest.php, line 36

Class

OrderTokensTest
Tests the order tokens.

Namespace

Drupal\Tests\commerce_order\Kernel

Code

public function testTokens(string $test_token, string $expected_replacement) {
  $token = $this->container
    ->get('token');
  $user = User::create([
    'uid' => '456',
    'name' => 'foobar',
    'mail' => 'foobar@example.com',
  ]);
  $user
    ->enforceIsNew(FALSE);
  $order = Order::create([
    'order_id' => '123',
    'uid' => $user,
    'type' => 'default',
  ]);
  $order
    ->enforceIsNew(FALSE);
  $token_data = [
    'commerce_order' => $order,
  ];
  $bubbleable_metadata = new BubbleableMetadata();
  $this
    ->assertEquals($expected_replacement, $token
    ->replace($test_token, $token_data, [], $bubbleable_metadata));
  $this
    ->assertEquals([
    'commerce_order:123',
  ], $bubbleable_metadata
    ->getCacheTags());
}