1<?php 2 3namespace Sabre\DAV; 4 5use Sabre\HTTP; 6 7require_once 'Sabre/TestUtil.php'; 8 9class Issue33Test extends \PHPUnit_Framework_TestCase { 10 11 function setUp() { 12 13 \Sabre\TestUtil::clearTempDir(); 14 15 } 16 17 function testCopyMoveInfo() { 18 19 $bar = new SimpleCollection('bar'); 20 $root = new SimpleCollection('webdav',array($bar)); 21 22 $server = new Server($root); 23 $server->setBaseUri('/webdav/'); 24 25 $serverVars = array( 26 'REQUEST_URI' => '/webdav/bar', 27 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', 28 'HTTP_OVERWRITE' => 'F', 29 ); 30 31 $request = HTTP\Sapi::createFromServerArray($serverVars); 32 33 $server->httpRequest = $request; 34 35 $info = $server->getCopyAndMoveInfo($request); 36 37 $this->assertEquals('%C3%A0fo%C3%B3', urlencode($info['destination'])); 38 $this->assertFalse($info['destinationExists']); 39 $this->assertFalse($info['destinationNode']); 40 41 } 42 43 function testTreeMove() { 44 45 mkdir(SABRE_TEMPDIR . '/issue33'); 46 $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33'); 47 48 $dir->createDirectory('bar'); 49 50 $tree = new Tree($dir); 51 $tree->move('bar',urldecode('%C3%A0fo%C3%B3')); 52 53 $node = $tree->getNodeForPath(urldecode('%C3%A0fo%C3%B3')); 54 $this->assertEquals(urldecode('%C3%A0fo%C3%B3'),$node->getName()); 55 56 } 57 58 function testDirName() { 59 60 $dirname1 = 'bar'; 61 $dirname2 = urlencode('%C3%A0fo%C3%B3');; 62 63 $this->assertTrue(dirname($dirname1)==dirname($dirname2)); 64 65 } 66 67 /** 68 * @depends testTreeMove 69 * @depends testCopyMoveInfo 70 */ 71 function testEverything() { 72 73 // Request object 74 $serverVars = array( 75 'REQUEST_METHOD' => 'MOVE', 76 'REQUEST_URI' => '/webdav/bar', 77 'HTTP_DESTINATION' => 'http://dev2.tribalos.com/webdav/%C3%A0fo%C3%B3', 78 'HTTP_OVERWRITE' => 'F', 79 ); 80 81 $request = HTTP\Sapi::createFromServerArray($serverVars); 82 $request->setBody(''); 83 84 $response = new HTTP\ResponseMock(); 85 86 // Server setup 87 mkdir(SABRE_TEMPDIR . '/issue33'); 88 $dir = new FS\Directory(SABRE_TEMPDIR . '/issue33'); 89 90 $dir->createDirectory('bar'); 91 92 $tree = new Tree($dir); 93 94 $server = new Server($tree); 95 $server->setBaseUri('/webdav/'); 96 97 $server->httpRequest = $request; 98 $server->httpResponse = $response; 99 $server->sapi = new HTTP\SapiMock(); 100 $server->exec(); 101 102 $this->assertTrue(file_exists(SABRE_TEMPDIR . '/issue33/' . urldecode('%C3%A0fo%C3%B3'))); 103 104 } 105 106} 107