function OgTranslationTestCase::testOgNodeLocale in Organic groups 7
Test disabling OG fields on translated content.
File
- ./
og.test, line 902
Class
- OgTranslationTestCase
- Test the multilangual groups.
Code
function testOgNodeLocale() {
// Setup users.
$web_user = $this
->drupalCreateUser(array(
'administer languages',
'administer content types',
'access administration pages',
'create page content',
'edit own page content',
'translate content',
));
$this
->drupalLogin($web_user);
// Add languages.
$this
->addLanguage('en');
$this
->addLanguage('es');
// Set "Basic page" content type to use multilingual support with translation.
$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'));
// Add OG group field to the node's "page" bundle.
og_create_field(OG_GROUP_FIELD, 'node', 'page');
// Create Basic page in English.
$node_title = $this
->randomName();
$node_body = $this
->randomName();
$node = $this
->createPage($node_title, $node_body, 'en');
// Submit translation in Spanish.
$node_translation_title = $this
->randomName();
$node_translation_body = $this
->randomName();
$node_translation = $this
->createTranslation($node, $node_translation_title, $node_translation_body, 'es');
// Assert both nodes return the same group.
$group1 = og_get_group('node', $node->nid);
$group2 = og_get_group('node', $node_translation->nid);
$this
->assertEqual($group1, $group2, t('Node and tranlated node are the same group.'));
$this
->drupalGet('node/' . $node_translation->nid . '/edit');
$message = t('You can not change "Group" field from a translated content.');
$this
->assertText($message, t('Group field on tranlated node does not allow editing.'));
$this
->drupalGet('node/' . $node->nid . '/edit');
$this
->assertNoText($message, t('Group field on original node allows editing.'));
}