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