FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
printLicTbl.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 
28 require_once('../fossologyTestCase.php');
29 require_once('../commonTestFuncs.php');
30 require_once('../TestEnvironment.php');
31 require_once('../testClasses/parseBrowseMenu.php');
32 require_once('../testClasses/parseMiniMenu.php');
33 require_once('../testClasses/parseFolderPath.php');
34 require_once('../testClasses/dom-parseLicenseTable.php');
35 require_once('../copyright/libCopyRight.php');
36 
37 global $URL;
38 
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 3files.tar.bz2
52  */
53  global $URL;
54  global $name;
55  global $safeName;
56 
57  $name = 'RedHat.tar.gz';
58  $safeName = escapeDots($name);
59  $this->host = getHost($URL);
60  //print "SetUp: host is:$this->host\n";
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  "verifySimpletest FAILED! Could not find Browse menu\n");
68  $page = $this->mybrowser->clickLink('Testing');
69  $this->assertTrue($this->myassertText($page, "/$safeName/"),
70  "verifySimpleTest FAILED! Could not find RedHat.tar upload\n");
71  $result = $this->myassertText($page, "/$name/");
72  //if(!($result)) { echo "WTF!\n"; exit(FALSE); }
73  }
74 
75  function testLicTbl()
76  {
77  global $URL;
78  global $name;
79  global $safeName;
80 
81 
82  print "starting print lics\n";
83  $page = $this->mybrowser->clickLink('Browse');
84  $this->assertTrue($this->myassertText($page, '/Browse/'),
85  "verifySimpleTest FAILED! Could not find Browse menu\n");
86  $this->assertTrue($this->myassertText($page, "/Browse/"),
87  "verifySimpleTest FAILED! Browse Title not found\n");
88  $this->assertTrue($this->myassertText($page, "/$safeName/"),
89  "verifySimpleTest FAILED! did not find $name\n");
90  $this->assertTrue($this->myassertText($page, "/>View</"),
91  "verifySimpletest FAILED! >View< not found\n");
92  $this->assertTrue($this->myassertText($page, "/>Info</"),
93  "verifySimpletest FAILED! >Info< not found\n");
94  $this->assertTrue($this->myassertText($page, "/>Download</"),
95  "verifySimpletest FAILED! >Download< not found\n");
96 
97  /* Select archive */
98  $page = $this->mybrowser->clickLink('Testing');
99  $page = $this->mybrowser->clickLink($name);
100  //print "************ Page after select RedHat.tar *************\n$page\n";
101  $this->assertTrue($this->myassertText($page, "/1 item/"),
102  "verifySimpletest FAILED! '1 item' not found\n");
103  $this->assertTrue($this->myassertText($page, "/RedHat/"),
104  "verifySimpletest FAILED! 'RedHat' not found\n");
105  $page = $this->mybrowser->clickLink('RedHat/');
106  //print "************ Page after select RedHat Link *************\n$page\n";
107 
108  /* Select the link to get copyright info */
109  $mini = new parseMiniMenu($page);
110  $miniMenu = $mini->parseMiniMenu();
111  //print "MiniMenu is:\n";print_r($miniMenu) . "\n";
112  $url = makeUrl($this->host, $miniMenu['Nomos License']);
113  if($url === NULL) { $this->fail("RHEL Lics Failed, host/URL is not set"); }
114 
115  $page = $this->mybrowser->get($url);
116 
117  // get the 'Show' links and License color links
118  $ct = new domParseLicenseTbl($page, 'lichistogram');
119  $ct->parseLicenseTbl();
120  // empty table? Error
121  if($ct->noRows) {
122  $this->fail("Error! table with id=copyright has no rows!" .
123  " nothing to process, There should be!\n");
124  }
125  else if(empty($ct->hList)) {
126  $this->fail("Error! table with id=copyright was not found on" .
127  "the page, There should be one\n");
128  }
129  else {
130  $total = 0;
131  print "\$copyStd = array(\n";
132  foreach($ct->hList as $list)
133  {
134  $cs = cleanString($list['textOrLink']);
135  print " '$cs' => $list[count],\n";
136  $total += (int)$list['count'];
137  }
138  print ");\n";
139  }
140  }
141 }
142 ?>
Login($User=NULL, $Password=NULL)