diff --git a/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php b/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php index 0c4d5f0..6f9ec7a 100644 --- a/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php +++ b/core/modules/entity/lib/Drupal/entity/Tests/EntityTranslationTest.php @@ -211,6 +211,8 @@ class EntityTranslationTest extends WebTestBase { $this->assertEqual(count($entities), 1, 'One entity correctly loaded by id.'); $entities = entity_test_load_multiple(array(), array('name' => $name), TRUE); $this->assertEqual(count($entities), 2, 'Two entities correctly loaded by name.'); + // @todo The default language condition should go away in favor of an + // explicit parameter. $entities = entity_test_load_multiple(array(), array('name' => $properties[$langcode]['name'], 'default_langcode' => 0), TRUE); $this->assertEqual(count($entities), 1, 'One entity correctly loaded by name translation.'); $entities = entity_test_load_multiple(array(), array('langcode' => $default_langcode, 'name' => $name), TRUE); diff --git a/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php b/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php index a0eaf26..d39c4b8 100644 --- a/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php +++ b/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTest.php @@ -48,11 +48,10 @@ class EntityTest extends Entity { $this->langcode = !empty($values['langcode']) ? $values['langcode'] : LANGUAGE_NOT_SPECIFIED; // Set initial values ensuring that only real properties are stored. - foreach ($values as $property_name => $value) { - if ($property_name != 'id' && $property_name != 'default_langcode') { - $this->properties[$this->langcode][$property_name] = $value; - } - } + // @todo For now we have no way to mark a property as multlingual hence we + // just assume that all of them are. + unset($values['id'], $values['default_langcode']); + $this->setProperties($values, $this->langcode); } /** @@ -63,9 +62,10 @@ class EntityTest extends Entity { public function setLangcode($langcode) { // If the original language is changed the related properties must change // their language accordingly. - if (isset($this->properties[$this->langcode])) { - $this->properties[$langcode] = $this->properties[$this->langcode]; - unset($this->properties[$this->langcode]); + $prev_langcode = $this->langcode; + if (isset($this->properties[$prev_langcode])) { + $this->properties[$langcode] = $this->properties[$prev_langcode]; + unset($this->properties[$prev_langcode]); } $this->langcode = $langcode; } diff --git a/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php b/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php index 8062cff..5c35d91 100644 --- a/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php +++ b/core/modules/entity/tests/modules/entity_test/lib/Drupal/entity_test/EntityTestStorageController.php @@ -34,6 +34,9 @@ class EntityTestStorageController extends DatabaseStorageController { } if ($conditions) { + // @todo We should not be using a condition to specify whether conditions + // apply to the default language or not. We need to move this to a + // separate parameter during the following API refactoring. // Default to the original entity language if not explicitly specified // otherwise. if (!array_key_exists('default_langcode', $conditions)) {