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