diff options
author | Robin Appelman <robin@icewind.nl> | 2018-02-08 13:39:27 +0100 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2018-02-09 17:13:21 +0100 |
commit | 9b25ff9fcb7299419c42b457da23ea3bae186157 (patch) | |
tree | 9cfaa02ad646bfaf71fc769b3bd8a235650e72cd /tests/lib/Http/Client/ClientTest.php | |
parent | 18215eb01d0812651f4e3ef4dd772002df388a3a (diff) | |
download | nextcloud-server-9b25ff9fcb7299419c42b457da23ea3bae186157.tar.gz nextcloud-server-9b25ff9fcb7299419c42b457da23ea3bae186157.zip |
adjust httpclient to guzzle6
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Http/Client/ClientTest.php')
-rw-r--r-- | tests/lib/Http/Client/ClientTest.php | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php index 1b0a51b7395..ec4ca6ec90c 100644 --- a/tests/lib/Http/Client/ClientTest.php +++ b/tests/lib/Http/Client/ClientTest.php @@ -8,7 +8,8 @@ namespace Test\Http\Client; -use GuzzleHttp\Message\Response; +use GuzzleHttp\HandlerStack; +use GuzzleHttp\Psr7\Response; use OC\Http\Client\Client; use OC\Security\CertificateManager; use OCP\ICertificateManager; @@ -37,7 +38,8 @@ class ClientTest extends \Test\TestCase { $this->client = new Client( $this->config, $this->certificateManager, - $this->guzzleClient + $this->guzzleClient, + HandlerStack::create() ); } @@ -84,37 +86,37 @@ class ClientTest extends \Test\TestCase { } public function testGet() { - $this->guzzleClient->method('get') + $this->guzzleClient->method('request') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->get('http://localhost/', [])->getStatusCode()); } public function testPost() { - $this->guzzleClient->method('post') + $this->guzzleClient->method('request') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->post('http://localhost/', [])->getStatusCode()); } public function testPut() { - $this->guzzleClient->method('put') + $this->guzzleClient->method('request') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->put('http://localhost/', [])->getStatusCode()); } public function testDelete() { - $this->guzzleClient->method('delete') + $this->guzzleClient->method('request') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->delete('http://localhost/', [])->getStatusCode()); } public function testOptions() { - $this->guzzleClient->method('options') + $this->guzzleClient->method('request') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->options('http://localhost/', [])->getStatusCode()); } public function testHead() { - $this->guzzleClient->method('head') + $this->guzzleClient->method('request') ->willReturn(new Response(1337)); $this->assertEquals(1337, $this->client->head('http://localhost/', [])->getStatusCode()); } @@ -129,16 +131,10 @@ class ClientTest extends \Test\TestCase { ->expects($this->once()) ->method('listCertificates') ->willReturn([]); - $this->guzzleClient - ->expects($this->at(0)) - ->method('setDefaultOption') - ->with('verify', \OC::$SERVERROOT . '/resources/config/ca-bundle.crt'); - $this->guzzleClient - ->expects($this->at(1)) - ->method('setDefaultOption') - ->with('headers/User-Agent', 'Nextcloud Server Crawler'); - self::invokePrivate($this->client, 'setDefaultOptions'); + $this->assertEquals([ + 'verify' => \OC::$SERVERROOT . '/resources/config/ca-bundle.crt' + ], self::invokePrivate($this->client, 'getRequestOptions')); } public function testSetDefaultOptionsWithProxy() { @@ -157,19 +153,10 @@ class ClientTest extends \Test\TestCase { ->method('getAbsoluteBundlePath') ->with(null) ->willReturn('/my/path.crt'); - $this->guzzleClient - ->expects($this->at(0)) - ->method('setDefaultOption') - ->with('verify', '/my/path.crt'); - $this->guzzleClient - ->expects($this->at(1)) - ->method('setDefaultOption') - ->with('headers/User-Agent', 'Nextcloud Server Crawler'); - $this->guzzleClient - ->expects($this->at(2)) - ->method('setDefaultOption') - ->with('proxy', 'foo'); - - self::invokePrivate($this->client, 'setDefaultOptions'); + + $this->assertEquals([ + 'verify' => '/my/path.crt', + 'proxy' => 'foo' + ], self::invokePrivate($this->client, 'getRequestOptions')); } } |