You are here

function TMGMTEntitySourceListTestCase::testNodeEntityListings in Translation Management Tool 7

File

sources/entity/ui/tmgmt_entity_ui.list.test, line 177

Class

TMGMTEntitySourceListTestCase

Code

function testNodeEntityListings() {

  // Turn off the entity translation.
  $edit = array();
  $edit['language_content_type'] = TRANSLATION_ENABLED;
  $this
    ->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));

  // Check if we have appropriate message in case there are no entity
  // translatable content types.
  $this
    ->drupalGet('admin/tmgmt/sources/entity_node');
  $this
    ->assertText(t('Entity translation is not enabled for any of existing content types. To use this functionality go to Content types administration and enable entity translation for desired content types.'));

  // Turn on the entity translation for both - article and page - to test
  // search form.
  $edit = array();
  $edit['language_content_type'] = ENTITY_TRANSLATION_ENABLED;
  $this
    ->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
  $this
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));

  // Create page node after entity translation is enabled.
  $page_node_translatable = $this
    ->createNode('page');
  $this
    ->drupalGet('admin/tmgmt/sources/entity_node');

  // We have both listed - one of articles and page.
  $this
    ->assertText($this->nodes['article']['en'][0]->title);
  $this
    ->assertText($page_node_translatable->title);

  // Try the search by content type.
  $edit = array();
  $edit['search[type]'] = 'article';
  $this
    ->drupalPost('admin/tmgmt/sources/entity_node', $edit, t('Search'));

  // There should be article present.
  $this
    ->assertText($this->nodes['article']['en'][0]->title);

  // The page node should not be listed.
  $this
    ->assertNoText($page_node_translatable->title);

  // Try cancel button - despite we do post content type search value
  // we should get nodes of botch content types.
  $this
    ->drupalPost('admin/tmgmt/sources/entity_node', $edit, t('Cancel'));
  $this
    ->assertText($this->nodes['article']['en'][0]->title);
  $this
    ->assertText($page_node_translatable->title);
}