diff --git a/core/modules/rest/src/Tests/FileTest.php b/core/modules/rest/src/Tests/FileTest.php index 4e148db..84ce5c6 100644 --- a/core/modules/rest/src/Tests/FileTest.php +++ b/core/modules/rest/src/Tests/FileTest.php @@ -2,6 +2,7 @@ namespace Drupal\rest\Tests; +use Drupal\Core\Url; use Drupal\file\Entity\File; /** @@ -40,7 +41,7 @@ public function testCrudFile() { // Enables the REST service for 'file' entity type. $this->enableService('entity:' . $entity_type, 'POST', 'hal_json'); - //$this->enableService('entity:' . $entity_type, 'GET'); + $this->enableService('entity:' . $entity_type, 'GET', 'hal_json'); //$this->enableService('entity:' . $entity_type, 'PATCH'); $file_contents = 'hello world'; @@ -62,13 +63,19 @@ public function testCrudFile() { // POST method must be allowed for the current entity type. $permissions[] = 'restful post entity:' . $entity_type; + $permissions[] = 'restful get entity:' . $entity_type; // Create the user. $account = $this->drupalCreateUser($permissions); + // Create the file. $this->drupalLogin($account); $this->httpRequest('entity/' . $entity_type, 'POST', $serialized, 'application/hal+json'); $this->assertResponse(201); + + // Get the file. + $this->httpRequest(Url::fromUri('base://entity/file/1', ['query' => ['_format' => 'hal_json']]), 'GET', NULL, 'application/hal+json'); + $this->assertResponse(200); } } diff --git a/core/modules/rest/src/Tests/RESTTestBase.php b/core/modules/rest/src/Tests/RESTTestBase.php index e503216..933187e 100644 --- a/core/modules/rest/src/Tests/RESTTestBase.php +++ b/core/modules/rest/src/Tests/RESTTestBase.php @@ -263,7 +263,7 @@ protected function entityValues($entity_type) { protected function enableService($resource_type, $method = 'GET', $format = NULL, $auth = NULL) { // Enable REST API for this entity type. $config = $this->config('rest.settings'); - $settings = array(); + $settings = $config->get('resources'); if ($resource_type) { if ($format == NULL) {