2015-04-19 22:26:05 +03:00
|
|
|
<?php
|
2016-07-07 18:26:47 +03:00
|
|
|
|
2016-02-07 22:16:35 +03:00
|
|
|
/**
|
2024-06-24 11:04:29 +03:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
* SPDX-FileCopyrightText: 2015-2016 ownCloud, Inc.
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2016-02-07 22:16:35 +03:00
|
|
|
*/
|
2015-04-19 22:26:05 +03:00
|
|
|
|
2019-11-22 17:19:56 +03:00
|
|
|
namespace OCA\Mail\Tests\Unit\Http;
|
2015-04-19 22:26:05 +03:00
|
|
|
|
2018-02-12 14:41:56 +03:00
|
|
|
use ChristophWurst\Nextcloud\Testing\TestCase;
|
2015-04-19 22:26:05 +03:00
|
|
|
use OCA\Mail\Http\ProxyDownloadResponse;
|
|
|
|
|
2018-02-12 14:41:56 +03:00
|
|
|
class ProxyDownloadResponseTest extends TestCase {
|
2015-04-19 22:26:05 +03:00
|
|
|
/**
|
|
|
|
* @dataProvider providesResponseData
|
|
|
|
* @param $content
|
|
|
|
* @param $filename
|
|
|
|
* @param $contentType
|
|
|
|
*/
|
2016-11-02 01:19:16 +03:00
|
|
|
public function testIt($content, $filename, $contentType) {
|
2015-04-19 22:26:05 +03:00
|
|
|
$resp = new ProxyDownloadResponse($content, $filename, $contentType);
|
|
|
|
$headers = $resp->getHeaders();
|
|
|
|
$this->assertEquals($content, $resp->render());
|
|
|
|
$this->assertArrayHasKey('Content-Type', $headers);
|
|
|
|
$this->assertEquals($contentType, $headers['Content-Type']);
|
|
|
|
$this->assertArrayHasKey('Content-Disposition', $headers);
|
2024-09-11 08:37:01 +03:00
|
|
|
$pos = strpos($headers['Content-Disposition'], (string)$filename);
|
2015-04-19 22:26:05 +03:00
|
|
|
$this->assertTrue($pos > 0);
|
2016-11-02 01:19:16 +03:00
|
|
|
}
|
2015-04-19 22:26:05 +03:00
|
|
|
|
|
|
|
public function providesResponseData() {
|
|
|
|
return [
|
2020-04-14 17:06:46 +03:00
|
|
|
['1234567890', 'test.txt', 'text/plain']
|
2015-04-19 22:26:05 +03:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|