diff --git a/core/modules/history/src/Tests/HistoryTest.php b/core/modules/history/src/Tests/HistoryTest.php index 7b6254e..3f001b7 100644 --- a/core/modules/history/src/Tests/HistoryTest.php +++ b/core/modules/history/src/Tests/HistoryTest.php @@ -5,9 +5,7 @@ use Drupal\Component\Serialization\Json; use Drupal\Core\Url; use Drupal\simpletest\WebTestBase; -use Psr\Http\Message\ResponseInterface; use Symfony\Component\Serializer\Encoder\JsonEncoder; -use Symfony\Component\Serializer\Encoder\XmlEncoder; use Symfony\Component\Serializer\Serializer; /** @@ -61,7 +59,7 @@ protected function setUp() { $this->testNode = $this->drupalCreateNode(array('type' => 'page', 'uid' => $this->user->id())); $this->client = \Drupal::service('http_client_factory') ->fromOptions(['config/curl' => [CURLOPT_TIMEOUT => 10]]); - $encoders = [new JsonEncoder(), new XmlEncoder()]; + $encoders = [new JsonEncoder()]; $this->serializer = new Serializer([], $encoders); } @@ -71,7 +69,7 @@ protected function setUp() { * @param array $node_ids * An array of node IDs. * - * @return ResponseInterface + * @return \Psr\Http\Message\ResponseInterface * The response object. */ protected function getNodeReadTimestamps(array $node_ids) { @@ -83,9 +81,10 @@ protected function getNodeReadTimestamps(array $node_ids) { $url = Url::fromRoute('history.get_last_node_view') ->setAbsolute(); $this->verbose($this->serializer->encode($post, 'json')); - return \Drupal::httpClient()->post($url->toString(), [ + return $this->client->post($url->toString(), [ 'body' => $this->serializer->encode($post, 'json'), 'headers' => [ + 'Accept' => 'application/json', 'Content-Type' => 'application/x-www-form-urlencoded', ] ]); @@ -102,7 +101,7 @@ protected function getNodeReadTimestamps(array $node_ids) { */ protected function markNodeAsRead($node_id) { $url = Url::fromRoute('history.read_node', array('node' => $node_id), array('absolute' => TRUE))->toString(); - return \Drupal::httpClient()->post($url, [ + return $this->client->post($url, [ 'headers' => array( 'Accept' => 'application/json', ), @@ -114,7 +113,7 @@ protected function markNodeAsRead($node_id) { /** * Verifies that the history endpoints work. */ - function testHistory() { + public function testHistory() { $nid = $this->testNode->id(); // Retrieve "last read" timestamp for test node, for the current user.