FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
verifyFoss23D1F1L.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2008 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('../../../tests/fossologyTestCase.php');
28 require_once('../../../tests/commonTestFuncs.php');
29 require_once('../../../tests/TestEnvironment.php');
30 require_once('../../../tests/testClasses/parseMiniMenu.php');
31 require_once('../../../tests/testClasses/parseFolderPath.php');
32 require_once('../../../tests/testClasses/dom-parseLicenseTable.php');
33 
34 global $URL;
35 
41 class verify23D1F1L extends fossologyTestCase
42 {
43  public $mybrowser;
44  public $host;
45 
46  function setUp()
47  {
48  /*
49  * This test requires that the fossology test archive has been
50  * loaded under the name foss23D1F1L.tar.bz2
51  */
52  global $URL;
53  global $name;
54  global $safeName;
55 
56  $name = 'foss23D1F1L.tar.bz2';
57  $safeName = escapeDots($name);
58  $this->host = getHost($URL);
59  $this->Login();
60 
61  /* check for existense of archive */
62  $page = $this->mybrowser->get($URL);
63  $page = $this->mybrowser->clickLink('Browse');
64  $this->assertTrue($this->myassertText($page, '/Browse/'),
65  "verify23D1F1L FAILED! Could not find Browse menu\n");
66  $page = $this->mybrowser->clickLink('Testing');
67  $this->assertTrue($this->myassertText($page, '/Testing/'),
68  "verify23D1F1L FAILED! Could not find Testing folder\n");
69  $result = $this->myassertText($page, "/$name/");
70  if(!($result)) { exit(FALSE); }
71  }
72 
73  function testVerifyFossology()
74  {
75  global $URL;
76  global $name;
77  global $safeName;
78 
79  $licenseSummary = array(
80  'Unique licenses' => 1,
81  'Licenses found' => 1,
82  'Files with no licenses' => 0,
83  'Files' => 1
84  );
85 
86  print "starting VerifyFoss23D1F1L test\n";
87  $page = $this->mybrowser->clickLink('Browse');
88  $this->assertTrue($this->myassertText($page, '/Browse/'),
89  "verify23D1F1L FAILED! Could not find Browse menu\n");
90  $page = $this->mybrowser->clickLink('Testing');
91  //print "************ Page after upload link *************\n$page\n";
92  $this->assertTrue($this->myassertText($page, "/Browse/"),
93  "verify23D1F1L FAILED! Browse Title not found\n");
94  $this->assertTrue($this->myassertText($page, "/$safeName/"),
95  "verify23D1F1L FAILED! did not find $name\n");
96  $this->assertTrue($this->myassertText($page, "/>View</"),
97  "verifyfoss23D1F1L FAILED! >View< not found\n");
98  $this->assertTrue($this->myassertText($page, "/>Info</"),
99  "verifyFoss23D1F1L FAILED! >Info< not found\n");
100  $this->assertTrue($this->myassertText($page, "/>Download</"),
101  "verifyFoss23D1F1L FAILED! >Download< not found\n");
102 
103  /* Select archive */
104  $page = $this->mybrowser->clickLink($name);
105  //print "************ Page after select foss archive *************\n$page\n";
106  $this->assertTrue($this->myassertText($page, "/foss23Dirs1File1Lic\//"),
107  "verifyfoss23D1F1L FAILED! 'foss23Dirs1File1Lic/' not found\n");
108  $this->assertTrue($this->myassertText($page, "/1 item/"),
109  "verifyfoss23D1F1L FAILED! '1 item' not found\n");
110 
111  /* Select fossology link */
112  $page = $this->mybrowser->clickLink('foss23Dirs1File1Lic/');
113 
114  /* need to check that there are 9 items */
115  $this->assertTrue($this->myassertText($page, "/9 items/"),
116  "verifyfoss23D1F1L FAILED! '9 items' not found\n");
117  $this->assertTrue($this->myassertText($page, "/agents/"),
118  "verify23D1F1L FAILED! did not find 'agents' directory\n");
119  $this->assertTrue($this->myassertText($page, "/scheduler/"),
120  "verify23D1F1L FAILED! did not find scheduler directory\n");
121 
122  /* Select the License link to View License Historgram */
123  $mini = new parseMiniMenu($page);
124  $miniMenu = $mini->parseMiniMenu();
125  $url = makeUrl($this->host, $miniMenu['Nomos License']);
126  if($url === NULL) { $this->fail("verify23D1F1L Failed, host is not set"); }
127 
128  $page = $this->mybrowser->get($url);
129  //print "page after get of $url is:\n$page\n";
130  $this->assertTrue($this->myassertText($page, '/Nomos License Browser/'),
131  "verify23D1F1L FAILED! License Browser Title not found\n");
132 
133  // verify license summaries
134  $licSummary = new domParseLicenseTbl($page, 'licsummary', 0);
135  $licSummary->parseLicenseTbl();
136 
137  foreach ($licSummary->hList as $summary) {
138  $key = $summary['textOrLink'];
139  $this->assertEqual($licenseSummary[$key], $summary['count'],
140  "verifyFossDirsOnly FAILED! $key does not equal $licenseSummary[$key],
141  got $summary[count]\n");
142  //print "summary is:\n";print_r($summary) . "\n";
143  }
144 
145  // get the 'Show' links and License color links
146  $licHisto = new domParseLicenseTbl($page, 'lichistogram');
147  $licHisto->parseLicenseTbl();
148  if(empty($licHisto->hList)) {
149  $this->fail("FATAL! table with id=lichistogram was not found on
150  the page, nothing to process, stopping test\n");
151  exit(1);
152  }
153  /* Select show 'GPL_v2', verify */
154  $gplv2URL = makeUrl($this->host, $licHisto->hList[1]['showLink']);
155  $page = $this->mybrowser->get($gplv2URL);
156  $licFileList = new parseFolderPath($page, $URL);
157  $tblList = $licFileList->parseFolderPath();
158  $fileCnt = count($tblList);
159  print "Checking the number of files based on 'GPL_v2'\n";
160  $this->assertTrue($fileCnt == 1,
161  "FAILURE! Should only have 1 file with a GPL_v2 license: " .
162  "Testing/foss23D1F1L.bz2/foss23Dirs1File1Lic/cli/cp2foss.php, " .
163  "got:$fileCnt\n");
164  }
165 }
166 ?>
Login($User=NULL, $Password=NULL)