FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
UploadFileTest.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 
30 require_once ('../../../tests/fossologyTestCase.php');
31 require_once ('../../../tests/TestEnvironment.php');
32 
33 global $URL;
34 
36 {
37  public $mybrowser;
38 
39  function setUP()
40  {
41  global $URL;
42  $this->Login();
43  }
44 
45  function testUploadFile()
46  {
47  global $URL;
48 
49  print "starting UploadFileTest\n";
50 
51  $loggedIn = $this->mybrowser->get($URL);
52  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'));
53  $this->assertTrue($this->myassertText($loggedIn, '/From File/'));
54  $page = $this->mybrowser->get("$URL?mod=upload_file");
55  //print "*********** Page after going to upload file **************\n$page\n";
56  $this->assertTrue($this->myassertText($page, '/Upload a New File/'));
57  $this->assertTrue($this->myassertText($page, '/Select the file to upload:/'));
58  $id = $this->getFolderId('Basic-Testing', $page, 'folder');
59  $this->assertTrue($this->mybrowser->setField('folder', $id));
60  $this->assertTrue($this->mybrowser->setField('getfile', '/home/fosstester/licenses/gpl-3.0.txt' ));
61  $desc = 'File gpl-3.0.txt uploaded by test UploadFileTest into Basic-Testing folder';
62  $this->assertTrue($this->mybrowser->setField('description', "$desc" ));
63  $id = getmypid();
64  $upload_name = 'TestUploadFile-' . "$id";
65  $this->assertTrue($this->mybrowser->setField('name', $upload_name ));
66  /* we won't select any agents this time' */
67  $page = $this->mybrowser->clickSubmit('Upload');
68  //print "*********** Page after pressing Upload! **************\n$page\n";
69  $this->assertTrue($page);
70  $this->assertTrue($this->myassertText($page, '/The file .*? has been uploaded/'),
71  "FAILURE:Did not find the message 'The file .*? has been uploaded'\n");
72 
73  }
74 }
75 
76 ?>
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)