2015-05-15 03:08:10 -04:00
|
|
|
<?php
|
2024-05-28 06:34:11 -04:00
|
|
|
|
2025-05-27 17:36:08 -04:00
|
|
|
declare(strict_types=1);
|
2015-05-15 03:08:10 -04:00
|
|
|
/**
|
2024-05-28 06:34:11 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2015-05-15 03:08:10 -04:00
|
|
|
*/
|
2016-05-25 10:04:15 -04:00
|
|
|
namespace OCA\DAV\Tests\unit\Connector\Sabre;
|
2015-05-15 03:08:10 -04:00
|
|
|
|
2015-08-30 13:13:01 -04:00
|
|
|
use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin;
|
2017-10-24 09:26:53 -04:00
|
|
|
use Sabre\DAV\Server;
|
2017-10-24 18:03:28 -04:00
|
|
|
use Sabre\HTTP\RequestInterface;
|
|
|
|
|
use Sabre\HTTP\ResponseInterface;
|
2015-05-15 03:08:10 -04:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Class DummyGetResponsePluginTest
|
|
|
|
|
*
|
2016-05-25 10:04:15 -04:00
|
|
|
* @package OCA\DAV\Tests\unit\Connector\Sabre
|
2015-05-15 03:08:10 -04:00
|
|
|
*/
|
|
|
|
|
class DummyGetResponsePluginTest extends TestCase {
|
2025-05-27 17:36:08 -04:00
|
|
|
private DummyGetResponsePlugin $dummyGetResponsePlugin;
|
2015-05-15 03:08:10 -04:00
|
|
|
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2015-05-15 03:08:10 -04:00
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
|
|
$this->dummyGetResponsePlugin = new DummyGetResponsePlugin();
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testInitialize(): void {
|
2025-05-27 17:36:08 -04:00
|
|
|
$server = $this->createMock(Server::class);
|
2015-05-15 03:08:10 -04:00
|
|
|
$server
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('on')
|
|
|
|
|
->with('method:GET', [$this->dummyGetResponsePlugin, 'httpGet'], 200);
|
|
|
|
|
|
|
|
|
|
$this->dummyGetResponsePlugin->initialize($server);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-01-20 02:38:43 -05:00
|
|
|
public function testHttpGet(): void {
|
2025-05-27 17:36:08 -04:00
|
|
|
$request = $this->createMock(RequestInterface::class);
|
|
|
|
|
$response = $this->createMock(ResponseInterface::class);
|
2015-05-15 03:08:10 -04:00
|
|
|
$response
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('setBody');
|
2015-08-25 12:07:40 -04:00
|
|
|
$response
|
|
|
|
|
->expects($this->once())
|
|
|
|
|
->method('setStatus')
|
|
|
|
|
->with(200);
|
2015-05-15 03:08:10 -04:00
|
|
|
|
|
|
|
|
$this->assertSame(false, $this->dummyGetResponsePlugin->httpGet($request, $response));
|
|
|
|
|
}
|
|
|
|
|
}
|