<?php
namespace Drupal\node\Tests;
use Drupal\translation_entity\Tests\EntityTranslationUITest;
class NodeTranslationUITest extends EntityTranslationUITest {
protected $title;
public static $modules = array(
'language',
'translation_entity',
'node',
'field_ui',
);
public static function getInfo() {
return array(
'name' => 'Node translation UI',
'description' => 'Tests the node translation UI.',
'group' => 'Node',
);
}
function setUp() {
$this->entityType = 'node';
$this->bundle = 'article';
$this->title = $this
->randomName();
parent::setUp();
}
protected function setupBundle() {
parent::setupBundle();
$this
->drupalCreateContentType(array(
'type' => $this->bundle,
'name' => $this->bundle,
));
}
function getTranslatorPermissions() {
return array(
"edit any {$this->bundle} content",
"translate {$this->entityType} entities",
'edit original values',
);
}
function testTranslateLinkContentAdminPage() {
$this->admin_user = $this
->drupalCreateUser(array(
'access administration pages',
'access content overview',
'administer nodes',
'bypass node access',
));
$this
->drupalLogin($this->admin_user);
$page = $this
->drupalCreateNode(array(
'type' => 'page',
));
$article = $this
->drupalCreateNode(array(
'type' => 'article',
));
$this
->drupalGet('admin/content');
$this
->assertResponse(200);
$this
->assertLinkByHref('node/' . $article->nid . '/translations');
$this
->assertNoLinkByHref('node/' . $page->nid . '/translations');
}
function testFieldTranslationForm() {
$admin_user = $this
->drupalCreateUser(array(
'translate any entity',
'access administration pages',
'bypass node access',
));
$this
->drupalLogin($admin_user);
$article = $this
->drupalCreateNode(array(
'type' => 'article',
'langcode' => 'en',
));
$this
->drupalGet('node/' . $article->nid . '/translations');
$this
->assertRaw('Not translated');
field_delete_field('field_test_et_ui_test');
$this
->drupalGet('node/' . $article->nid . '/translations');
$this
->assertRaw('no translatable fields');
}
protected function getNewEntityValues($langcode) {
return array(
'title' => $this->title,
) + parent::getNewEntityValues($langcode);
}
public function testDisabledBundle() {
$disabledBundle = $this
->randomName();
$this
->drupalCreateContentType(array(
'type' => $disabledBundle,
'name' => $disabledBundle,
));
$enabledNode = $this
->drupalCreateNode(array(
'type' => $this->bundle,
));
$disabledNode = $this
->drupalCreateNode(array(
'type' => $disabledBundle,
));
$rows = db_query('SELECT * FROM {translation_entity}')
->fetchAll();
$this
->assertEqual(1, count($rows));
$this
->assertEqual($enabledNode
->id(), reset($rows)->entity_id);
}
}