public function OrderCommentsTest::testAdminEditAddComment in Ubercart 8.4
Tests adding admin comments on administrator's order edit page.
File
- uc_order/
tests/ src/ Functional/ OrderCommentsTest.php, line 90
Class
- OrderCommentsTest
- Tests customer administration page functionality.
Namespace
Drupal\Tests\uc_order\FunctionalCode
public function testAdminEditAddComment() {
$this
->drupalLogin($this->adminUser);
/** @var \Drupal\Tests\WebAssert $assert */
$assert = $this
->assertSession();
// Create an order to test order events.
$order = $this
->createOrder();
// Check that the edit page is viewable and has the expected comment text.
$this
->drupalGet('admin/store/orders/' . $order
->id() . '/edit');
$assert
->pageTextContains('Admin comments:');
$assert
->pageTextContains('No admin comments have been entered for this order.');
// Add an admin order comment from the order view page.
$edit = [
'admin_comment' => $message = $this
->randomString(30),
];
$this
->drupalGet('admin/store/orders/' . $order
->id() . '/edit');
$this
->submitForm($edit, 'Save changes');
$assert
->pageTextContains('Order changes saved.');
// Check for new properly-escaped comment in the comments section.
// Html::decodeEntities(Xss::filter()) is used because Xss::filter()
// HTML-encodes the string, but we want to compare to the text visible
// in the browser, which doesn't show the encoding.
// @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
->pageTextContains('[' . $this->adminUser
->getDisplayName() . '] ' . Html::decodeEntities(Xss::filter($message, [])));
}