diff options
author | Thomas Müller <DeepDiver1975@users.noreply.github.com> | 2016-09-23 19:57:07 +0200 |
---|---|---|
committer | Lukas Reschke <lukas@statuscode.ch> | 2016-09-28 21:12:50 +0200 |
commit | bd96c6aa38618dd7533ffbb0b6148c7e1522c1a6 (patch) | |
tree | f6de7a031bbc7cf7d0f0965b08f7d3d947e5b643 /apps/dav/tests/unit | |
parent | 2eaa2791b75f7c2c8c7892a5354f6e93fedaf396 (diff) | |
download | nextcloud-server-bd96c6aa38618dd7533ffbb0b6148c7e1522c1a6.tar.gz nextcloud-server-bd96c6aa38618dd7533ffbb0b6148c7e1522c1a6.zip |
Return ETag and OC-ETag in case of a move (#25683)
Downstreaming of https://github.com/owncloud/core/pull/25683
Signed-off-by: Lukas Reschke <lukas@statuscode.ch>
Diffstat (limited to 'apps/dav/tests/unit')
-rw-r--r-- | apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php | 37 |
1 files changed, 32 insertions, 5 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php index 0ee1b9591f3..773d5d7f98b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php @@ -23,23 +23,28 @@ */ namespace OCA\DAV\Tests\unit\Connector\Sabre; +use OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin; +use Sabre\DAV\Server; +use Test\TestCase; + /** * Copyright (c) 2015 Vincent Petry <pvince81@owncloud.com> * This file is licensed under the Affero General Public License version 3 or * later. * See the COPYING-README file. */ -class CopyEtagHeaderPluginTest extends \Test\TestCase { +class CopyEtagHeaderPluginTest extends TestCase { - /** - * @var \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin - */ + /** @var CopyEtagHeaderPlugin */ private $plugin; + /** @var Server */ + private $server; + public function setUp() { parent::setUp(); $this->server = new \Sabre\DAV\Server(); - $this->plugin = new \OCA\DAV\Connector\Sabre\CopyEtagHeaderPlugin(); + $this->plugin = new CopyEtagHeaderPlugin(); $this->plugin->initialize($this->server); } @@ -61,4 +66,26 @@ class CopyEtagHeaderPluginTest extends \Test\TestCase { $this->assertNull($response->getHeader('OC-Etag')); } + + public function testAfterMove() { + $node = $this->getMockBuilder('OCA\DAV\Connector\Sabre\File') + ->disableOriginalConstructor() + ->getMock(); + $node->expects($this->once()) + ->method('getETag') + ->willReturn('123456'); + $tree = $this->getMockBuilder('Sabre\DAV\Tree') + ->disableOriginalConstructor() + ->getMock(); + $tree->expects($this->once()) + ->method('getNodeForPath') + ->with('test.txt') + ->willReturn($node); + + $this->server->tree = $tree; + $this->plugin->afterMove('', 'test.txt'); + + $this->assertEquals('123456', $this->server->httpResponse->getHeader('OC-Etag')); + $this->assertEquals('123456', $this->server->httpResponse->getHeader('Etag')); + } } |