You are here

public function OrderReassignTest::testReassignToNewUser in Commerce Core 8.2

Tests the reassign form with a new user.

File

modules/order/tests/src/FunctionalJavascript/OrderReassignTest.php, line 66

Class

OrderReassignTest
Tests the commerce_order reassign form.

Namespace

Drupal\Tests\commerce_order\FunctionalJavascript

Code

public function testReassignToNewUser() {
  $this
    ->drupalGet($this->order
    ->toUrl('reassign-form'));
  $this
    ->getSession()
    ->getPage()
    ->fillField('customer_type', 'new');
  $this
    ->assertSession()
    ->assertWaitOnAjaxRequest();
  $values = [
    'mail' => 'example@example.com',
  ];
  $this
    ->submitForm($values, 'Reassign order');
  $collection_url = $this->order
    ->toUrl('collection', [
    'absolute' => TRUE,
  ]);
  $this
    ->assertSession()
    ->addressEquals($collection_url);
  $this
    ->assertSession()
    ->pageTextContains(t('has been assigned to customer @customer.', [
    '@customer' => 'example@example.com',
  ]));
  $this->order = $this
    ->reloadEntity($this->order);
  $this
    ->assertNotEquals($this->loggedInUser
    ->id(), $this->order
    ->getCustomerId());
  $this
    ->assertEquals('example@example.com', $this->order
    ->getCustomer()
    ->getEmail());
}