FOSSology  4.4.0
Open Source License Compliance by Open Source Software
UploadFileTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
19 require_once ('../../../tests/fossologyTestCase.php');
20 require_once ('../../../tests/TestEnvironment.php');
21 
22 global $URL;
23 
25 {
26  public $mybrowser;
27 
28  function setUP()
29  {
30  global $URL;
31  $this->Login();
32  }
33 
34  function testUploadFile()
35  {
36  global $URL;
37 
38  print "starting UploadFileTest\n";
39 
40  $loggedIn = $this->mybrowser->get($URL);
41  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'));
42  $this->assertTrue($this->myassertText($loggedIn, '/From File/'));
43  $page = $this->mybrowser->get("$URL?mod=upload_file");
44  //print "*********** Page after going to upload file **************\n$page\n";
45  $this->assertTrue($this->myassertText($page, '/Upload a New File/'));
46  $this->assertTrue($this->myassertText($page, '/Select the file to upload:/'));
47  $id = $this->getFolderId('Basic-Testing', $page, 'folder');
48  $this->assertTrue($this->mybrowser->setField('folder', $id));
49  $this->assertTrue($this->mybrowser->setField('getfile', '/home/fosstester/licenses/gpl-3.0.txt' ));
50  $desc = 'File gpl-3.0.txt uploaded by test UploadFileTest into Basic-Testing folder';
51  $this->assertTrue($this->mybrowser->setField('description', "$desc" ));
52  $id = getmypid();
53  $upload_name = 'TestUploadFile-' . "$id";
54  $this->assertTrue($this->mybrowser->setField('name', $upload_name ));
55  /* we won't select any agents this time' */
56  $page = $this->mybrowser->clickSubmit('Upload');
57  //print "*********** Page after pressing Upload! **************\n$page\n";
58  $this->assertTrue($page);
59  $this->assertTrue($this->myassertText($page, '/The file .*? has been uploaded/'),
60  "FAILURE:Did not find the message 'The file .*? has been uploaded'\n");
61 
62  }
63 }
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)