0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-21 13:37:39 +00:00
nextcloud_server/tests/lib/Http/Client/ResponseTest.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

59 lines
1.4 KiB
PHP
Raw Normal View History

2015-03-16 11:28:23 +01:00
<?php
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-or-later
2015-03-16 11:28:23 +01:00
*/
2016-05-19 08:46:58 +02:00
namespace Test\Http\Client;
2015-03-16 11:28:23 +01:00
use GuzzleHttp\Psr7\Response as GuzzleResponse;
use GuzzleHttp\Psr7\Utils;
2016-05-19 08:46:58 +02:00
use OC\Http\Client\Response;
2015-03-16 11:28:23 +01:00
/**
* Class ResponseTest
*/
class ResponseTest extends \Test\TestCase {
/** @var GuzzleResponse */
private $guzzleResponse;
protected function setUp(): void {
2015-03-16 11:28:23 +01:00
parent::setUp();
$this->guzzleResponse = new GuzzleResponse(418);
2015-03-16 11:28:23 +01:00
}
public function testGetBody(): void {
$response = new Response($this->guzzleResponse->withBody(Utils::streamFor('MyResponse')));
$this->assertSame('MyResponse', $response->getBody());
}
2015-03-16 11:28:23 +01:00
public function testGetStatusCode(): void {
$response = new Response($this->guzzleResponse);
$this->assertSame(418, $response->getStatusCode());
2015-03-16 11:28:23 +01:00
}
public function testGetHeader(): void {
$response = new Response($this->guzzleResponse->withHeader('bar', 'foo'));
$this->assertSame('foo', $response->getHeader('bar'));
}
public function testGetHeaders(): void {
$response = new Response($this->guzzleResponse
->withHeader('bar', 'foo')
->withHeader('x-awesome', 'yes')
);
$expected = [
'bar' => [
0 => 'foo',
],
'x-awesome' => [
0 => 'yes',
],
];
$this->assertSame($expected, $response->getHeaders());
$this->assertSame('yes', $response->getHeader('x-awesome'));
2015-03-16 11:28:23 +01:00
}
}