protected function NodeTest::postNode in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/rest/src/Tests/NodeTest.php \Drupal\rest\Tests\NodeTest::postNode()
Serializes and attempts to create a node via a REST "post" http request.
Parameters
array $data:
4 calls to NodeTest::postNode()
- NodeTest::testBundleNormalization in core/modules/ rest/ src/ Tests/ NodeTest.php 
- Test bundle normalization when posting bundle as a simple string.
- NodeTest::testCreate in core/modules/ rest/ src/ Tests/ NodeTest.php 
- Test creating a node using json serialization.
- NodeTest::testInvalidBundle in core/modules/ rest/ src/ Tests/ NodeTest.php 
- Test bundle normalization when posting using a simple string.
- NodeTest::testMissingBundle in core/modules/ rest/ src/ Tests/ NodeTest.php 
- Test when the bundle is missing.
File
- core/modules/ rest/ src/ Tests/ NodeTest.php, line 50 
- Contains \Drupal\rest\Tests\NodeTest.
Class
- NodeTest
- Tests special cases for node entities.
Namespace
Drupal\rest\TestsCode
protected function postNode($data) {
  // Enable node creation via POST.
  $this
    ->enableNodeConfiguration('POST', 'create');
  $this
    ->enableService('entity:node', 'POST', 'json');
  // Create a JSON version of a simple node with the title.
  $serialized = $this->container
    ->get('serializer')
    ->serialize($data, 'json');
  // Post to the REST service to create the node.
  $this
    ->httpRequest('/entity/node', 'POST', $serialized, 'application/json');
}