private function RestfulViewEntityMultiLingualTestCase::assertExpectedResult in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulViewEntityMultiLingualTestCase.test \RestfulViewEntityMultiLingualTestCase::assertExpectedResult()
Helper to test viewing an entity (GET method) in a certain language.
Parameters
string $langcode: The language to view the entity in.
int $id: The ID of the entity to test.
string $text1: The first expected string (text_single and text_multiple[0]).
string $text2: The second expected string (text_multiple[2]).
1 call to RestfulViewEntityMultiLingualTestCase::assertExpectedResult()
- RestfulViewEntityMultiLingualTestCase::testViewMultiLangualEntity in tests/
RestfulViewEntityMultiLingualTestCase.test - Test viewing an entity with translatable fields.
File
- tests/
RestfulViewEntityMultiLingualTestCase.test, line 143 - Contains RestfulViewEntityMultiLingualTestCase
Class
- RestfulViewEntityMultiLingualTestCase
- @file Contains RestfulViewEntityMultiLingualTestCase
Code
private function assertExpectedResult($langcode, $id, $text1, $text2) {
$handler = restful_get_restful_handler('restful_test_translatable_entity');
// Explicitly set the langcode.
$handler
->setLangCode($langcode);
$response = $handler
->get($id);
$result = $response[0];
$this
->assertEqual(trim(strip_tags($result['text_single'])), $text1, 'Entity view has correct result for "text_single" in language "' . $langcode . '".');
$this
->assertEqual(trim(strip_tags($result['text_multiple'][0])), $text1, 'Entity view has correct result for the first value of "text_multiple" in language "' . $langcode . '".');
$this
->assertEqual(trim(strip_tags($result['text_multiple'][1])), $text2, 'Entity view has correct result for the second value of "text_multiple" in language "' . $langcode . '".');
}