public function query(RODSGenQueSelFlds $select, RODSGenQueConds $condition, $start = 0, $limit = -1) { //parent::query($select, $condition, $start, $limit); stubRODSConn::$params = array($select, $condition, $start, $limit); $name_array = array("/myZone"); $owner_array = array("me"); $zone_array = array("myZone"); $create_array = array("01298479459"); $modify_array = array("01298479459"); $comment_array = array("foo"); $names = $select->getNames(); if (array_search("COL_D_DATA_ID", $names)) { //this is a file stats request - 2 files $id_array = array("2"); $dname_array = array("first_file.txt"); $dtype_array = array("generic"); $dresc_array = array("testResc"); $dsize_array = array("1020157"); $result_array = array("COL_DATA_NAME" => $dname_array, "COL_COLL_NAME" => $name_array, "COL_D_DATA_ID" => $id_array, "COL_DATA_TYPE_NAME" => $dtype_array, "COL_D_RESC_NAME" => $dresc_array, "COL_DATA_SIZE" => $dsize_array, "COL_D_OWNER_NAME" => $owner_array, "COL_D_OWNER_ZONE" => $zone_array, "COL_D_CREATE_TIME" => $create_array, "COL_D_MODIFY_TIME" => $modify_array, "COL_D_COMMENTS" => $comment_array); } else { // this is a dirs stats request - 1 directory $name_array = array("/myZone"); $id_array = array("1"); $owner_array = array("me"); $zone_array = array("myZone"); $create_array = array("01298479459"); $modify_array = array("01298479459"); $comment_array = array("foo"); $result_array = array("COL_COLL_NAME" => $name_array, "COL_COLL_ID" => $id_array, "COL_COLL_OWNER_NAME", $owner_array, "COL_COLL_OWNER_ZONE" => $zone_array, "COL_COLL_CREATE_TIME" => $create_array, "COL_COLL_MODIFY_TIME" => $modify_array, "COL_COLL_COMMENTS" => $comment_array); } if ($limit == -1) { $total = 1; } else { $total = $limit; } $results = new RODSGenQueResults($total, $result_array); return $results; }
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); }
/** * @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()); }