public function OrderTest::testOrderCustomerView in Ubercart 8.4
Tests the customer View of the completed order.
File
- uc_order/
tests/ src/ Functional/ OrderTest.php, line 207
Class
- OrderTest
- Tests for Ubercart orders.
Namespace
Drupal\Tests\uc_order\FunctionalCode
public function testOrderCustomerView() {
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
$order = $this
->ucCreateOrder($this->customer);
// Update the status to pending, so the user can see the order on the
// "My order history" page.
$order
->setStatusId('pending');
$order
->save();
$this
->drupalLogin($this->customer);
$this
->drupalGet('user/' . $this->customer
->id() . '/orders');
$assert
->pageTextContains('My order history');
$assert
->pageTextContains('Pending', 'Order status is visible to the customer.');
$this
->drupalGet('user/' . $this->customer
->id() . '/orders/' . $order
->id());
$assert
->statusCodeEquals(200, 'Customer can view their own order.');
$address = $order
->getAddress('billing');
// Check for customer first and last name.
$assert
->pageTextContains(mb_strtoupper($address
->getFirstName()));
$assert
->pageTextContains(mb_strtoupper($address
->getLastName()));
$this
->drupalGet('admin/store/orders/' . $order
->id());
$assert
->statusCodeEquals(403, 'Customer may not see the admin view of their order.');
$this
->drupalGet('admin/store/orders/' . $order
->id() . '/edit');
$assert
->statusCodeEquals(403, 'Customer may not edit orders.');
}