]> source.dussan.org Git - nextcloud-server.git/commitdiff
code cleanup
authorThomas Müller <thomas.mueller@tmit.eu>
Fri, 27 Sep 2013 11:41:23 +0000 (13:41 +0200)
committerThomas Müller <thomas.mueller@tmit.eu>
Fri, 27 Sep 2013 11:41:23 +0000 (13:41 +0200)
tests/lib/connector/sabre/objecttree.php

index c920441c8b42d2f94f0f2401611d711887c80942..1d76bb596766035b264b4ebf9ce67efd6e615460 100644 (file)
@@ -36,38 +36,14 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
         * @expectedException Sabre_DAV_Exception_Forbidden
         */
        public function testMoveFailed($source, $dest, $updatables) {
-               $rootDir = new OC_Connector_Sabre_Directory('');
-               $objectTree = $this->getMock('\OC\Connector\Sabre\ObjectTree',
-                       array('nodeExists', 'getNodeForPath'),
-                       array($rootDir));
-
-               $objectTree->expects($this->once())
-                       ->method('getNodeForPath')
-                       ->with($this->identicalTo('a/b'))
-                       ->will($this->returnValue(false));
-
-               /** @var $objectTree \OC\Connector\Sabre\ObjectTree */
-               $objectTree->fileView = new TestDoubleFileView($updatables);
-               $objectTree->move($source, $dest);
+               $this->moveTest($source, $dest, $updatables);
        }
 
        /**
         * @dataProvider moveSuccessProvider
         */
        public function testMoveSuccess($source, $dest, $updatables) {
-               $rootDir = new OC_Connector_Sabre_Directory('');
-               $objectTree = $this->getMock('\OC\Connector\Sabre\ObjectTree',
-                       array('nodeExists', 'getNodeForPath'),
-                       array($rootDir));
-
-               $objectTree->expects($this->once())
-                       ->method('getNodeForPath')
-                       ->with($this->identicalTo('a/b'))
-                       ->will($this->returnValue(false));
-
-               /** @var $objectTree \OC\Connector\Sabre\ObjectTree */
-               $objectTree->fileView = new TestDoubleFileView($updatables);
-               $objectTree->move($source, $dest);
+               $this->moveTest($source, $dest, $updatables);
                $this->assertTrue(true);
        }
 
@@ -87,18 +63,25 @@ class ObjectTree extends PHPUnit_Framework_TestCase {
                );
        }
 
-//     private function buildFileViewMock($updatables) {
-//             // mock filesysten
-//             $view = $this->getMock('\OC\Files\View', array('isUpdatable'), array(), '', FALSE);
-//
-//             foreach ($updatables as $path => $updatable) {
-//                     $view->expects($this->any())
-//                             ->method('isUpdatable')
-//                             ->with($this->identicalTo($path))
-//                             ->will($this->returnValue($updatable));
-//             }
-//
-//             return $view;
-//     }
+       /**
+        * @param $source
+        * @param $dest
+        * @param $updatables
+        */
+       private function moveTest($source, $dest, $updatables) {
+               $rootDir = new OC_Connector_Sabre_Directory('');
+               $objectTree = $this->getMock('\OC\Connector\Sabre\ObjectTree',
+                       array('nodeExists', 'getNodeForPath'),
+                       array($rootDir));
+
+               $objectTree->expects($this->once())
+                       ->method('getNodeForPath')
+                       ->with($this->identicalTo($source))
+                       ->will($this->returnValue(false));
+
+               /** @var $objectTree \OC\Connector\Sabre\ObjectTree */
+               $objectTree->fileView = new TestDoubleFileView($updatables);
+               $objectTree->move($source, $dest);
+       }
 
 }