FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
bsam-verifyFossI16L518.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  ***********************************************************/
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 
35 global $URL;
36 
38 {
39  public $mybrowser;
40  public $host;
41 
42  function setUp()
43  {
44  /*
45  * This test requires that the fossology test archive has been
46  * loaded under the name fossarchive-T.tar.bz2 For now, the setup
47  * will just verify the material is there?
48  */
49  global $URL;
50  global $name;
51  global $safeName;
52 
53  $name = 'fossI16L518.tar.bz2';
54  $safeName = escapeDots($name);
55  $this->host = getHost($URL);
56 
57  $this->Login();
58 
59  /* check for existense of archive */
60  $page = $this->mybrowser->get($URL);
61  $page = $this->mybrowser->clickLink('Browse');
62  $this->assertTrue($this->myassertText($page, '/Browse/'),
63  "verifyFossI16L518 FAILED! Could not find Browse menu\n");
64  $page = $this->mybrowser->clickLink('Testing');
65  $this->assertTrue($this->myassertText($page, '/Testing/'),
66  "verifyFossI16L518 FAILED! Could not find Testing folder\n");
67  $result = $this->myassertText($page, "/$safeName/");
68  if(!($result)) { exit(FALSE); }
69  }
70 
71  function testVerifyFossI16L518()
72  {
73  global $URL;
74  global $name;
75  global $safeName;
76 
77  print "starting VerifyFossI16L518 test\n";
78  $page = $this->mybrowser->clickLink('Browse');
79  $this->assertTrue($this->myassertText($page, '/Browse/'),
80  "verifyFossI16L518 FAILED! Could not find Browse menu\n");
81  /* Testing folder */
82  $page = $this->mybrowser->clickLink('Testing');
83  //print "************ Page after upload link *************\n$page\n";
84  $this->assertTrue($this->myassertText($page, "/Browse/"),
85  "verifyFossI16L518 FAILED! Browse Title not found\n");
86  $this->assertTrue($this->myassertText($page, "/$safeName/"),
87  "verifyFossI16L518 FAILED! did not find $name\n");
88  $this->assertTrue($this->myassertText($page, "/>View</"),
89  "verifyFossI16L518 FAILED! >View< not found\n");
90  $this->assertTrue($this->myassertText($page, "/>Meta</"),
91  "verifyFossI16L518 FAILED! >Meta< not found\n");
92  $this->assertTrue($this->myassertText($page, "/>Download</"),
93  "verifyFossI16L518 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, "/fossology\//"));
99 
100  /* Select fossology link */
101  $page = $this->mybrowser->clickLink('fossology/');
102 
103  /* need to check that there are 16 items */
104  /* check that all the [xxx] items add to 519 */
105 
106  $this->assertTrue($this->myassertText($page, "/Makefile/"));
107  $this->assertTrue($this->myassertText($page, "/mkcheck\.sh/"),
108  "FAIL! did not find mkcheck.sh\n");
109  $this->assertTrue($this->myassertText($page, "/>View</"),
110  "FAIL! >View< not found\n");
111  $this->assertTrue($this->myassertText($page, "/>Meta</"),
112  "FAIL! >Meta< not found\n");
113  $this->assertTrue($this->myassertText($page, "/>Download</"),
114  "FAIL! >Download< not found\n");
115 
116  /* Select the License link to View License Historgram */
117  $browse = new parseBrowseMenu($page);
118  $mini = new parseMiniMenu($page);
119  $miniMenu = $mini->parseMiniMenu();
120  print "DEBUG: miniMenu is:\n";print_r($miniMenu) . "\n";
121  $url = makeUrl($this->host, $miniMenu['License']);
122  if($url === NULL) { $this->fail("verifyFossI16L518 Failed, host is not set"); }
123 
124  $page = $this->mybrowser->get($url);
125  //print "page after get of $url is:\n$page\n";
126  $this->assertTrue($this->myassertText($page, '/License Browser/'),
127  "verifyFossI16L518 FAILED! License Browser Title not found\n");
128  $this->assertTrue($this->myassertText($page, '/Total licenses: 518/'),
129  "verifyFossI16L518 FAILED! Total Licenses does not equal 518\n");
130 
131  // get the 'Show' links and License color links
132  $licTbl = new parseLicenseTbl($page);
133  $licTable = $licTbl->parseLicenseTbl();
134 
135  /* FIX THIS Select show 'Public Domain, verify, select 'LGPL v2.1', verify */
136  $pdURL = makeUrl($this->host, $licTable['Public Domain']);
137  $lgplURL = makeUrl($this->host, $licTable['\'LGPL v2.1\'-style']);
138 
139  $page = $this->mybrowser->get($pdURL);
140  $licFileList = new parseFolderPath($page, $URL);
141  $fileCount = $licFileList->countFiles();
142  print "Checking the number of files based on Public Domain\n";
143  $this->assertEqual($fileCount, 4,
144  "verifyFossI16L518 FAILED! Should be 4 files based on Public Domain got:$fileCount\n");
145 
146  $page = $this->mybrowser->get($lgplURL);
147  $licFileList->setPage($page);
148  $flist = $licFileList->countFiles();
149  print "Checking the number of files based on LGPL v2.1-style\n";
150  $this->assertEqual($flist, 16,
151  "verifyFossI16L518 FAILED! Should be 16 files based on LGPL v2.1-style got:$flist\n");
152  }
153 }
154 ?>
Login($User=NULL, $Password=NULL)