You are here

public function OrderCommentsTest::testUserCheckoutAddComment in Ubercart 8.4

Tests adding admin comments on administrator's order view page.

Test as an authenticated user.

File

uc_order/tests/src/Functional/OrderCommentsTest.php, line 122

Class

OrderCommentsTest
Tests customer administration page functionality.

Namespace

Drupal\Tests\uc_order\Functional

Code

public function testUserCheckoutAddComment() {
  $this
    ->drupalLogin($this->customer);

  /** @var \Drupal\Tests\WebAssert $assert */
  $assert = $this
    ->assertSession();

  // Add product to cart.
  $this
    ->addToCart($this->product);

  // Start checkout.
  $this
    ->submitForm([], 'Checkout');

  // Fill in checkout form, add a comment.
  $edit = $this
    ->populateCheckoutForm([
    'panes[comments][comments]' => $message = $this
      ->randomString(30),
  ]);

  // Review order and make sure entered comment shows up.
  $this
    ->submitForm($edit, 'Review order');
  $assert
    ->pageTextContains('Order comments');
  $assert
    ->pageTextContains('Comment:');
  $assert
    ->responseContains(Xss::filterAdmin($message));

  // Submit order.
  $this
    ->submitForm([], 'Submit order');

  // Go to user view order page and make sure entered comment shows up.
  $this
    ->drupalGet('user/' . $this->customer
    ->id() . '/orders');
  $this
    ->clickLink('View');
  $assert
    ->pageTextContains('Order comments:');
  $assert
    ->pageTextContains('Order created.');
  $assert
    ->pageTextContains('Pending');
  $assert
    ->responseContains(Xss::filterAdmin($message));
}