aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Http
diff options
context:
space:
mode:
authorCôme Chilliet <come.chilliet@nextcloud.com>2023-04-05 17:42:14 +0200
committerCôme Chilliet <come.chilliet@nextcloud.com>2023-04-05 17:42:14 +0200
commit8d5165e8dc40289b5d523523c4140f780b2fe293 (patch)
treeb4d15f2bc67e16c94d7cdfdb893a773b415d2738 /tests/lib/Http
parent426c0341ffff262f58d1b7f031de4f0c53c8bec5 (diff)
downloadnextcloud-server-8d5165e8dc40289b5d523523c4140f780b2fe293.tar.gz
nextcloud-server-8d5165e8dc40289b5d523523c4140f780b2fe293.zip
Adapt tests to config value typing
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
Diffstat (limited to 'tests/lib/Http')
-rw-r--r--tests/lib/Http/Client/ClientTest.php156
1 files changed, 84 insertions, 72 deletions
diff --git a/tests/lib/Http/Client/ClientTest.php b/tests/lib/Http/Client/ClientTest.php
index 93948a5daf3..9a4fb1c657e 100644
--- a/tests/lib/Http/Client/ClientTest.php
+++ b/tests/lib/Http/Client/ClientTest.php
@@ -54,22 +54,25 @@ class ClientTest extends \Test\TestCase {
public function testGetProxyUri(): void {
$this->config
- ->method('getSystemValue')
- ->with('proxy', null)
- ->willReturn(null);
+ ->method('getSystemValueString')
+ ->with('proxy', '')
+ ->willReturn('');
$this->assertNull(self::invokePrivate($this->client, 'getProxyUri'));
}
public function testGetProxyUriProxyHostEmptyPassword(): void {
- $map = [
- ['proxy', '', 'foo'],
- ['proxyuserpwd', '', null],
- ['proxyexclude', [], []],
- ];
-
$this->config
->method('getSystemValue')
- ->will($this->returnValueMap($map));
+ ->will($this->returnValueMap([
+ ['proxyexclude', [], []],
+ ]));
+
+ $this->config
+ ->method('getSystemValueString')
+ ->will($this->returnValueMap([
+ ['proxy', '', 'foo'],
+ ['proxyuserpwd', '', ''],
+ ]));
$this->assertEquals([
'http' => 'foo',
@@ -79,32 +82,20 @@ class ClientTest extends \Test\TestCase {
public function testGetProxyUriProxyHostWithPassword(): void {
$this->config
- ->expects($this->exactly(3))
+ ->expects($this->once())
->method('getSystemValue')
+ ->with('proxyexclude', [])
+ ->willReturn([]);
+ $this->config
+ ->expects($this->exactly(2))
+ ->method('getSystemValueString')
->withConsecutive(
- [
- $this->equalTo('proxy'),
- $this->callback(function ($input) {
- return $input === '';
- })
- ],
- [
- $this->equalTo('proxyuserpwd'),
- $this->callback(function ($input) {
- return $input === '';
- })
- ],
- [
- $this->equalTo('proxyexclude'),
- $this->callback(function ($input) {
- return $input === [];
- })
- ],
+ ['proxy', ''],
+ ['proxyuserpwd', ''],
)
->willReturnOnConsecutiveCalls(
'foo',
'username:password',
- [],
);
$this->assertEquals([
'http' => 'username:password@foo',
@@ -114,32 +105,20 @@ class ClientTest extends \Test\TestCase {
public function testGetProxyUriProxyHostWithPasswordAndExclude(): void {
$this->config
- ->expects($this->exactly(3))
+ ->expects($this->once())
->method('getSystemValue')
+ ->with('proxyexclude', [])
+ ->willReturn(['bar']);
+ $this->config
+ ->expects($this->exactly(2))
+ ->method('getSystemValueString')
->withConsecutive(
- [
- $this->equalTo('proxy'),
- $this->callback(function ($input) {
- return $input === '';
- })
- ],
- [
- $this->equalTo('proxyuserpwd'),
- $this->callback(function ($input) {
- return $input === '';
- })
- ],
- [
- $this->equalTo('proxyexclude'),
- $this->callback(function ($input) {
- return $input === [];
- })
- ],
+ ['proxy', ''],
+ ['proxyuserpwd', ''],
)
->willReturnOnConsecutiveCalls(
'foo',
'username:password',
- ['bar'],
);
$this->assertEquals([
'http' => 'username:password@foo',
@@ -271,19 +250,23 @@ class ClientTest extends \Test\TestCase {
}
private function setUpDefaultRequestOptions(): void {
- $map = [
- ['proxy', '', 'foo'],
- ['proxyuserpwd', '', null],
- ['proxyexclude', [], []],
- ];
-
$this->config
->method('getSystemValue')
- ->will($this->returnValueMap($map));
+ ->will($this->returnValueMap([
+ ['proxyexclude', [], []],
+ ]));
+ $this->config
+ ->method('getSystemValueString')
+ ->will($this->returnValueMap([
+ ['proxy', '', 'foo'],
+ ['proxyuserpwd', '', ''],
+ ]));
$this->config
->method('getSystemValueBool')
- ->with('allow_local_remote_servers', false)
- ->willReturn(true);
+ ->will($this->returnValueMap([
+ ['installed', false, true],
+ ['allow_local_remote_servers', false, true],
+ ]));
$this->certificateManager
->expects($this->once())
@@ -467,15 +450,20 @@ class ClientTest extends \Test\TestCase {
public function testSetDefaultOptionsWithNotInstalled(): void {
$this->config
->expects($this->exactly(2))
- ->method('getSystemValue')
+ ->method('getSystemValueBool')
->withConsecutive(
- ['proxy', ''],
['installed', false],
+ ['allow_local_remote_servers', false],
)
->willReturnOnConsecutiveCalls(
- '',
+ false,
false,
);
+ $this->config
+ ->expects($this->once())
+ ->method('getSystemValueString')
+ ->with('proxy', '')
+ ->willReturn('');
$this->certificateManager
->expects($this->never())
->method('listCertificates');
@@ -503,19 +491,31 @@ class ClientTest extends \Test\TestCase {
public function testSetDefaultOptionsWithProxy(): void {
$this->config
- ->expects($this->exactly(4))
+ ->expects($this->exactly(2))
+ ->method('getSystemValueBool')
+ ->withConsecutive(
+ ['installed', false],
+ ['allow_local_remote_servers', false],
+ )
+ ->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ );
+ $this->config
+ ->expects($this->once())
->method('getSystemValue')
+ ->with('proxyexclude', [])
+ ->willReturn([]);
+ $this->config
+ ->expects($this->exactly(2))
+ ->method('getSystemValueString')
->withConsecutive(
['proxy', ''],
['proxyuserpwd', ''],
- ['proxyexclude', []],
- ['installed', false],
)
->willReturnOnConsecutiveCalls(
'foo',
'',
- [],
- true,
);
$this->certificateManager
->expects($this->once())
@@ -550,19 +550,31 @@ class ClientTest extends \Test\TestCase {
public function testSetDefaultOptionsWithProxyAndExclude(): void {
$this->config
- ->expects($this->exactly(4))
+ ->expects($this->exactly(2))
+ ->method('getSystemValueBool')
+ ->withConsecutive(
+ ['installed', false],
+ ['allow_local_remote_servers', false],
+ )
+ ->willReturnOnConsecutiveCalls(
+ true,
+ false,
+ );
+ $this->config
+ ->expects($this->once())
->method('getSystemValue')
+ ->with('proxyexclude', [])
+ ->willReturn(['bar']);
+ $this->config
+ ->expects($this->exactly(2))
+ ->method('getSystemValueString')
->withConsecutive(
['proxy', ''],
['proxyuserpwd', ''],
- ['proxyexclude', []],
- ['installed', false],
)
->willReturnOnConsecutiveCalls(
'foo',
'',
- ['bar'],
- true,
);
$this->certificateManager
->expects($this->once())