You are here

public function RemoteIdItemTest::testField in Commerce Core 8.2

Tests the field.

File

tests/src/Kernel/RemoteIdItemTest.php, line 47

Class

RemoteIdItemTest
Tests the 'commerce_remote_id' field type.

Namespace

Drupal\Tests\commerce\Kernel

Code

public function testField() {
  $entity = EntityTest::create([
    'test_remote_id' => [
      'provider' => 'braintree',
      'remote_id' => '123',
    ],
  ]);
  $entity
    ->save();
  $entity = $this
    ->reloadEntity($entity);
  $this
    ->assertEquals('123', $entity->test_remote_id
    ->getByProvider('braintree'));
  $this
    ->assertNull($entity->test_remote_id
    ->getByProvider('stripe'));
  $entity->test_remote_id
    ->setByProvider('braintree', '456');
  $entity->test_remote_id
    ->setByProvider('stripe', '789');
  $entity
    ->save();
  $entity = $this
    ->reloadEntity($entity);
  $this
    ->assertEquals('456', $entity->test_remote_id
    ->getByProvider('braintree'));
  $this
    ->assertNull($entity->test_remote_id
    ->getByProvider('stripe'));
}