DummyGetResponsePluginTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\DAV\Tests\unit\Connector\Sabre;
  8. use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin;
  9. use Sabre\DAV\Server;
  10. use Sabre\HTTP\RequestInterface;
  11. use Sabre\HTTP\ResponseInterface;
  12. use Test\TestCase;
  13. /**
  14. * Class DummyGetResponsePluginTest
  15. *
  16. * @package OCA\DAV\Tests\unit\Connector\Sabre
  17. */
  18. class DummyGetResponsePluginTest extends TestCase {
  19. /** @var DummyGetResponsePlugin */
  20. private $dummyGetResponsePlugin;
  21. protected function setUp(): void {
  22. parent::setUp();
  23. $this->dummyGetResponsePlugin = new DummyGetResponsePlugin();
  24. }
  25. public function testInitialize(): void {
  26. /** @var Server $server */
  27. $server = $this->getMockBuilder(Server::class)
  28. ->disableOriginalConstructor()
  29. ->getMock();
  30. $server
  31. ->expects($this->once())
  32. ->method('on')
  33. ->with('method:GET', [$this->dummyGetResponsePlugin, 'httpGet'], 200);
  34. $this->dummyGetResponsePlugin->initialize($server);
  35. }
  36. public function testHttpGet(): void {
  37. /** @var \Sabre\HTTP\RequestInterface $request */
  38. $request = $this->getMockBuilder(RequestInterface::class)
  39. ->disableOriginalConstructor()
  40. ->getMock();
  41. /** @var \Sabre\HTTP\ResponseInterface $response */
  42. $response = $server = $this->getMockBuilder(ResponseInterface::class)
  43. ->disableOriginalConstructor()
  44. ->getMock();
  45. $response
  46. ->expects($this->once())
  47. ->method('setBody');
  48. $response
  49. ->expects($this->once())
  50. ->method('setStatus')
  51. ->with(200);
  52. $this->assertSame(false, $this->dummyGetResponsePlugin->httpGet($request, $response));
  53. }
  54. }