Commit d65270d4 authored by webchick's avatar webchick
Browse files

Issue #1832932 by tstoeckler, attiks: Fixed translation_entity_entity_insert()...

Issue #1832932 by tstoeckler, attiks: Fixed translation_entity_entity_insert() assumes entity IDs are integers.
parent 7b88ea7c
<?php
/**
* @file
* Definition of Drupal\entity\Tests\ConfigTestTranslationUITest.
*/
namespace Drupal\translation_entity\Tests;
/**
* Tests the Config Test Translation UI.
*/
class ConfigTestTranslationUITest extends EntityTranslationUITest {
/**
* Modules to enable.
*
* config_test.module has a (soft) dependency on image.module.
*
* @var array
*/
public static $modules = array('language', 'translation_entity', 'image', 'config_test');
public static function getInfo() {
return array(
'name' => 'Config Test Translation UI',
'description' => 'Tests the test entity translation UI with the test config entity.',
'group' => 'Entity Translation UI',
);
}
/**
* Overrides \Drupal\simpletest\WebTestBase::setUp().
*/
function setUp() {
$this->entityType = 'config_test';
parent::setUp();
}
/**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getTranslatorPermission().
*/
function getTranslatorPermissions() {
return array("translate $this->entityType entities", 'edit original values');
}
/**
* Overrides \Drupal\translation_entity\Tests\EntityTranslationUITest::getNewEntityValues().
*/
protected function getNewEntityValues($langcode) {
return array(
'id' => $this->randomName(),
'label' => $this->randomName(),
'style' => 'large',
);
}
/**
* Overrides EntityTranslationTest::testTranslationUI().
*
* @todo This override is a copy-paste of parts of the parent method. Turn
* ConfigTest into a properly translatable entity and remove this override.
*/
function testTranslationUI() {
// Create a new test entity with original values in the default language.
$default_langcode = $this->langcodes[0];
$values[$default_langcode] = $this->getNewEntityValues($default_langcode);
$id = $this->createEntity($values[$default_langcode], $default_langcode);
$entity = entity_load($this->entityType, $id, TRUE);
$this->assertTrue($entity, t('Entity found in the database.'));
$translation = $this->getTranslation($entity, $default_langcode);
foreach ($values[$default_langcode] as $property => $value) {
$stored_value = $this->getValue($translation, $property, $default_langcode);
$value = is_array($value) ? $value[0]['value'] : $value;
$message = format_string('@property correctly stored in the default language.', array('@property' => $property));
$this->assertIdentical($stored_value, $value, $message);
}
}
/**
* Overrides EntityTranslationUITest::setupTestFields().
*
* The config_test entity is not fieldable.
*/
protected function setupTestFields() {}
}
......@@ -22,7 +22,7 @@ class EntityTestTranslationUITest extends EntityTranslationUITest {
public static function getInfo() {
return array(
'name' => 'Entity Test Translation UI',
'description' => 'Tests the test entity translation UI.',
'description' => 'Tests the test entity translation UI with the test entity.',
'group' => 'Entity Translation UI',
);
}
......
......@@ -20,9 +20,10 @@ function translation_entity_schema() {
'description' => 'The entity type this translation relates to',
),
'entity_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
'default' => '',
'description' => 'The entity id this translation relates to',
),
'langcode' => array(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment