FOSSology  4.4.0
Open Source License Compliance by Open Source Software
DupUploadTest.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 
18 require_once ('../../../tests/fossologyTestCase.php');
19 require_once ('../../../tests/TestEnvironment.php');
20 
21 global $URL;
22 
24 {
25  public $mybrowser;
26 
27  function setUP()
28  {
29  global $URL;
30  $this->Login();
31  }
32 
33  function testUploadFile()
34  {
35  global $URL;
36 
37  print "starting DupUploadTest\n";
38 
39  for ($i = 0; $i < 2; $i++)
40  {
41  $loggedIn = $this->mybrowser->get($URL);
42  $this->assertTrue($this->myassertText($loggedIn, '/Upload/'));
43  $this->assertTrue($this->myassertText($loggedIn, '/From File/'));
44 
45  $page = $this->mybrowser->clickLink('From File');
46  $this->assertTrue($this->myassertText($page, '/Upload a New File/'));
47  $this->assertTrue($this->myassertText($page, '/Select the file to upload:/'));
48  /* select Testing folder, filename based on pid */
49 
50  $id = $this->getFolderId('Basic-Testing', $page, 'folder');
51  $this->assertTrue($this->mybrowser->setField('folder', $id));
52  $this->assertTrue($this->mybrowser->setField('getfile', '/home/fosstester/licenses/Affero-v1.0'));
53  $desc = 'File Affero-v1.0 uploaded by test UploadFileTest into Testing folder';
54  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
55  $id = getmypid();
56  $upload_name = 'TestUploadFile-' . "$id";
57  $this->assertTrue($this->mybrowser->setField('name', $upload_name));
58  /* we won't select any agents this time' */
59  $page = $this->mybrowser->clickSubmit('Upload');
60  $this->assertTrue($page);
61  /* On the second try, we SHOULD see Upload added to job queue */
62  if($i == 1) {
63  $this->assertTrue($this->myassertText($page, "/The file $upload_name has been uploaded/"),
64  "FAIL! A Duplicate Upload was NOT created!\n" .
65  "The phrase, The file $upload_name has been uploaded was NOT seen\n");
66  }
67  else{
68  $this->assertFalse($this->myassertText($page, "/Upload failed/"),
69  "FAIL! Upload Failed?\nPhrase 'Upload failed found\n");
70  }
71  //print "*********** Page after upload **************\n$page\n";
72  }
73  }
74 }
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)