public function EntityTranslationHierarchyViewsWebTestCase::testViewsSupport in Language Hierarchy 7
Test support for inheritance in views.
File
- modules/
entity_translation_hierarchy/ tests/ entity_translation_hierarchy.test, line 220 - Tests for Entity Translation Hierarchy module.
Class
- EntityTranslationHierarchyViewsWebTestCase
- Functional tests for entity translation.
Code
public function testViewsSupport() {
// Create Basic page in English.
$node_title = $this
->randomName();
$node_body = $this
->randomName();
$node = $this
->createPageNode($node_title, $node_body, 'en');
// Submit translation in Portuguese, Portugal.
$node_translation_body_pt_pt = $this
->randomName();
$this
->createTranslation($node, $node_translation_body_pt_pt, 'pt-pt');
// Submit translation in Portuguese, International.
$node_translation_body_pt = $this
->randomName();
$this
->createTranslation($node, $node_translation_body_pt, 'pt');
// Test if view is exported properly.
$this
->get('en', 'test');
$this
->assertText('Entity Translation Hierarchy test page');
// Test if english content is displayed properly.
$this
->assertText($node_body);
// Test if Portuguese, International content is displayed properly.
$this
->get('pt', 'test');
$this
->assertText($node_translation_body_pt, 'Portuguese, International content is displayed properly.');
// Test if there is only one views row.
$this
->assertNoFieldByXPath('/div[@class="views-row-2"]', TRUE, 'There is only one row in view for Portuguese, International.');
// Test if Portuguese, Portugal content is displayed properly.
$this
->get('pt-pt', 'test');
$this
->assertText($node_translation_body_pt_pt, 'Portuguese, Portugal content is displayed properly.');
// Test if there is only one views row.
$this
->assertNoFieldByXPath('/div[@class="views-row-2"]', TRUE, 'There is only one row in view for Portuguese, Portugal.');
// Test if Portuguese, Brazil content is inherited from parent (Portuguese, International).
$this
->get('pt-br', 'test');
$this
->assertText($node_translation_body_pt, 'Portuguese, Brazil content is inherited from parent (Portuguese, International).');
// Test if there is only one views row.
$this
->assertNoFieldByXPath('/div[@class="views-row-2"]', TRUE, 'There is only one row in view for Portuguese, Brazil.');
// Make Portuguese, Portugal translation as blocking.
$edit = array(
'translation[blocking]' => 1,
);
$this
->drupalPost('node/' . $node->nid . '/edit/pt-pt', $edit, t('Save'));
// Test if blocking Portuguese, Portugal translation is no longer visible.
$this
->get('pt-pt', 'test');
$this
->assertNoText($node_translation_body_pt, 'Portuguese, Portugal blocking translation is no longer visible.');
// Test if there are no rows.
$this
->assertNoFieldByXPath('/div[@class="views-row-1"]', TRUE, 'There is no rows in view for blocked Portuguese, Portugal translation.');
// Test if Portuguese, Brazil content is still inherited from parent (Portuguese, International).
$this
->get('pt-br', 'test');
$this
->assertText($node_translation_body_pt, 'Portuguese, Brazil content is still inherited from parent (Portuguese, International).');
// Test if there is still only one views row.
$this
->assertNoFieldByXPath('/div[@class="views-row-2"]', TRUE, 'There is still only one row in view for Portuguese, International.');
}