DummyGetResponsePluginTest.php 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Thomas Müller <thomas.mueller@tmit.eu>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\DAV\Tests\unit\Connector\Sabre;
  27. use OCA\DAV\Connector\Sabre\DummyGetResponsePlugin;
  28. use Sabre\DAV\Server;
  29. use Sabre\HTTP\RequestInterface;
  30. use Sabre\HTTP\ResponseInterface;
  31. use Test\TestCase;
  32. /**
  33. * Class DummyGetResponsePluginTest
  34. *
  35. * @package OCA\DAV\Tests\unit\Connector\Sabre
  36. */
  37. class DummyGetResponsePluginTest extends TestCase {
  38. /** @var DummyGetResponsePlugin */
  39. private $dummyGetResponsePlugin;
  40. protected function setUp(): void {
  41. parent::setUp();
  42. $this->dummyGetResponsePlugin = new DummyGetResponsePlugin();
  43. }
  44. public function testInitialize() {
  45. /** @var Server $server */
  46. $server = $this->getMockBuilder(Server::class)
  47. ->disableOriginalConstructor()
  48. ->getMock();
  49. $server
  50. ->expects($this->once())
  51. ->method('on')
  52. ->with('method:GET', [$this->dummyGetResponsePlugin, 'httpGet'], 200);
  53. $this->dummyGetResponsePlugin->initialize($server);
  54. }
  55. public function testHttpGet() {
  56. /** @var \Sabre\HTTP\RequestInterface $request */
  57. $request = $this->getMockBuilder(RequestInterface::class)
  58. ->disableOriginalConstructor()
  59. ->getMock();
  60. /** @var \Sabre\HTTP\ResponseInterface $response */
  61. $response = $server = $this->getMockBuilder(ResponseInterface::class)
  62. ->disableOriginalConstructor()
  63. ->getMock();
  64. $response
  65. ->expects($this->once())
  66. ->method('setBody');
  67. $response
  68. ->expects($this->once())
  69. ->method('setStatus')
  70. ->with(200);
  71. $this->assertSame(false, $this->dummyGetResponsePlugin->httpGet($request, $response));
  72. }
  73. }