FOSSology  4.4.0
Open Source License Compliance by Open Source Software
uploadWEmail.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
19 require_once ('../../../tests/fossologyTestCase.php');
20 require_once ('../../../tests/TestEnvironment.php');
21 
22 global $URL;
23 
25 
26  public $mybrowser;
27 
28  protected function setUp() {
29  $this->Login();
30  $this->CreateFolder(1, 'Enote', 'Folder for Email notification uploads');
31  }
32 
33  public function testUploadWEmail() {
34 
35  global $URL;
36 
37  print "Starting UploadWEmail test...\n";
38  /* login fosstester*/
39  //$this->Login('fosstester','fosstester');
40  $page = $this->mybrowser->get($URL);
41 
42  $File = '/home/fosstester/licenses/Apache-v1.1';
43  $Filedescription = "The Apache License Version 1.1 from the Apache site";
44 
45  $Url = 'http://www.apache.org/licenses/LICENSE-2.0';
46  $Urldescription = "The Apache License Version 2.0 from www.apache.org/licenses/LICENSE-2.0";
47 
48  $Srv = '/home/fosstester/archives/foss23D1F1L.tar.bz2';
49  $Srvdescription = "fossology test archive";
50 
51  $this->uploadFile('Enote', $File, $Filedescription, null, '1');
52  $this->uploadUrl('Enote', $Url, $Urldescription, null, '2');
53  $this->uploadServer('Enote', $Srv, $Srvdescription, null, 'all');
54  // need to get the upload id's of the files just uploaded.
55  sleep(60); // wait for 2 min for jobs to start then check they got started
56  // use fossjobs to get the upload id
57  $jobs = $this->parseFossjobs();
58 
59  /* verify, use the basename as the upload name is stored as the basename of
60  * the upload path
61  */
62  print "Verifying jobs exist\n";
63  $srvFile = basename($Srv);
64  if(array_key_exists($srvFile,$jobs)) {
65  $this->pass();
66  }
67  else {
68  $this->fail("upload $Srv not found\n");
69  }
70  $urlFile = basename($Url);
71  if(array_key_exists($urlFile,$jobs)) {
72  $this->pass();
73  }
74  else {
75  $this->fail("upload $Url not found\n");
76  }
77  /* upload from file only stores the filename */
78  $FileName = basename($File);
79  if(array_key_exists($FileName,$jobs)) {
80  $this->pass();
81  }
82  else {
83  $this->fail("upload $FileName not found\n");
84  }
85  /*
86  * uploads exist, but still, need to check email when they finish....
87  */
88  print "waiting for jobs to finish\n";
89  $this->wait4jobs();
90  print "verifying correct email was received\n";
91  if(!($this->checkEmailNotification(3))) {
92  $this->fail("checkEmailNotification failed, is local email configured?\n");
93  }
94  }
95 }
uploadServer($parentFolder, $uploadPath, $description=null, $uploadName=null, $agents=null)
uploadUrl($parentFolder, $url, $description=null, $uploadName=null, $agents=null)
uploadFile($parentFolder, $uploadFile, $description=null, $uploadName=null, $agents=null)
parseFossjobs($all=NULL)
Login($User=NULL, $Password=NULL)