protected function RESTTestBase::entityValues in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/rest/src/Tests/RESTTestBase.php \Drupal\rest\Tests\RESTTestBase::entityValues()
Provides an array of suitable property values for an entity type.
Required properties differ from entity type to entity type, so we keep a minimum mapping here.
Parameters
string $entity_type: The type of the entity that should be created.
Return value
array An array of values keyed by property name.
8 calls to RESTTestBase::entityValues()
- CreateTest::testCreateComment in core/
modules/ rest/ src/ Tests/ CreateTest.php - Test comment creation.
- CreateTest::testCreateEntityTest in core/
modules/ rest/ src/ Tests/ CreateTest.php - Tests valid and invalid create requests for 'entity_test' entity type.
- CreateTest::testCreateNode in core/
modules/ rest/ src/ Tests/ CreateTest.php - Tests several valid and invalid create requests for 'node' entity type.
- CreateTest::testCreateResourceRestApiNotEnabled in core/
modules/ rest/ src/ Tests/ CreateTest.php - Try to create a resource which is not REST API enabled.
- CreateTest::testCreateUser in core/
modules/ rest/ src/ Tests/ CreateTest.php - Tests several valid and invalid create requests for 'user' entity type.
File
- core/
modules/ rest/ src/ Tests/ RESTTestBase.php, line 201 - Contains \Drupal\rest\Tests\RESTTestBase.
Class
- RESTTestBase
- Test helper class that provides a REST client method to send HTTP requests.
Namespace
Drupal\rest\TestsCode
protected function entityValues($entity_type) {
switch ($entity_type) {
case 'entity_test':
return array(
'name' => $this
->randomMachineName(),
'user_id' => 1,
'field_test_text' => array(
0 => array(
'value' => $this
->randomString(),
'format' => 'plain_text',
),
),
);
case 'node':
return array(
'title' => $this
->randomString(),
'type' => 'resttest',
);
case 'node_type':
return array(
'type' => 'article',
'name' => $this
->randomMachineName(),
);
case 'user':
return array(
'name' => $this
->randomMachineName(),
);
case 'comment':
return [
'subject' => $this
->randomMachineName(),
'entity_type' => 'node',
'comment_type' => 'comment',
'comment_body' => $this
->randomString(),
'entity_id' => 'invalid',
'field_name' => 'comment',
];
default:
return array();
}
}