function RestfulViewEntityMultiLingualTestCase::testViewMultiLangualEntity in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulViewEntityMultiLingualTestCase.test \RestfulViewEntityMultiLingualTestCase::testViewMultiLangualEntity()
Test viewing an entity with translatable fields.
File
- tests/
RestfulViewEntityMultiLingualTestCase.test, line 99 - Contains RestfulViewEntityMultiLingualTestCase
Class
- RestfulViewEntityMultiLingualTestCase
- @file Contains RestfulViewEntityMultiLingualTestCase
Code
function testViewMultiLangualEntity() {
$user = $this
->drupalCreateUser();
$values = array(
'name' => 'restful_test_translatable_entity',
'uid' => $user->uid,
'label' => 'Test translation',
);
$entity = entity_create('restful_test_translatable_entity', $values);
$wrapper = entity_metadata_wrapper('restful_test_translatable_entity', $entity);
$text1 = array(
'en' => $this
->randomName(),
'fr' => $this
->randomName(),
);
$text2 = array(
'en' => $this
->randomName(),
'fr' => $this
->randomName(),
);
foreach (array(
'en',
'fr',
) as $langcode) {
$wrapper
->language($langcode);
$wrapper->text_single
->set($text1[$langcode]);
$wrapper->text_multiple
->set(array(
$text1[$langcode],
$text2[$langcode],
));
}
$wrapper
->save();
$id = $entity->pid;
foreach (array(
'en',
'fr',
) as $langcode) {
$this
->assertExpectedResult($langcode, $id, $text1[$langcode], $text2[$langcode]);
}
}