function RestfulReferenceTestCase::testPropertyReference in RESTful 7
Same name and namespace in other branches
- 7.2 tests/RestfulReferenceTestCase.test \RestfulReferenceTestCase::testPropertyReference()
Test property reference.
File
- tests/
RestfulReferenceTestCase.test, line 25 - Contains RestfulReferenceTestCase.
Class
- RestfulReferenceTestCase
- @file Contains RestfulReferenceTestCase.
Code
function testPropertyReference() {
$user1 = $this
->drupalCreateUser();
$settings = array(
'type' => 'article',
'uid' => $user1->uid,
);
$node1 = $this
->drupalCreateNode($settings);
$node2 = $this
->drupalCreateNode($settings);
$handler = restful_get_restful_handler('test_articles', 1, 2);
variable_set('restful_test_reference_simple', TRUE);
$result = $handler
->get($node1->nid);
$this
->assertEqual($result[0]['user']->uid, $user1->uid, 'Property is not defined as resource, thus the referenced entity appears as the entity.');
variable_set('restful_test_reference_resource', TRUE);
// Clear public fields cache.
$handler
->setPublicFields(array());
$result = $handler
->get($node2->nid);
$this
->assertEqual($result[0]['user']['id'], $user1->uid, 'Property is defined as resource, thus the referenced entity appears as the rendered resource.');
}