FOSSology  4.4.0
Open Source License Compliance by Open Source Software
printUrlTbl.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 
16 require_once('../fossologyTestCase.php');
17 require_once('../commonTestFuncs.php');
18 require_once('../TestEnvironment.php');
19 require_once('../testClasses/parseBrowseMenu.php');
20 require_once('../testClasses/parseMiniMenu.php');
21 require_once('../testClasses/parseFolderPath.php');
22 require_once('../testClasses/dom-parseLicenseTable.php');
23 require_once('libCopyRight.php');
24 
25 global $URL;
26 
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 = 'simpletest_1.0.1.tar.gz';
47  $safeName = escapeDots($name);
48  $this->host = getHost($URL);
49  $this->Login();
50 
51  /* check for existense of archive */
52  $page = $this->mybrowser->get($URL);
53  $page = $this->mybrowser->clickLink('Browse');
54  $this->assertTrue($this->myassertText($page, '/Browse/'),
55  "verifySimpletest FAILED! Could not find Browse menu\n");
56  $this->assertTrue($this->myassertText($page, "/$safeName/"),
57  "verifySimpleTest FAILED! Could not find simpletest_1.0.1.tar.gz upload\n");
58  $result = $this->myassertText($page, "/$name/");
59  if(!($result)) { exit(FALSE); }
60  }
61 
62  function testSimpletest()
63  {
64  global $URL;
65  global $name;
66  global $safeName;
67 
68 
69  print "starting print url's\n";
70  $page = $this->mybrowser->clickLink('Browse');
71  $this->assertTrue($this->myassertText($page, '/Browse/'),
72  "verifySimpleTest FAILED! Could not find Browse menu\n");
73  $this->assertTrue($this->myassertText($page, "/Browse/"),
74  "verifySimpleTest FAILED! Browse Title not found\n");
75  $this->assertTrue($this->myassertText($page, "/$safeName/"),
76  "verifySimpleTest FAILED! did not find $name\n");
77  $this->assertTrue($this->myassertText($page, "/>View</"),
78  "verifySimpletest FAILED! >View< not found\n");
79  $this->assertTrue($this->myassertText($page, "/>Info</"),
80  "verifySimpletest FAILED! >Info< not found\n");
81  $this->assertTrue($this->myassertText($page, "/>Download</"),
82  "verifySimpletest 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, "/simpletest\//"),
88  "verifySimpletest FAILED! 'simpletest/' not found\n");
89  $this->assertTrue($this->myassertText($page, "/1 item/"),
90  "verifySimpletest FAILED! '1 item' not found\n");
91 
92  /* Select the link to get copyright info */
93  $browse = new parseBrowseMenu($page);
94  $mini = new parseMiniMenu($page);
95  $miniMenu = $mini->parseMiniMenu();
96  $url = makeUrl($this->host, $miniMenu['Copyright/Email/URL']);
97  if($url === NULL) { $this->fail("verifySimpletest Failed, host is not set"); }
98 
99  $page = $this->mybrowser->get($url);
100 
101  // get the 'Show' links and License color links
102  $ct = new domParseLicenseTbl($page, 'copyrighturl');
103  $ct->parseLicenseTbl();
104  // empty table? Error
105  if($ct->noRows) {
106  $this->fail("Error! table with id=copyrighturl has no rows!" .
107  " nothing to process, There should be!\n");
108  }
109  else if(empty($ct->hList)) {
110  $this->fail("Error! table with id=copyrighturl was not found on" .
111  "the page, There should be one\n");
112  }
113  else {
114  $total = 0;
115  print "\$urlStd = array(\n";
116  foreach($ct->hList as $list)
117  {
118  $cs = cleanString($list['textOrLink']);
119  print "\t\t'$cs' => $list[count],\n";
120  $total += (int)$list['count'];
121  }
122  print ");\n";
123  print "Total URLs: $total\n";
124  }
125  }
126 }
Login($User=NULL, $Password=NULL)