FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
fossologyTestCase.php
1 <?php
2 
3 /***********************************************************
4  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License
8  version 2 as published by the Free Software Foundation.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License along
16  with this program; if not, write to the Free Software Foundation, Inc.,
17  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  ***********************************************************/
31 require_once ('TestEnvironment.php');
32 require_once ('fossologyTest.php');
33 
44 {
45  public $mybrowser;
46  public $debug;
47  public $webProxy;
48 
65  public function addUser($UserName, $Description = NULL, $Email = NULL, $Access = 1, $Folder = 1, $Password = NULL, $EmailNotify = 'y')
66  {
67 
68  global $URL;
69 
70  // check user name, everything else defaults (not a good idea to use defaults)
71  if (empty ($UserName))
72  {
73  return ("No User Name, cannot add user");
74  }
75 
76  $page = $this->mybrowser->get($URL);
77  $page = $this->mybrowser->clickLink('Add');
78  $this->assertTrue($this->myassertText($page, '/Add A User/'), "Did NOT find Title, 'Add A User'");
79 
80  $this->setUserFields($UserName, $Description, $Email, $Access, $Folder, NULL, NULL, $Password, $EmailNotify);
81 
82  /* fields set, add the user */
83  $page = $this->mybrowser->clickSubmit('Add!', "Could not select the Add! button");
84  $this->assertTrue($page);
85  //print "<pre>page after clicking Add!\n"; print_r($page) . "\n</pre>";
86  if ($this->myassertText($page, "/User .*? added/"))
87  {
88  return (NULL);
89  } else
90  if ($this->myassertText($page, "/User already exists\. Not added/"))
91  {
92  return ('User already exists. Not added');
93  } else
94  if ($this->myassertText($page, "/ERROR/"))
95  {
96  return ("addUser FAILED! ERROR when adding users, please investigate");
97  }
98  return (NULL);
99  } // addUser
100 
118  public function checkEmailNotification($number)
119  {
120 
121  if (empty ($number))
122  {
123  return (array (
124  0,
125  'ERROR! Must supply a number to verify'
126  ));
127  }
128 
129  $headers = getMailSubjects();
130  if (empty ($headers))
131  {
132  //print "No messages found\n";
133  $this->pass();
134  return (NULL);
135  }
136  //print "Got back from getMailSubjects:\n";print_r($headers) . "\n";
137 
138  /*
139  check for errors
140  */
144  if (preg_match('/ERROR/', $headers[0], $matches))
145  {
146  $this->fail("{$headers[0]}\n");
147  return (FALSE);
148  }
149  $pattern = 'completed with no errors';
150 
151  $failed = array ();
152  foreach ($headers as $header)
153  {
154  /* Make sure all say completed */
155  $match = preg_match("/$pattern/", $header, $matches);
156  if ($match == 0)
157  {
158  $failed[] = $header;
159  }
160  }
161  if (!empty ($failed))
162  {
163  $this->fail("Failures! there were jobs that did not report as completed\n");
164  //foreach($failed as $fail) {
165  // print "$fail\n";
166  return ($failed);
167  }
168  }
169 
188  public function createFolder($parent = null, $name, $description = null)
189  {
190 
191  global $URL;
192  $FolderId = 0;
193 
194  /* Need to check parameters */
195  if (is_null($parent))
196  {
197  $FolderId = 1; // default is root folder
198  }
199  if (is_null($description))
200  { // set default if null
201  $description = "Folder $name created by createFolder as subfolder of $parent";
202  }
203  if(empty($name))
204  {
205  $this->fail("FATAL! No folder name supplied, cannot create folder\n");
206  }
207  $page = $this->mybrowser->get($URL);
208  // There is only 1 create menu, so just select it
209  // No need to make sure we are in folders menu.
210  $page = $this->mybrowser->clickLink('Create');
211  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
212  /* if $FolderId=0 select the folder to create this folder under */
213  if (!$FolderId)
214  {
215  $FolderId = $this->getFolderId($parent, $page, 'parentid');
216  }
217  $this->assertTrue($this->mybrowser->setField('parentid', $FolderId));
218  $this->assertTrue($this->mybrowser->setField('newname', $name),
219  "FATAL! Could not set newname for folder:$name\n");
220  $this->assertTrue($this->mybrowser->setField('description', "$description"),
221  "FATAL! Could not set description for folder:$name\n");
222  $createdPage = $this->mybrowser->clickSubmit('Create!');
223  $this->assertTrue($createdPage);
224  if ($this->myassertText($createdPage, "/Folder $name Created/"))
225  {
226  $folderId = $this->getFolderId($name, $createdPage, 'parentid');
227  return ($folderId);
228  }
229  if ($this->myassertText($createdPage, "/Folder $name Exists/"))
230  {
231  $folderId = $this->getFolderId($name, $createdPage, 'parentid');
232  return ($folderId);
233  }
234  else
235  {
236  $this->fail("Failure! Did not find phrase 'Folder $name Created'\n");
237  }
238  }
239 
254  public function deleteFolder($folder)
255  {
256  global $URL;
257 
258  $page = $this->mybrowser->get($URL);
259  $page = $this->mybrowser->clickLink('Delete Folder');
260  $this->assertTrue($this->myassertText($page, '/Select the folder to delete/'));
261  $FolderId = $this->getFolderId($folder, $page, 'folder');
262  if (empty ($FolderId)) // not in the list of folders
263  {
264  return (true);
265  }
266  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
267  $page = $this->mybrowser->clickSubmit('Delete!');
268  $this->assertTrue($page);
269  $this->assertTrue($this->myassertText($page, "/Deletion of folder $folder added to job queue/"), "delete Folder Failed!\nPhrase 'Deletion of folder $folder added to job queue' not found\n");
270  }
271 
286  public function deleteUpload($upload)
287  {
288  global $URL;
289 
290  $page = $this->mybrowser->get($URL);
291  $page = $this->mybrowser->clickLink('Delete Uploaded File');
292  $this->assertTrue($this->myassertText($page, '/Select the uploaded file to delete/'));
293  $UploadId = $this->getUploadId($upload, $page, 'upload');
294  if (empty ($UploadId)) // not in the list of uploads on the root page
295  {
296  return (FALSE);
297  }
298  $this->assertTrue($this->mybrowser->setField('upload', $UploadId));
299  $page = $this->mybrowser->clickSubmit('Delete!');
300  $this->assertTrue($page);
301  $this->assertTrue($this->myassertText($page, "/Deletion added to job queue/"), "delete Upload Failed!\nPhrase 'Deletion added to job queue' not found\n");
302  }
303 
310  public function deleteUser($User)
311  {
312 
313  global $URL;
314 
315  if (empty ($User))
316  {
317  return ('No User Specified');
318  }
319  // Should already be logged in... no need to call this: $this->Login();
320  $page = $this->mybrowser->get("$URL?mod=user_del");
321  /* Get the user id */
322  $select = $this->parseSelectStmnt($page, 'userid', $User);
323  if (!is_null($select))
324  {
325  $this->assertTrue($this->mybrowser->setField('userid', $select));
326  $this->assertTrue($this->mybrowser->setField('confirm', 1));
327  $page = $this->mybrowser->clickSubmit('Delete!', "Could not select the Delete! button");
328  $this->assertTrue($page);
329  if ($this->myassertText($page, "/User deleted/"))
330  {
331  print "User $User Deleted\n";
332  $this->pass();
333  } else
334  {
335  $this->fail("Delete User Failed!\nPhrase 'User deleted' not found\n");
336  }
337  }
338  } // Delete User
350  public function editFolder($folder, $newName, $description = null)
351  {
352  global $URL;
353 
354  /* Need to check parameters */
355  if (empty ($folder))
356  {
357  return (FALSE);
358  }
359  if (is_null($description)) // set default if null
360  {
361  $description = "Folder $newName edited by editFolder Test, this is the changed description";
362  }
363  $page = $this->mybrowser->get($URL);
364  $page = $this->mybrowser->clickLink('Edit Properties');
365  $this->assertTrue($this->myassertText($page, '/Edit Folder Properties/'));
366  $FolderId = $this->getFolderId($folder, $page, 'oldfolderid');
367  $this->assertTrue($this->mybrowser->setField('oldfolderid', $FolderId));
368  if (!(empty ($newName)))
369  {
370  $this->assertTrue($this->mybrowser->setField('newname', $newName));
371  }
372  $this->assertTrue($this->mybrowser->setField('newdesc', "$description"));
373  $page = $this->mybrowser->clickSubmit('Edit!');
374  $this->assertTrue($page);
375  $this->assertTrue($this->myassertText($page, "/Folder Properties changed/"), "editFolder Failed!\nPhrase 'Folder Properties changed' not found\n");
376  }
395  public function editUser($UserName, $Description = NULL, $Email = NULL, $Access = 1, $Folder = 1, $Block = NULL, $Blank = NULL, $Password = NULL, $EmailNotify = 'y')
396  {
397 
398  global $URL;
399 
400  // check user name, everything else defaults (not a good idea to use defaults)
401  if (empty ($UserName))
402  {
403  return ("No User Name, cannot add user");
404  }
405  $page = $this->mybrowser->get($URL);
406  $page = $this->mybrowser->clickLink('Edit Users');
407  $this->assertTrue($this->myassertText($page, '/Edit A User/'), "Did NOT find Title, 'Edit A User'");
408  $this->setUserFields($UserName, $Description, $Email, $Access, $Folder, NULL, NULL, $Password, $EmailNotify);
409 
410  /* fields set, edit the user */
411  $page = $this->mybrowser->clickSubmit('Edit!', "Could not select the Edit! button");
412  $this->assertTrue($page);
413  //print "<pre>page after clicking Add!\n"; print_r($page) . "\n</pre>";
414  if ($this->myassertText($page, "/User edited/"))
415  {
416  return (NULL);
417  }
418  return;
419  } // addUser
438  public function moveUpload($oldFolder, $destFolder, $upload)
439  {
440  global $URL;
441  print "mU: OF:$oldFolder DF:$destFolder U:$upload\n";
442  if (empty ($oldFolder))
443  {
444  return FALSE;
445  }
446  if (empty ($destFolder))
447  {
448  $destFolder = 'root'; // default is root folder
449  }
450  $page = $this->mybrowser->get($URL);
451  /* use the method below till you write a menu function */
452  $page = $this->mybrowser->get("$URL?mod=upload_move");
453  //$page = $this->mybrowser->clickLink('Move');
454  $this->assertTrue($this->myassertText($page, '/Move upload to different folder/'));
455  $oldFolderId = $this->getFolderId($oldFolder, $page, 'oldfolderid');
456  $this->assertTrue($this->mybrowser->setField('oldfolderid', $oldFolderId));
457  $uploadId = $this->getUploadId($upload, $page, 'uploadid');
458  if (empty ($uploadId))
459  {
460  $this->fail("moveUpload FAILED! could not find upload id for upload" .
461  "$upload\n is $upload in $oldFolder?\n");
462  }
463  $this->assertTrue($this->mybrowser->setField('uploadid', $uploadId));
464  $destFolderId = $this->getFolderId($destFolder, $page, 'targetfolderid');
465  $this->assertTrue($this->mybrowser->setField('targetfolderid', $destFolderId));
466  $page = $this->mybrowser->clickSubmit('Move!');
467  $this->assertTrue($page);
468  print "page after move is:\n$page\n";
469  $this->assertTrue($this->myassertText($page,
470  //"/Moved $upload from folder $oldFolder to folder $destFolder/"),
471  "/Moved $upload from folder /"), "moveUpload Failed!\nPhrase 'Move $upload from folder $oldFolder " .
472  "to folder $destFolder' not found\n");
473  }
474 
485  public function mvFolder($folder, $destination)
486  {
487  global $URL;
488  if (empty ($folder))
489  {
490  return (FALSE);
491  }
492  if (empty ($destination))
493  {
494  $destination = 1;
495  }
496  $page = $this->mybrowser->get($URL);
497  $page = $this->mybrowser->clickLink('Move');
498  $this->assertTrue($this->myassertText($page, '/Move Folder/'));
499  $FolderId = $this->getFolderId($folder, $page, 'oldfolderid');
500  $this->assertTrue($this->mybrowser->setField('oldfolderid', $FolderId));
501  if ($destination != 1)
502  {
503  $DfolderId = $this->getFolderId($destination, $page, 'targetfolderid');
504  }
505  $this->assertTrue($this->mybrowser->setField('targetfolderid', $DfolderId));
506  $page = $this->mybrowser->clickSubmit('Move!');
507  $this->assertTrue($page);
508  $this->assertTrue($this->myassertText($page, "/Moved folder $folder to folder $destination/"), "moveFolder Failed!\nPhrase 'Move folder $folder to folder ....' not found\n");
509  }
510 
521  public function fillGroupForm($groupName, $user)
522  {
523  global $URL;
524 
525  if (is_NULL($groupName))
526  {
527  $msg = "FATAL! no group name to set\n";
528  $this->fail($msg);
529  return ($msg);
530  }
531  if (is_NULL($user))
532  {
533  $msg = "FATAL! no user name to set\n";
534  $this->fail($msg);
535  return ($msg);
536  }
537  // make sure we are on the page
538  $page = $this->mybrowser->get("$URL?mod=group_manage");
539  $this->assertTrue($this->myassertText($page, '/Manage Group/'), "Did NOT find Title, 'Manage Group'");
540  $this->assertTrue($this->myassertText($page, '/Add a Group/'), "Did NOT find phrase, 'Add a Group'");
541 
542  // set the fields
543  $groupNotSet = 'FATAL! Could Not set the groupname field';
544  if (!empty ($groupName))
545  {
546  $this->assertTrue($this->mybrowser->setField('groupname', $groupName), $groupNotSet);
547  }
548  if (!empty ($user))
549  {
550  $userNotSet = 'FATAL! Could Not set the userid field in select';
551  $this->assertTrue($this->mybrowser->setField('userid', $user), $userNotSet);
552  //return($userNotSet);
553  }
554  return (NULL);
555  } //fillGroupForm
556 
572  protected function setUserFields($UserName = NULL, $Description = NULL,
573  $Email = NULL, $Access = 1, $Folder = 1, $Block = NULL, $Blank = NULL,
574  $Password = NULL, $EmailNotify = NULL, $BucketPool = 1, $Ui = 'simple')
575  {
576 
577  $FailStrings = NULL;
578  $simple = FALSE;
579  $original = FALSE;
580 
581  global $URL;
582 
583  if (strtoupper($UserName) == 'NULL')
584  {
585  $this->fail("setUserFields, FATAL! no user name to set\n");
586  }
587  if (strtoupper($Description) == 'NULL')
588  {
589  $Description = '';
590  }
591  if (strtoupper($Email) == 'NULL')
592  {
593  $Email = '';
594  }
595  if (strtoupper($Access) == 'NULL')
596  {
597  $Access = 1;
598  }
599  if (strtoupper($Folder) == 'NULL')
600  {
601  $Folder = 1;
602  }
603  if (strtoupper($Block) == 'NULL')
604  {
605  $Block = '';
606  }
607  if (strtoupper($Blank) == 'NULL')
608  {
609  $Blank = '';
610  }
611  if (strtoupper($Password) == 'NULL')
612  {
613  $Password = '';
614  }
615  if (strtoupper($EmailNotify) == 'NULL' || is_null($EmailNotify))
616  {
617  unset ($EmailNotify);
618  }
619  if ($BucketPool == NULL)
620  {
621  $BucketPool = 1; // default bucket pool
622  }
623  if (strcasecmp($Ui, 'simple'))
624  {
625  $simple = TRUE;
626  }
627  else if (strcasecmp($Ui, 'original'))
628  {
629  $orignal = TRUE;
630  }
631 
632  $page = $this->mybrowser->get($URL);
633  $page = $this->mybrowser->clickLink('Add');
634  $this->assertTrue($this->myassertText($page, '/Add A User/'),
635  "Did NOT find Title, 'Add A User'");
636 
637  if (!empty ($UserName))
638  {
639  $this->assertTrue($this->mybrowser->setField('username', $UserName),
640  "Could Not set the username field");
641  }
642  if (!empty ($Description))
643  {
644  $this->assertTrue($this->mybrowser->setField('description', $Description),
645  "Could Not set the description field");
646  }
647  if (!empty ($Email))
648  {
649  $this->assertTrue($this->mybrowser->setField('email', $Email),
650  "Could Not set the email field");
651  }
652  if (!empty ($Access))
653  {
654  $this->assertTrue($this->mybrowser->setField('permission', $Access),
655  "Could Not set the permission field");
656  } else
657  {
658  return ('FATAL: Access/permission is a required field');
659  }
660  if (!empty ($Folder))
661  {
662  $this->assertTrue($this->mybrowser->setField('folder', $Folder),
663  "Could Not set the folder Field");
664  }
665  if (!empty ($Block))
666  {
667  $this->assertTrue($this->mybrowser->setField('block', $Block),
668  "Could Not set the block Field");
669  }
670  if (!empty ($Blank))
671  {
672  $this->assertTrue($this->mybrowser->setField('blank', $Blank),
673  "Could Not set the blank Field");
674  }
675  if (!empty ($Password))
676  {
677  $this->assertTrue($this->mybrowser->setField('pass1', $Password),
678  "Could Not set the pass1 field");
679  $this->assertTrue($this->mybrowser->setField('pass2', $Password),
680  "Could Not set the pass2 field");
681  }
682  if (isset ($EmailNotify))
683  {
684  $this->assertTrue($this->mybrowser->setField('enote', TRUE),
685  "Could Not set the enote Field to non default value");
686  } else
687  {
688  $this->assertTrue($this->mybrowser->setField('enote', FALSE),
689  "Could Not set the enote Field");
690  }
691  if (!empty($BucketPool))
692  {
693  $this->assertTrue($this->mybrowser->setField('default_bucketpool_fk', $BucketPool),
694  "Could Not set the default bucketpool select");
695  }
696  if ($simple)
697  {
698  $this->assertTrue($this->mybrowser->setField('simple', 'checked'),
699  "Could Not set the simple check box");
700 
701  }
702  if($original)
703  {
704  $this->assertTrue($this->mybrowser->setField('original', 'checked'),
705  "Could Not set the original check box");
706  }
707  return (NULL);
708  } // setUserFields
709 
726  public function uploadFile($parentFolder, $uploadFile, $description = null, $uploadName = null, $agents = null)
727  {
728  global $URL;
729  /*
730  * check parameters:
731  * default parent folder is root folder
732  * no uploadfile return false
733  * description and upload name are optonal
734  * future: agents are optional
735  */
736  if (empty ($parentFolder))
737  {
738  $parentFolder = 1;
739  }
740  if (empty ($uploadFile))
741  {
742  return (FALSE);
743  }
744  if (is_null($description)) // set default if null
745  {
746  $description = "File $uploadFile uploaded by test UploadFileTest";
747  }
748  //print "starting uploadFile\n";
749  $loggedIn = $this->mybrowser->get($URL);
750  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'));
751  $page = $this->mybrowser->get("$URL?mod=upload_file");
752  $this->assertTrue($this->myassertText($page, '/Upload a New File/'));
753  $this->assertTrue($this->myassertText($page, '/Select the file to upload:/'));
754  $FolderId = $this->getFolderId($parentFolder, $page, 'folder');
755  $this->assertTrue($this->mybrowser->setField('folder', $FolderId),
756  "uploadFile FAILED! could not set 'folder' field!\n");
757  $this->assertTrue($this->mybrowser->setField('getfile', "$uploadFile"),
758  "uploadFile FAILED! could not set 'getfile' field!\n");
759  $this->assertTrue($this->mybrowser->setField('description', "$description"),
760  "uploadFile FAILED! could not set 'description' field!\n");
761  /*
762  * the test will fail if name is set to null, so we special case it
763  * rather than just set it.
764  */
765  if (!(is_null($uploadName)))
766  {
767  $this->assertTrue($this->mybrowser->setField('name', "$uploadName"),
768  "uploadFile FAILED! could not set 'name' field!\n");
769  }
770  /*
771  * Select agents to run, we just pass on the parameter to setAgents,
772  * don't bother if null
773  */
774  if (!(is_null($agents)))
775  {
776  $this->setAgents($agents);
777  }
778  $page = $this->mybrowser->clickSubmit('Upload');
779  $this->assertTrue($page);
780  $this->assertTrue($this->myassertText($page, '/The file .*? has been uploaded/'), "FAILURE:Did not find the message 'The file .*? has been uploaded'\n");
781  } // uploadFile
802  public function uploadServer($parentFolder = 1, $uploadPath, $description = null, $uploadName = null, $agents = null)
803  {
804  global $URL;
805  global $PROXY;
806  /*
807  * check parameters:
808  * default parent folder is root folder
809  * no uploadfile return false
810  * description and upload name are optonal
811  * future: agents are optional
812  */
813  if (empty ($parentFolder))
814  {
815  $parentFolder = 1;
816  }
817  if (empty ($uploadPath))
818  {
819  return (FALSE);
820  }
821  if (is_null($description)) // set default if null
822  {
823  $description = "File $uploadPath uploaded by test UploadAUrl";
824  }
825  //print "starting UploadAUrl\n";
826  $loggedIn = $this->mybrowser->get($URL);
827  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'), "uploadURL FAILED! cannot file Upload menu, did we get a fossology page?\n");
828  $page = $this->mybrowser->clickLink("From Server");
829 
830  $this->assertTrue($this->myassertText($page, '/Upload from Server/'));
831  $this->assertTrue($this->myassertText($page, '/Select the directory or file\(s\) on the server to upload/'));
832  /* only look for the the folder id if it's not the root folder */
833  $folderId = $parentFolder;
834  if ($parentFolder != 1)
835  {
836  $folderId = $this->getFolderId($parentFolder, $page, 'folder');
837  }
838  $this->assertTrue($this->mybrowser->setField('folder', $folderId), "Count not set folder field\n");
839  $this->assertTrue($this->mybrowser->setField('sourcefiles', $uploadPath), "Count not set sourcefiles field\n");
840  $this->assertTrue($this->mybrowser->setField('description', "$description"), "Count not set description field\n");
841  /* Set the name field if an upload name was passed in. */
842  if (!is_null($uploadName))
843  {
844  $this->assertTrue($this->mybrowser->setField('name', $uploadName));
845  }
846  /* selects agents */
847  $rtn = $this->setAgents($agents);
848  if (!is_null($rtn))
849  {
850  $this->fail("FAIL: could not set agents in uploadServer test\n");
851  }
852  $page = $this->mybrowser->clickSubmit('Upload!');
853  $this->assertTrue($page);
854  $this->assertTrue($this->myassertText($page, '/The upload for .*? has been scheduled/'), "FAIL! did not see phrase The upload for .*? has been scheduled\n");
855  //print "************ page after Upload! *************\n$page\n";
856  } //uploadServer
857 
877  public function uploadUrl($parentFolder = 1, $url, $description = null, $uploadName = null, $agents = null)
878  {
879  global $URL;
880  global $PROXY;
881  /*
882  * check parameters:
883  * default parent folder is root folder
884  * no uploadfile return false
885  * description and upload name are optonal
886  * future: agents are optional
887  */
888  if (empty ($parentFolder))
889  {
890  $parentFolder = 1;
891  }
892  if (empty ($url))
893  {
894  return (FALSE);
895  }
896  if (is_null($description)) // set default if null
897  {
898  $description = "File $url uploaded by test UploadAUrl";
899  }
900  //print "starting UploadAUrl\n";
901  $loggedIn = $this->mybrowser->get($URL);
902  $this->assertFalse($this->myassertText($loggedIn, '/Network Error/'), "uploadURL FAILED! there was a Newtwork Error (dns lookup?)\n");
903  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'), "uploadURL FAILED! cannot file Upload menu, did we get a fossology page?\n");
904  $this->assertTrue($this->myassertText($loggedIn, '/From URL/'));
905  $page = $this->mybrowser->get("$URL?mod=upload_url");
906 
907  $this->assertTrue($this->myassertText($page, '/Upload from URL/'));
908  $this->assertTrue($this->myassertText($page, '/Enter the URL to the file/'));
909  /* only look for the the folder id if it's not the root folder */
910  $folderId = $parentFolder;
911  if ($parentFolder != 1)
912  {
913  $folderId = $this->getFolderId($parentFolder, $page, 'folder');
914  }
915  $this->assertTrue($this->mybrowser->setField('folder', $folderId));
916  $this->assertTrue($this->mybrowser->setField('geturl', $url));
917  $this->assertTrue($this->mybrowser->setField('description', "$description"));
918  /* Set the name field if an upload name was passed in. */
919  if (!(is_null($uploadName)))
920  {
921  $this->assertTrue($this->mybrowser->setField('name', $url));
922  }
923  /* selects agents using numbers 1,2,3 or names license, mime, pkgmetagetta */
924  $rtn = $this->setAgents($agents);
925  if (!is_null($rtn))
926  {
927  $this->fail("FAIL: could not set agents in uploadAFILE test\n");
928  }
929  $page = $this->mybrowser->clickSubmit('Upload!');
930  $this->assertTrue($page);
931  $this->assertTrue($this->myassertText($page, '/The upload .*? has been scheduled/'), "FAIL! did find phrase The upload .*? has been scheduled\n");
932  //print "************ page after Upload! *************\n$page\n";
933  } //uploadUrl
934 
952  public function wait4jobs()
953  {
954 
955  require_once ('testClasses/check4jobs.php');
956 
957  define("FiveMIN", "300");
958 
959  $Jq = new check4jobs();
960 
961  /* wait at most 2 hours for test jobs to finish */
962  $done = FALSE;
963  for ($i = 1; $i <= 24; $i++)
964  {
965  //print "DB:W4Q: checking Q...\n";
966  $number = $Jq->Check();
967  if ($number != 0)
968  {
969  //print "sleeping 10 min...\n";
970  sleep(FiveMIN);
971  } else
972  {
973  //print "$number jobs found in the Queue\n";
974  $done = TRUE;
975  break;
976  }
977  }
978  if ($done === FALSE)
979  {
980  print "{$argv[0]} waited for 2 hours and the jobs are still not done\n" .
981  "Please investigate\n";
982  return (FALSE);
983  }
984  if ($done === TRUE)
985  {
986  return (TRUE);
987  }
988  } // wait4jobs
989 
990  /* possible methods to add */
991  public function dbCheck()
992  {
993  return TRUE;
994  }
995 
996  public function jobsSummary()
997  {
998  return TRUE;
999  }
1000  public function jobsDetail()
1001  {
1002  return TRUE;
1003  }
1004 
1005  public function oneShotLicense()
1006  {
1007  return TRUE;
1008  }
1009  public function rmLicAnalysis()
1010  {
1011  return TRUE;
1012  }
1013 }
1014 ?>
createFolder($parent=null, $name, $description=null)
getUploadId($uploadName, $page, $selectName)
parseSelectStmnt($page, $selectName, $optionText=NULL)
editUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Block=NULL, $Blank=NULL, $Password=NULL, $EmailNotify= 'y')
fillGroupForm($groupName, $user)
uploadFile($parentFolder, $uploadFile, $description=null, $uploadName=null, $agents=null)
setUserFields($UserName=NULL, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Block=NULL, $Blank=NULL, $Password=NULL, $EmailNotify=NULL, $BucketPool=1, $Ui= 'simple')
editFolder($folder, $newName, $description=null)
uploadUrl($parentFolder=1, $url, $description=null, $uploadName=null, $agents=null)
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify= 'y')
getFolderId($folderName, $page, $selectName)
setAgents($agents=NULL)
mvFolder($folder, $destination)
moveUpload($oldFolder, $destFolder, $upload)
uploadServer($parentFolder=1, $uploadPath, $description=null, $uploadName=null, $agents=null)