FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
printUrlTbl.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 
27 require_once('../fossologyTestCase.php');
28 require_once('../commonTestFuncs.php');
29 require_once('../TestEnvironment.php');
30 require_once('../testClasses/parseBrowseMenu.php');
31 require_once('../testClasses/parseMiniMenu.php');
32 require_once('../testClasses/parseFolderPath.php');
33 require_once('../testClasses/dom-parseLicenseTable.php');
34 require_once('libCopyRight.php');
35 
36 global $URL;
37 
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 = 'simpletest_1.0.1.tar.gz';
58  $safeName = escapeDots($name);
59  $this->host = getHost($URL);
60  $this->Login();
61 
62  /* check for existense of archive */
63  $page = $this->mybrowser->get($URL);
64  $page = $this->mybrowser->clickLink('Browse');
65  $this->assertTrue($this->myassertText($page, '/Browse/'),
66  "verifySimpletest FAILED! Could not find Browse menu\n");
67  $this->assertTrue($this->myassertText($page, "/$safeName/"),
68  "verifySimpleTest FAILED! Could not find simpletest_1.0.1.tar.gz upload\n");
69  $result = $this->myassertText($page, "/$name/");
70  if(!($result)) { exit(FALSE); }
71  }
72 
73  function testSimpletest()
74  {
75  global $URL;
76  global $name;
77  global $safeName;
78 
79 
80  print "starting print url's\n";
81  $page = $this->mybrowser->clickLink('Browse');
82  $this->assertTrue($this->myassertText($page, '/Browse/'),
83  "verifySimpleTest FAILED! Could not find Browse menu\n");
84  $this->assertTrue($this->myassertText($page, "/Browse/"),
85  "verifySimpleTest FAILED! Browse Title not found\n");
86  $this->assertTrue($this->myassertText($page, "/$safeName/"),
87  "verifySimpleTest FAILED! did not find $name\n");
88  $this->assertTrue($this->myassertText($page, "/>View</"),
89  "verifySimpletest FAILED! >View< not found\n");
90  $this->assertTrue($this->myassertText($page, "/>Info</"),
91  "verifySimpletest FAILED! >Info< not found\n");
92  $this->assertTrue($this->myassertText($page, "/>Download</"),
93  "verifySimpletest 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, "/simpletest\//"),
99  "verifySimpletest FAILED! 'simpletest/' not found\n");
100  $this->assertTrue($this->myassertText($page, "/1 item/"),
101  "verifySimpletest FAILED! '1 item' not found\n");
102 
103  /* Select the link to get copyright info */
104  $browse = new parseBrowseMenu($page);
105  $mini = new parseMiniMenu($page);
106  $miniMenu = $mini->parseMiniMenu();
107  $url = makeUrl($this->host, $miniMenu['Copyright/Email/URL']);
108  if($url === NULL) { $this->fail("verifySimpletest Failed, host is not set"); }
109 
110  $page = $this->mybrowser->get($url);
111 
112  // get the 'Show' links and License color links
113  $ct = new domParseLicenseTbl($page, 'copyrighturl');
114  $ct->parseLicenseTbl();
115  // empty table? Error
116  if($ct->noRows) {
117  $this->fail("Error! table with id=copyrighturl has no rows!" .
118  " nothing to process, There should be!\n");
119  }
120  else if(empty($ct->hList)) {
121  $this->fail("Error! table with id=copyrighturl was not found on" .
122  "the page, There should be one\n");
123  }
124  else {
125  $total = 0;
126  print "\$urlStd = array(\n";
127  foreach($ct->hList as $list)
128  {
129  $cs = cleanString($list['textOrLink']);
130  print "\t\t'$cs' => $list[count],\n";
131  $total += (int)$list['count'];
132  }
133  print ");\n";
134  print "Total URLs: $total\n";
135  }
136  }
137 }
138 ?>
Login($User=NULL, $Password=NULL)