diff options
author | Morris Jobke <hey@morrisjobke.de> | 2016-09-28 21:46:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-28 21:46:51 +0200 |
commit | 85301df8176fdbdb2486c3241bd7e2f23ce1b916 (patch) | |
tree | 1be43b1f64ab18b0dc8323f1e0bcdd4a6a16479b /apps/dav/tests | |
parent | ef0760f84f7da2adbb44851aa8ff4f6fdbdf4720 (diff) | |
parent | bd96c6aa38618dd7533ffbb0b6148c7e1522c1a6 (diff) | |
download | nextcloud-server-85301df8176fdbdb2486c3241bd7e2f23ce1b916.tar.gz nextcloud-server-85301df8176fdbdb2486c3241bd7e2f23ce1b916.zip |
Merge pull request #1513 from nextcloud/fix-etag-on-move
Return ETag and OC-ETag in case of a move (#25683)
Diffstat (limited to 'apps/dav/tests')
-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')); + } } |