function EntityTranslationCommentTestCase::testCommentLanguageFiltering in Entity Translation 7
Test comment filtering by language.
File
- tests/
entity_translation.test, line 453 - Tests for Entity translation module.
Class
- EntityTranslationCommentTestCase
- Basic tests for comment related things.
Code
function testCommentLanguageFiltering() {
$node = $this
->createPage($this
->randomName(), $this
->randomName(), 'en');
$this
->login($this
->getCommentUser());
// Create comments in different languages.
$comment_en = $this
->randomName();
$this
->postComment($node, $comment_en, 'en');
$comment_es = $this
->randomName();
$this
->postComment($node, $comment_es, 'es');
// Check that ALL comments are being displayed when comment language filter
// is disabled (default behavior).
$this
->get('en', 'node/' . $node->nid);
$this
->assertText($comment_en, 'English comment found.');
$this
->assertText($comment_es, 'Spanish comment found.');
// Enable comment filtering by language.
$this
->login($this
->getAdminUser());
$this
->configureComments(TRUE);
$this
->login($this
->getCommentUser());
// Load page in different languages. Check that only comments matching
// current language are being displayed.
$this
->get('en', 'node/' . $node->nid);
$this
->assertText($comment_en, 'English comment found.');
$this
->assertNoText($comment_es, 'Spanish comment not found.');
$this
->get('es', 'node/' . $node->nid);
$this
->assertNoText($comment_en, 'English comment not found.');
$this
->assertText($comment_es, 'Spanish comment found.');
}