public function ServicesEntityTestHelper::action in Services Entity API 7.2
Helper to perform a RESTful action of a resource.
Parameters
String $resource: The resource type to operate on.
int $name: The name of the resource to update
array $data: The update data to put.
int $code: The expected response code (defaults to 200).
File
- tests/
services_entity.test, line 219 - Services Entity Tests
Class
- ServicesEntityTestHelper
- Services Entity Test Helper class.
Code
public function action($resource, $name, $action, $data, $code) {
if (!is_array($data)) {
$data = (array) $data;
}
$destination = '';
if (isset($name) && strlen($name) > 0) {
$path = "{$resource}/{$name}/{$action}";
}
else {
$path = "{$resource}/{$action}";
}
$r = $this
->servicesPost($this->endpoint_path . '/' . $path, $data);
$this
->assertEqual($r['code'], $code, "Received {$code} response code from ACTION {$path} (actual response=" . $r['code'] . ")");
return $this
->unObject($r['body']);
}