diff --git a/src/Tests/AjaxCommentsTest.php b/src/Tests/AjaxCommentsTest.php index 298e27f..57a5493 100644 --- a/src/Tests/AjaxCommentsTest.php +++ b/src/Tests/AjaxCommentsTest.php @@ -8,7 +8,6 @@ namespace Drupal\ajax_comments\Tests; use Drupal\comment\Tests\CommentTestBase; -use Drupal\Component\Utility\Xss; /** * Tests posting ajax comments. @@ -40,10 +39,17 @@ class AjaxCommentsTest extends CommentTestBase { $edit = [ 'comment_body[0][value]' => $comment, ]; - $this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Save')]); - $this->drupalGet('node/' . $this->node->id()); - $this->assertText(Xss::filter($comment), 'Comment posted.'); - $this->pass($comment); + $ajax_result = $this->drupalPostAjaxForm(NULL, $edit, ['op' => t('Save')]); + // The fifth ajax command ($ajax_result[4]) is the replacement one. + // + // TODO: Refactor AjaxCommentsController to have a separate method for + // returning the content of the comment field. This would allow structuring + // this test more like \Drupal\system\Tests\Ajax\DialogTest::testDialog(), + // and allow code reuse among the forthcoming controllers for the edit and + // reply ajax routes. + $this->assertTrue(strpos($ajax_result[4]['data'], $comment) !== FALSE, 'Comment posted.'); + $this->pass('Ajax replacement content: ' . $ajax_result[4]['data']); + $this->pass('Comment: ' . $comment); } }