function TMGMTEntitySourceListTestCase::testEntitySourceListSearch in Translation Management Tool 7
File
- sources/
entity/ ui/ tmgmt_entity_ui.list.test, line 219
Class
Code
function testEntitySourceListSearch() {
// We need a node with title composed of several words to test
// "any words" search.
$title_part_1 = $this
->randomName('4');
$title_part_2 = $this
->randomName('4');
$title_part_3 = $this
->randomName('4');
$this->nodes['article']['en'][0]->title = "{$title_part_1} {$title_part_2} {$title_part_3}";
node_save($this->nodes['article']['en'][0]);
// Submit partial node title and see if we have a result.
$edit = array();
$edit['search[title]'] = "{$title_part_1} {$title_part_3}";
$this
->drupalPost('admin/tmgmt/sources/entity_node', $edit, t('Search'));
$this
->assertText("{$title_part_1} {$title_part_2} {$title_part_3}", 'Searching on partial node title must return the result.');
// Check if there is only one result in the list.
$search_result_rows = $this
->xpath('//table[@id="tmgmt-entities-list"]/tbody/tr');
$this
->assert(count($search_result_rows) == 1, 'The search result must return only one row.');
// To test if other entity types work go for simple comment search.
$comment = new stdClass();
$comment->comment_body[LANGUAGE_NONE][0]['value'] = $this
->randomName();
$comment->subject = $this
->randomName();
// We need to associate the comment with entity translatable node object.
$comment->nid = $this->nodes['article']['en'][0]->nid;
// Set defaults - without these we will get Undefined property notices.
$comment->is_anonymous = TRUE;
$comment->cid = 0;
$comment->pid = 0;
$comment->uid = 0;
// Will add further comment variables.
$comment = comment_submit($comment);
comment_save($comment);
// Do search for the comment.
$edit = array();
$edit['search[subject]'] = $comment->subject;
$this
->drupalPost('admin/tmgmt/sources/entity_comment', $edit, t('Search'));
$this
->assertText($comment->subject, 'Searching for a comment subject.');
}