public function OrderUserTest::testAnonymousViewOrder in Commerce Core 8.2
Tests viewing an anonymous order is denied.
File
- modules/
order/ tests/ src/ Functional/ OrderUserTest.php, line 88
Class
- OrderUserTest
- Tests normal user operations with orders.
Namespace
Drupal\Tests\commerce_order\FunctionalCode
public function testAnonymousViewOrder() {
$order_item = OrderItem::create([
'type' => 'default',
'quantity' => 2,
'unit_price' => new Price('12.00', 'USD'),
]);
$order_item
->save();
/** @var \Drupal\commerce_order\Entity\Order $order */
$order = Order::create([
'type' => 'default',
'state' => 'completed',
'uid' => 0,
'order_items' => [
$order_item,
],
'mail' => 'testViewOrder@example.com',
'order_number' => '1',
]);
$order
->save();
// Check order list page is not available even though there is a completed
// order.
$this
->drupalGet('/user/0/orders/');
$this
->assertSession()
->statusCodeEquals(404);
// Check that the order is also not available directly.
$this
->drupalGet('/user/0/orders/' . $order
->id());
$this
->assertSession()
->statusCodeEquals(403);
}