public function OrderCommentsTest::testAdminViewAddComment in Ubercart 8.4
Tests adding admin comments on administrator's order view page.
File
- uc_order/
tests/ src/ Functional/ OrderCommentsTest.php, line 40
Class
- OrderCommentsTest
- Tests customer administration page functionality.
Namespace
Drupal\Tests\uc_order\FunctionalCode
public function testAdminViewAddComment() {
$this
->drupalLogin($this->adminUser);
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// Create an order to test order events.
$order = $this
->createOrder();
// Check that order creation was entered as a comment.
$this
->drupalGet('admin/store/orders/' . $order
->id());
$assert
->pageTextContains('This order has no comments associated with it.');
$assert
->pageTextContains('This order has no admin comments associated with it.');
// Changing the order status on the admin form will also create
// an order comment.
$edit = [
'status' => 'processing',
];
$this
->drupalGet('admin/store/orders/' . $order
->id());
$this
->submitForm($edit, 'Update');
$assert
->pageTextContains('Order updated.');
// Check for new priority in the comments section.
// @todo Should use xpath to make sure we are checking this in the order
// comments pane, not just finding this somewhere on the page.
$assert
->responseContains('<td class="status priority-low">Processing</td>');
// Add an order comment from the order view page.
$edit = [
'order_comment' => $message = $this
->randomString(30),
];
$this
->drupalGet('admin/store/orders/' . $order
->id());
$this
->submitForm($edit, 'Update');
$assert
->pageTextContains('Order updated.');
// Check for new properly-escaped comment in the comments section.
// Xss::filter() is used because that is what #markup does to the message
// text and we want to ensure we are comparing apples to apples.
// @todo Should use xpath to make sure we are checking this in the order
// comments pane, not just finding this somewhere on the page.
$assert
->responseContains('<td class="message">' . Xss::filterAdmin($message) . '</td>');
// Add an admin order comment from the order view page.
$edit = [
'admin_comment' => $message = $this
->randomString(30),
];
$this
->drupalGet('admin/store/orders/' . $order
->id());
$this
->submitForm($edit, 'Update');
$assert
->pageTextContains('Order updated.');
// Check for new properly-escaped comment in the comments section.
// @todo Should use xpath to make sure we are checking this in the order
// comments pane, not just finding this somewhere on the page.
$assert
->responseContains('<td class="message">' . Xss::filterAdmin($message) . '</td>');
}