You are here

public function Drupali18nSyncNodeReferenceTestCase::setUp in i18n node reference synch 7

Sets up the tests.

Overrides DrupalWebTestCase::setUp

File

./i18n_node_reference.test, line 32
Test node reference field synchronization.

Class

Drupali18nSyncNodeReferenceTestCase
Unit test for node reference field synchronisation.

Code

public function setUp() {
  parent::setUp('translation', 'i18n_string', 'i18n_sync', 'references', 'node_reference', 'i18n_node_reference');
  parent::setUpLanguages();

  // Add test languages.
  $this
    ->addLanguage('en');
  $this
    ->addLanguage('nl');
  $this
    ->addLanguage('fr');

  // Set up page content type.
  $this
    ->drupalGet('admin/structure/types/manage/page');
  $edit = array();
  $edit['language_content_type'] = 2;
  $this
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  $this
    ->drupalGet('admin/structure/types/manage/page');

  // Set up article content type.
  $this
    ->drupalGet('admin/structure/types/manage/article');
  $edit = array();
  $edit['language_content_type'] = 2;
  $this
    ->drupalPost('admin/structure/types/manage/article', $edit, t('Save content type'));
  $this
    ->drupalGet('admin/structure/types/manage/article');

  // Set up untranslated content type.
  $settings = array(
    'type' => 'untranslated',
    'name' => 'untranslated',
  );
  $this
    ->drupalCreateContentType($settings);

  // Set up article content type.
  $this
    ->drupalGet('admin/structure/types/manage/untranslated');
  $edit = array();
  $edit['language_content_type'] = 1;

  // Languages enabled, but no translation.
  $this
    ->drupalPost('admin/structure/types/manage/untranslated', $edit, t('Save content type'));
  $this
    ->drupalGet('admin/structure/types/manage/untranslated');

  // Add user that has content edit permissions.
  $this->content_editor = $this
    ->drupalCreateUser(array(
    'create untranslated content',
    'edit own untranslated content',
    'create page content',
    'edit own page content',
    'create article content',
    'edit own article content',
    'translate content',
    'translate interface',
  ));
  $this
    ->createNodeRefField(array(
    'article',
    'untranslated',
  ), 'field_article');

  // Set up fields for synchronization: field_article.
  $this
    ->drupalLogin($this->admin_user);
  $edit = array(
    'i18n_sync_node_type[field_article]' => 1,
  );
  $this
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  $this
    ->drupalGet('admin/structure/types/manage/page');
}