Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/mail.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDaniel Kesselberg <mail@danielkesselberg.de>2021-08-04 14:14:06 +0300
committerDaniel Kesselberg <mail@danielkesselberg.de>2021-08-04 15:48:25 +0300
commit1d2da1b2c58f1cc5a11f8626785c0120ed289fd9 (patch)
treeabe9d0a9829f2d894f9b7176d9de0981ae271bea /tests
parenta0d72077203f108f015c12619d06edfd923e8a32 (diff)
Catch guzzle error in proxy
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
Diffstat (limited to 'tests')
-rw-r--r--tests/Unit/Controller/ProxyControllerTest.php20
1 files changed, 11 insertions, 9 deletions
diff --git a/tests/Unit/Controller/ProxyControllerTest.php b/tests/Unit/Controller/ProxyControllerTest.php
index 7f81a6986..f05aeb70b 100644
--- a/tests/Unit/Controller/ProxyControllerTest.php
+++ b/tests/Unit/Controller/ProxyControllerTest.php
@@ -33,6 +33,8 @@ use OCP\IRequest;
use OCP\ISession;
use OCP\IURLGenerator;
use PHPUnit\Framework\MockObject\MockObject;
+use Psr\Log\LoggerInterface;
+use Psr\Log\NullLogger;
class ProxyControllerTest extends TestCase {
@@ -51,8 +53,8 @@ class ProxyControllerTest extends TestCase {
/** @var IClientService|MockObject */
private $clientService;
- /** @var string */
- private $hostname;
+ /** @var LoggerInterface */
+ private $logger;
/** @var ProxyController */
private $controller;
@@ -65,7 +67,7 @@ class ProxyControllerTest extends TestCase {
$this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->session = $this->createMock(ISession::class);
$this->clientService = $this->createMock(IClientService::class);
- $this->hostname = 'example.com';
+ $this->logger = new NullLogger();
}
public function redirectDataProvider() {
@@ -122,7 +124,7 @@ class ProxyControllerTest extends TestCase {
$this->urlGenerator,
$this->session,
$this->clientService,
- 'example.com'
+ $this->logger
);
$expected = new TemplateResponse(
$this->appName,
@@ -148,7 +150,7 @@ class ProxyControllerTest extends TestCase {
$this->urlGenerator,
$this->session,
$this->clientService,
- ''
+ $this->logger
);
$this->expectException(Exception::class);
@@ -165,14 +167,14 @@ class ProxyControllerTest extends TestCase {
$client = $this->getMockBuilder(IClient::class)->getMock();
$this->clientService->expects($this->once())
->method('newClient')
- ->will($this->returnValue($client));
+ ->willReturn($client);
$client->expects($this->once())
->method('get')
->with($src)
- ->will($this->returnValue($httpResponse));
+ ->willReturn($httpResponse);
$httpResponse->expects($this->once())
->method('getBody')
- ->will($this->returnValue($content));
+ ->willReturn($content);
$expected = new ProxyDownloadResponse(
$content,
@@ -185,7 +187,7 @@ class ProxyControllerTest extends TestCase {
$this->urlGenerator,
$this->session,
$this->clientService,
- ''
+ $this->logger
);
$response = $this->controller->proxy($src);