Issue #2927766 by Wim Leers: Update ResponseGeneratorTest to use the BrowserTestBase base class instead of the deprecated RESTTestBase

8.5.x
xjm 2017-12-03 11:34:14 -06:00
parent 8d06691e00
commit 6d0a2eaa46
1 changed files with 8 additions and 8 deletions

View File

@ -1,15 +1,16 @@
<?php <?php
namespace Drupal\system\Tests\System; namespace Drupal\Tests\system\Functional\System;
use Drupal\rest\Tests\RESTTestBase; use Drupal\rest\Entity\RestResourceConfig;
use Drupal\Tests\BrowserTestBase;
/** /**
* Tests to see if generator header is added. * Tests to see if generator header is added.
* *
* @group system * @group system
*/ */
class ResponseGeneratorTest extends RESTTestBase { class ResponseGeneratorTest extends BrowserTestBase {
/** /**
* Modules to install. * Modules to install.
@ -25,8 +26,7 @@ class ResponseGeneratorTest extends RESTTestBase {
parent::setUp(); parent::setUp();
$this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']); $this->drupalCreateContentType(['type' => 'page', 'name' => 'Basic page']);
$permissions = $this->entityPermissions('node', 'view'); $account = $this->drupalCreateUser(['access content']);
$account = $this->drupalCreateUser($permissions);
$this->drupalLogin($account); $this->drupalLogin($account);
} }
@ -54,14 +54,14 @@ class ResponseGeneratorTest extends RESTTestBase {
// Enable cookie-based authentication for the entity:node REST resource. // Enable cookie-based authentication for the entity:node REST resource.
/** @var \Drupal\rest\RestResourceConfigInterface $resource_config */ /** @var \Drupal\rest\RestResourceConfigInterface $resource_config */
$resource_config = $this->resourceConfigStorage->load('entity.node'); $resource_config = RestResourceConfig::load('entity.node');
$configuration = $resource_config->get('configuration'); $configuration = $resource_config->get('configuration');
$configuration['authentication'][] = 'cookie'; $configuration['authentication'][] = 'cookie';
$resource_config->set('configuration', $configuration)->save(); $resource_config->set('configuration', $configuration)->save();
$this->rebuildCache(); $this->rebuildAll();
// Tests to see if this also works for a non-html request // Tests to see if this also works for a non-html request
$this->httpRequest($node->urlInfo()->setOption('query', ['_format' => 'hal_json']), 'GET'); $this->drupalGet($node->toUrl()->setOption('query', ['_format' => 'hal_json']));
$this->assertResponse(200); $this->assertResponse(200);
$this->assertEqual('application/hal+json', $this->drupalGetHeader('Content-Type')); $this->assertEqual('application/hal+json', $this->drupalGetHeader('Content-Type'));
$this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator')); $this->assertEqual($expectedGeneratorHeader, $this->drupalGetHeader('X-Generator'));