FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
DupUploadTest.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
29 require_once ('../../../tests/fossologyTestCase.php');
30 require_once ('../../../tests/TestEnvironment.php');
31 
32 global $URL;
33 
35 {
36  public $mybrowser;
37 
38  function setUP()
39  {
40  global $URL;
41  $this->Login();
42  }
43 
44  function testUploadFile()
45  {
46  global $URL;
47 
48  print "starting DupUploadTest\n";
49 
50  for ($i = 0; $i < 2; $i++)
51  {
52  $loggedIn = $this->mybrowser->get($URL);
53  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'));
54  $this->assertTrue($this->myassertText($loggedIn, '/From File/'));
55 
56  $page = $this->mybrowser->clickLink('From File');
57  $this->assertTrue($this->myassertText($page, '/Upload a New File/'));
58  $this->assertTrue($this->myassertText($page, '/Select the file to upload:/'));
59  /* select Testing folder, filename based on pid */
60 
61  $id = $this->getFolderId('Basic-Testing', $page, 'folder');
62  $this->assertTrue($this->mybrowser->setField('folder', $id));
63  $this->assertTrue($this->mybrowser->setField('getfile', '/home/fosstester/licenses/Affero-v1.0'));
64  $desc = 'File Affero-v1.0 uploaded by test UploadFileTest into Testing folder';
65  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
66  $id = getmypid();
67  $upload_name = 'TestUploadFile-' . "$id";
68  $this->assertTrue($this->mybrowser->setField('name', $upload_name));
69  /* we won't select any agents this time' */
70  $page = $this->mybrowser->clickSubmit('Upload');
71  $this->assertTrue($page);
72  /* On the second try, we SHOULD see Upload added to job queue */
73  if($i == 1) {
74  $this->assertTrue($this->myassertText($page, "/The file $upload_name has been uploaded/"),
75  "FAIL! A Duplicate Upload was NOT created!\n" .
76  "The phrase, The file $upload_name has been uploaded was NOT seen\n");
77  }
78  else{
79  $this->assertFalse($this->myassertText($page, "/Upload failed/"),
80  "FAIL! Upload Failed?\nPhrase 'Upload failed found\n");
81  }
82  //print "*********** Page after upload **************\n$page\n";
83  }
84  }
85 }
86 ?>
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)