FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
bsam-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/parseBrowseMenu.php');
31 require_once('../../../tests/testClasses/parseMiniMenu.php');
32 require_once('../../../tests/testClasses/parseFolderPath.php');
33 require_once('../../../tests/testClasses/parseLicenseTbl.php');
34 
35 global $URL;
36 
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 foss23D1F1L.tar.bz2
52  */
53  global $URL;
54  global $name;
55  global $safeName;
56 
57  $name = 'foss23D1F1L.tar.bz2';
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  "verify23D1F1L FAILED! Could not find Browse menu\n");
67  $page = $this->mybrowser->clickLink('Testing');
68  $this->assertTrue($this->myassertText($page, '/Testing/'),
69  "verify23D1F1L FAILED! Could not find Testing folder\n");
70  $result = $this->myassertText($page, "/$name/");
71  if(!($result)) { exit(FALSE); }
72  }
73 
74  function testVerifyFossology()
75  {
76  global $URL;
77  global $name;
78  global $safeName;
79 
80  print "starting VerifyFoss23D1F1L test\n";
81  $page = $this->mybrowser->clickLink('Browse');
82  $this->assertTrue($this->myassertText($page, '/Browse/'),
83  "verify23D1F1L FAILED! Could not find Browse menu\n");
84  $page = $this->mybrowser->clickLink('Testing');
85  //print "************ Page after upload link *************\n$page\n";
86  $this->assertTrue($this->myassertText($page, "/Browse/"),
87  "verify23D1F1L FAILED! Browse Title not found\n");
88  $this->assertTrue($this->myassertText($page, "/$safeName/"),
89  "verify23D1F1L FAILED! did not find $name\n");
90  $this->assertTrue($this->myassertText($page, "/>View</"),
91  "verifyfoss23D1F1L FAILED! >View< not found\n");
92  $this->assertTrue($this->myassertText($page, "/>Meta</"),
93  "verifyFoss23D1F1L FAILED! >Meta< not found\n");
94  $this->assertTrue($this->myassertText($page, "/>Download</"),
95  "verifyFoss23D1F1L FAILED! >Download< not found\n");
96 
97  /* Select archive */
98  $page = $this->mybrowser->clickLink($name);
99  //print "************ Page after select foss archive *************\n$page\n";
100  $this->assertTrue($this->myassertText($page, "/foss23Dirs1File1Lic\//"),
101  "verifyfoss23D1F1L FAILED! 'foss23Dirs1File1Lic/' not found\n");
102  $this->assertTrue($this->myassertText($page, "/1 item/"),
103  "verifyfoss23D1F1L FAILED! '1 item' not found\n");
104 
105  /* Select fossology link */
106  $page = $this->mybrowser->clickLink('foss23Dirs1File1Lic/');
107 
108  /* need to check that there are 9 items */
109  $this->assertTrue($this->myassertText($page, "/9 items/"),
110  "verifyfoss23D1F1L FAILED! '9 items' not found\n");
111  $this->assertTrue($this->myassertText($page, "/agents/"),
112  "verify23D1F1L FAILED! did not find 'agents' directory\n");
113  $this->assertTrue($this->myassertText($page, "/scheduler/"),
114  "verify23D1F1L FAILED! did not find scheduler directory\n");
115 
116  /* Select the License link to View License Historgram */
117  $browse = new parseBrowseMenu($page);
118  $mini = new parseMiniMenu($page);
119  $miniMenu = $mini->parseMiniMenu();
120  $url = makeUrl($this->host, $miniMenu['License']);
121  if($url === NULL) { $this->fail("verify23D1F1L Failed, host is not set"); }
122 
123  $page = $this->mybrowser->get($url);
124  //print "page after get of $url is:\n$page\n";
125  $this->assertTrue($this->myassertText($page, '/License Browser/'),
126  "verify23D1F1L FAILED! License Browser Title not found\n");
127  $this->assertTrue($this->myassertText($page, '/Total licenses: 2/'),
128  "verify23D1F1L FAILED! Total Licenses does not equal 2\n");
129 
130  // get the 'Show' links and License color links
131  $licTbl = new parseLicenseTbl($page);
132  $licTable = $licTbl->parseLicenseTbl();
133  //print "DB: licTable is:\n"; print_r($licTable) . "\n";
134 
135  /* Select show 'GPL v2-stype', verify */
136  $gplv2URL = makeUrl($this->host, $licTable['\'GPL v2\'-style']);
137  $page = $this->mybrowser->get($gplv2URL);
138  $licFileList = new parseFolderPath($page, $URL);
139  $tblList = $licFileList->parseFolderPath();
140  $tableCnt = count($tblList);
141  print "Checking the number of files based on 'GPL v2'-style\n";
142  $this->assertEqual($tableCnt, 1);
143  }
144 }
145 ?>
Login($User=NULL, $Password=NULL)