コード例 #1
0
 public function testFindFiles()
 {
     $path = "/path/tonowhere";
     $mocked_prodsdir_construct_params = array(&$this->rodsAcct, $path);
     $mocked_prodsdir_methods = array('exists');
     $prods_dir_stub = $this->getMock('ProdsDir', $mocked_prodsdir_methods, $mocked_prodsdir_construct_params);
     $prods_dir_stub->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
     $terms = array("descendantOnly" => true, "recursive" => false, "logicalFile" => false);
     $total_count = -1;
     $stats = $prods_dir_stub->findFiles($terms, $total_count, 0, -1, array("name"), array('stubRODSConnManager', 'getConn'), array('stubRODSConnManager', 'releaseConn'));
     // check total count return
     $this->assertEquals(1, $total_count);
     // test limiting number of results to 0
     $prods_dir_stub->findFiles($terms, $total_count, 0, 0, array(), array('stubRODSConnManager', 'getConn'), array('stubRODSConnManager', 'releaseConn'));
     $this->assertEquals(0, $total_count);
     // test that all search conditions ($terms) are specified correctly in params to RODSConn:query()
     // 'name' (string) - partial name of the target (file or dir)
     // 'descendantOnly' (boolean) - whether to search among this directory's decendents. default is false.
     // 'recursive'      (boolean) - whether to search recursively, among all decendents and their children. default is false. This option only works when 'descendantOnly' is true
     // 'logicalFile'    (boolean) - whether to return logical file, instead of all replicas for each file. if true, the resource name for each file will be null, instead, num_replicas will be provided. default is false.
     // 'smtime'         (int)     - start last-modified-time in unix timestamp. The specified time is included in query, in other words the search can be thought was "mtime >= specified time"
     // 'emtime'         (int)     - end last-modified-time in unix timestamp. The specified time is not included in query, in other words the search can be thought was "mtime < specified time"
     // 'owner'          (string)  - owner name of the file
     // 'rescname'       (string)  - resource name of the file
     $terms = array("name" => "test");
     $prods_dir_stub->findFiles($terms, $total_count, 0, -1, array(), array('stubRODSConnManager', 'getConn'), array('stubRODSConnManager', 'releaseConn'));
     $params_array = stubRODSConn::getParams();
     $cond = $params_array[1]->getCond();
     // test all sort conditions ($sort_flds) are specified correctly in params to RODSConn:query()
     // 'name'      - name of the file or dir
     // 'size'      - size of the file
     // 'mtime'     - last modified time
     // 'ctime'     - creation time
     // 'owner'     - owner of the file
     // 'typename'  - file/data type
     // 'dirname'   - directory/collection name for the file
     //        var_dump($stats);
     //        $params_array = stubRODSConn::getParams();
     //        var_dump($params_array);
     //        $params_array = stubRODSConn::getParams();
     //        $actual_name = $params_array[0]->getNames();
     //        $this->assertEquals("COL_COLL_ID", $actual_name[0]);
     //        $this->assertEquals(1, $stats);
 }
コード例 #2
0
 /**
  * @todo Implement testRename().
  */
 public function testRename()
 {
     $path = "/path/tohere";
     $new_ppath = "/path";
     $new_name = "to_new_here";
     $new_path = $new_ppath . "/" . $new_name;
     $mocked_prodspath_construct_params = array(&$this->rodsAcct, $path);
     $prods_path_stub = $this->getMockForAbstractClass('ProdsPath', $mocked_prodspath_construct_params, 'ProdsFile1');
     $prods_path_stub->rename($new_path, array('stubRODSConnManager', 'getConn'), array('stubRODSConnManager', 'releaseConn'));
     $params_array = stubRODSConn::getParams();
     $this->assertEquals($path, $params_array[0]);
     $this->assertEquals($new_path, $params_array[1]);
     // PROBABLY SHOULD ALSO ADD TEST FOR INSTANCE OF PRODSFILE PATH (params_array[2] = "0") IN METHOD SOURCE CODE
     $this->assertEquals("1", $params_array[2]);
     $this->assertEquals($new_path, $prods_path_stub->getPath());
     $this->assertEquals($new_ppath, $prods_path_stub->getParentPath());
     $this->assertEquals($new_name, $prods_path_stub->getName());
 }