FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
bsam-verifyFossDirsOnly.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2010 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 
27 require_once('../../../tests/fossologyTestCase.php');
28 require_once('../../../tests/commonTestFuncs.php');
29 require_once('../../../tests/TestEnvironment.php');
30 require_once('../../../tests/testClasses/parseBrowseMenu.php');
31 require_once('../../../tests/testClasses/parseMiniMenu.php');
32 require_once('../../../tests/testClasses/parseFolderPath.php');
33 require_once('../../../tests/testClasses/parseLicenseTbl.php');
34 require_once('../../../tests/testClasses/parseLicenseTblDirs.php');
35 
36 global $URL;
37 
43 {
44  public $mybrowser;
45  public $host;
46 
47  function setUp()
48  {
49  /*
50  * This test requires that the fossology test archive has been
51  * loaded under the name fossDirsOnly.tar.bz2
52  */
53  global $URL;
54  global $name;
55  global $safeName;
56 
57  print "starting verifyFossDirsOnly-SetUp\n";
58  $name = 'fossDirsOnly.tar.bz2';
59  $safeName = escapeDots($name);
60  $this->host = getHost($URL);
61  $this->Login();
62 
63  /* check for existense of archive */
64  $page = $this->mybrowser->get($URL);
65  $page = $this->mybrowser->clickLink('Browse');
66  $this->assertTrue($this->myassertText($page, '/Browse/'),
67  "verifyDirsOnly FAILED! Could not find Browse menu\n");
68  $result = $this->myassertText($page, "/$safeName/");
69  if(!($result)) {
70  $this->fail("Failure, cannot find archive $name, Stopping test\n");
71  exit(1);
72  }
73  }
74 
75  function testVerifyFossology()
76  {
77  global $URL;
78  global $name;
79  global $safeName;
80 
81  print "starting verifyFossDirsOnly test\n";
82  $page = $this->mybrowser->clickLink('Browse');
83  $this->assertTrue($this->myassertText($page, '/Browse/'),
84  "verifyFossDirsOnly FAILED! Could not find Browse menu\n");
85  //print "************ Page after upload link *************\n$page\n";
86  $this->assertTrue($this->myassertText($page, "/$safeName/"),
87  "verifyFossDirsOnly FAILED! did not find $name\n");
88  $this->assertTrue($this->myassertText($page, "/>View</"),
89  "verifyFossDirsOnly FAILED! >View< not found\n");
90  $this->assertTrue($this->myassertText($page, "/>Meta</"),
91  "verifyFossDirsOnly FAILED! >Meta< not found\n");
92  $this->assertTrue($this->myassertText($page, "/>Download</"),
93  "verifyFossDirsOnly FAILED! >Download< not found\n");
94 
95  /* Select archive */
96  $page = $this->mybrowser->clickLink($name);
97  //print "************ Page after select foss archive *************\n$page\n";
98  $this->assertTrue($this->myassertText($page, "/empty\//"),
99  "verifyFossDirsOnly FAILED! 'empty/' not found\n");
100  $this->assertTrue($this->myassertText($page, "/1 item/"),
101  "verifyFossDirsOnly FAILED! '1 item' not found\n");
102 
103  /* Select empty link */
104  $page = $this->mybrowser->clickLink('empty/');
105 
106  /* need to check that there are 9 items */
107  $this->assertTrue($this->myassertText($page, "/9 items/"),
108  "verifyFossDirsOnly FAILED! '9 items' not found\n");
109  $this->assertTrue($this->myassertText($page, "/agents/"),
110  "verifyFossDirsOnly FAILED! did not find 'agents' directory\n");
111  $this->assertTrue($this->myassertText($page, "/scheduler/"),
112  "verifyFossDirsOnly FAILED! did not find scheduler directory\n");
113 
114  /* Select the License link to View License Historgram */
115  $browse = new parseBrowseMenu($page);
116  $mini = new parseMiniMenu($page);
117  $miniMenu = $mini->parseMiniMenu();
118  $url = makeUrl($this->host, $miniMenu['License']);
119  if($url === NULL) { $this->fail("verifyFossDirsOnly Failed, host is not set"); }
120 
121  $page = $this->mybrowser->get($url);
122  //print "page after get of $url is:\n$page\n";
123  $this->assertTrue($this->myassertText($page, '/License Browser/'),
124  "verifyFossDirsOnly FAILED! License Browser Title not found\n");
125  $this->assertTrue($this->myassertText($page, '/Total licenses: 0/'),
126  "verifyFossDirsOnly FAILED! Total Licenses does not equal 0\n");
127 
128  $dList = new parseLicenseTblDirs($page);
129  $dirList = $dList->parseLicenseTblDirs();
130  //print "dirList is:\n"; print_r($dirList) . "\n";
131  /*
132  * the directiory agents has 13 subdirectories all other directories
133  * are empty. we are going to loop through them, but for now just
134  * test a few of them out....
135  */
136  $url = makeUrl($this->host, $dirList['scheduler/']);
137  $page = $this->mybrowser->get($url);
138  //print "page after scheduler is:\n$page\n";
139  $fList = new parseFolderPath($page, $url);
140  $dirCnt = $fList->countFiles();
141  // should only get one folder path)
142  $this->assertEqual((int)$dirCnt, 1,
143  "verifyFossDirsOnly FAILED! did not get 1 folder path back, got $dirCnt instead\n");
144  // every entry but the last must have a non-null value (we assume parse
145  // routine worked)
146  $fpaths = $fList->parseFolderPath();
147  $this->assertTrue($this->check4Links($fpaths),
148  "verifyFossDirsOnly FAILED! something wrong with folder path\n" .
149  "See this url:\n$url\n");
150  }
163  function check4Links($folderPath)
164  {
165  $flistSize = count($folderPath[0]);
166  foreach($folderPath as $flist)
167  {
168  $i = 0;
169  foreach($flist as $folder => $link)
170  {
171  $i++;
172  // is it the last entry?
173  if ($i == $flistSize)
174  {
175  $this->assertTrue(is_null($link),
176  "verifyFossDirsOnly FAILED! Last entry is not null\n$folder $link\n");
177  continue;
178  }
179  $this->assertFalse(is_null($link),
180  "verifyFossDirsOnly FAILED! Found a folder with no link\n$folder $link\n");
181  }
182  }
183  return(TRUE);
184  }
185 }
186 ?>
Login($User=NULL, $Password=NULL)