FOSSology  4.4.0
Open Source License Compliance by Open Source Software
printLicTbl.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2010 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
17 require_once('../fossologyTestCase.php');
18 require_once('../commonTestFuncs.php');
19 require_once('../TestEnvironment.php');
20 require_once('../testClasses/parseBrowseMenu.php');
21 require_once('../testClasses/parseMiniMenu.php');
22 require_once('../testClasses/parseFolderPath.php');
23 require_once('../testClasses/dom-parseLicenseTable.php');
24 require_once('../copyright/libCopyRight.php');
25 
26 global $URL;
27 
32 {
33  public $mybrowser;
34  public $host;
35 
36  function setUp()
37  {
38  /*
39  * This test requires that the fossology test archive has been
40  * loaded under the name 3files.tar.bz2
41  */
42  global $URL;
43  global $name;
44  global $safeName;
45 
46  $name = 'RedHat.tar.gz';
47  $safeName = escapeDots($name);
48  $this->host = getHost($URL);
49  //print "SetUp: host is:$this->host\n";
50  $this->Login();
51 
52  /* check for existense of archive */
53  $page = $this->mybrowser->get($URL);
54  $page = $this->mybrowser->clickLink('Browse');
55  $this->assertTrue($this->myassertText($page, '/Browse/'),
56  "verifySimpletest FAILED! Could not find Browse menu\n");
57  $page = $this->mybrowser->clickLink('Testing');
58  $this->assertTrue($this->myassertText($page, "/$safeName/"),
59  "verifySimpleTest FAILED! Could not find RedHat.tar upload\n");
60  $result = $this->myassertText($page, "/$name/");
61  //if(!($result)) { echo "WTF!\n"; exit(FALSE); }
62  }
63 
64  function testLicTbl()
65  {
66  global $URL;
67  global $name;
68  global $safeName;
69 
70 
71  print "starting print lics\n";
72  $page = $this->mybrowser->clickLink('Browse');
73  $this->assertTrue($this->myassertText($page, '/Browse/'),
74  "verifySimpleTest FAILED! Could not find Browse menu\n");
75  $this->assertTrue($this->myassertText($page, "/Browse/"),
76  "verifySimpleTest FAILED! Browse Title not found\n");
77  $this->assertTrue($this->myassertText($page, "/$safeName/"),
78  "verifySimpleTest FAILED! did not find $name\n");
79  $this->assertTrue($this->myassertText($page, "/>View</"),
80  "verifySimpletest FAILED! >View< not found\n");
81  $this->assertTrue($this->myassertText($page, "/>Info</"),
82  "verifySimpletest FAILED! >Info< not found\n");
83  $this->assertTrue($this->myassertText($page, "/>Download</"),
84  "verifySimpletest FAILED! >Download< not found\n");
85 
86  /* Select archive */
87  $page = $this->mybrowser->clickLink('Testing');
88  $page = $this->mybrowser->clickLink($name);
89  //print "************ Page after select RedHat.tar *************\n$page\n";
90  $this->assertTrue($this->myassertText($page, "/1 item/"),
91  "verifySimpletest FAILED! '1 item' not found\n");
92  $this->assertTrue($this->myassertText($page, "/RedHat/"),
93  "verifySimpletest FAILED! 'RedHat' not found\n");
94  $page = $this->mybrowser->clickLink('RedHat/');
95  //print "************ Page after select RedHat Link *************\n$page\n";
96 
97  /* Select the link to get copyright info */
98  $mini = new parseMiniMenu($page);
99  $miniMenu = $mini->parseMiniMenu();
100  //print "MiniMenu is:\n";print_r($miniMenu) . "\n";
101  $url = makeUrl($this->host, $miniMenu['Nomos License']);
102  if($url === NULL) { $this->fail("RHEL Lics Failed, host/URL is not set"); }
103 
104  $page = $this->mybrowser->get($url);
105 
106  // get the 'Show' links and License color links
107  $ct = new domParseLicenseTbl($page, 'lichistogram');
108  $ct->parseLicenseTbl();
109  // empty table? Error
110  if($ct->noRows) {
111  $this->fail("Error! table with id=copyright has no rows!" .
112  " nothing to process, There should be!\n");
113  }
114  else if(empty($ct->hList)) {
115  $this->fail("Error! table with id=copyright was not found on" .
116  "the page, There should be one\n");
117  }
118  else {
119  $total = 0;
120  print "\$copyStd = array(\n";
121  foreach($ct->hList as $list)
122  {
123  $cs = cleanString($list['textOrLink']);
124  print " '$cs' => $list[count],\n";
125  $total += (int)$list['count'];
126  }
127  print ");\n";
128  }
129  }
130 }
Login($User=NULL, $Password=NULL)