RestfulListEntityMultipleBundlesTestCase.test in RESTful 7
Same filename and directory in other branches
Contains RestfulListEntityMultipleBundlesTestCase
File
tests/RestfulListEntityMultipleBundlesTestCase.testView source
<?php
/**
* @file
* Contains RestfulListEntityMultipleBundlesTestCase
*/
class RestfulListEntityMultipleBundlesTestCase extends DrupalWebTestCase {
public static function getInfo() {
return array(
'name' => 'List entity with multiple bundles',
'description' => 'Test listing an entity with multiple bundles.',
'group' => 'RESTful',
);
}
function setUp() {
parent::setUp('restful_test');
}
/**
* Test listing an entity with multiple bundles.
*/
function testList() {
$user1 = $this
->drupalCreateUser();
$entity1 = entity_create('entity_test', array(
'name' => 'main',
'uid' => $user1->uid,
));
$entity1
->save();
$entity2 = entity_create('entity_test', array(
'name' => 'main',
'uid' => $user1->uid,
));
$entity2
->save();
$entity3 = entity_create('entity_test', array(
'name' => 'test',
'uid' => $user1->uid,
));
$entity3
->save();
$handler = restful_get_restful_handler('entity_tests');
$expected_result = array(
array(
'id' => $entity1->pid,
'label' => 'Main test type',
'self' => url('api/v1.0/main/' . $entity1->pid, array(
'absolute' => TRUE,
)),
),
array(
'id' => $entity2->pid,
'label' => 'Main test type',
'self' => url('api/v1.0/main/' . $entity2->pid, array(
'absolute' => TRUE,
)),
),
array(
'id' => $entity3->pid,
'label' => 'label',
'self' => url('api/v1.0/tests/' . $entity3->pid, array(
'absolute' => TRUE,
)),
// The "test" bundle also exposes the "type" property.
'type' => 'test',
),
);
$result = $handler
->get();
$this
->assertEqual($result, $expected_result);
}
}
Classes
Name | Description |
---|---|
RestfulListEntityMultipleBundlesTestCase | @file Contains RestfulListEntityMultipleBundlesTestCase |