/**
  * testMoveFileNodesToFolder
  * 
  * @return array target node
  */
 public function testMoveFileNodesToFolder()
 {
     $filesToMove = $this->testCreateFileNodes();
     $targetNode = $this->testCreateContainerNodeInPersonalFolder();
     $result = $this->_json->moveNodes($filesToMove, $targetNode['path'], FALSE);
     $this->assertEquals(2, count($result));
     $this->assertEquals($targetNode['path'] . '/file1', $result[0]['path']);
     $filter = array(array('field' => 'path', 'operator' => 'equals', 'value' => '/' . Tinebase_Model_Container::TYPE_SHARED . '/testcontainer'), array('field' => 'type', 'operator' => 'equals', 'value' => Tinebase_Model_Tree_Node::TYPE_FILE));
     $result = $this->_json->searchNodes($filter, array());
     $this->assertEquals(0, $result['totalcount']);
     return $targetNode;
 }
 /**
  * tests the recursive filter
  */
 public function testSearchRecursiveFilter()
 {
     $fixtures = array(array('/' . Tinebase_Model_Container::TYPE_PERSONAL . '/' . Tinebase_Core::getUser()->accountLoginName . '/testa', 'color-red.gif'), array('/' . Tinebase_Model_Container::TYPE_PERSONAL . '/' . Tinebase_Core::getUser()->accountLoginName . '/testb', 'color-green.gif'), array('/' . Tinebase_Model_Container::TYPE_PERSONAL . '/' . Tinebase_Core::getUser()->accountLoginName . '/testc', 'color-blue.gif'));
     $tempFileBackend = new Tinebase_TempFile();
     foreach ($fixtures as $path) {
         $node = $this->_json->createNode($path[0], Tinebase_Model_Tree_Node::TYPE_FOLDER, NULL, FALSE);
         $this->_objects['containerids'][] = $node['name']['id'];
         $this->assertTrue(is_array($node['name']));
         $this->assertEquals(str_replace('/' . Tinebase_Model_Container::TYPE_PERSONAL . '/' . Tinebase_Core::getUser()->accountLoginName . '/', '', $path[0]), $node['name']['name']);
         $this->assertEquals($path[0], $node['path']);
         $this->_objects['paths'][] = Filemanager_Controller_Node::getInstance()->addBasePath($node['path']);
         $filepath = $node['path'] . '/' . $path[1];
         // create empty file first (like the js frontend does)
         $result = $this->_json->createNode($filepath, Tinebase_Model_Tree_Node::TYPE_FILE, array(), FALSE);
         $tempFile = $tempFileBackend->createTempFile(dirname(dirname(__FILE__)) . '/files/' . $path[1]);
         $result = $this->_json->createNode($filepath, Tinebase_Model_Tree_Node::TYPE_FILE, $tempFile->getId(), TRUE);
     }
     $filter = array(array('field' => 'recursive', 'operator' => 'equals', 'value' => 1), array('field' => 'path', 'operator' => 'equals', 'value' => '/'), array('field' => 'query', 'operator' => 'contains', 'value' => 'color'), 'AND');
     $result = $this->_json->searchNodes($filter, array('sort' => 'name', 'start' => 0, 'limit' => 0));
     $this->assertEquals(3, count($result), '3 files should have been found!');
 }