FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
ckZendTest.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 
30 $where = dirname(__FILE__);
31 if(preg_match('!/home/jenkins.*?tests.*!', $where, $matches))
32 {
33  //echo "running from jenkins....fossology/tests\n";
34  require_once ('fossologyTestCase.php');
35  require_once('testClasses/parseMiniMenu.php');
36  require_once('testClasses/parseBrowseMenu.php');
37  require_once('commonTestFuncs.php');
38 
39 }
40 else
41 {
42  //echo "using requires for running outside of jenkins\n";
43  require_once ('../fossologyTestCase.php');
44  require_once('../testClasses/parseMiniMenu.php');
45  require_once('../testClasses/parseBrowseMenu.php');
46  require_once('../commonTestFuncs.php');
47 
48 }
49 
50 global $URL;
51 
53 {
54  public $mybrowser; // must have
55  public $someOtherVariable;
56  protected $host;
57 
58  /*
59  * Every Test needs to login so we use the setUp method for that.
60  * setUp is called before any other method by default.
61  *
62  */
63  function setUp()
64  {
65  global $URL;
66  $this->Login();
67  $this->host = getHost($URL);
68  }
69 
70  function testZendLic()
71  {
72  global $URL;
73 
74  print "starting testZendLic\n";
75 
76  $name = 'zend-license';
77  $page = $this->mybrowser->clickLink('Browse');
78  $this->assertTrue($this->myassertText($page, "/>View</"),
79  "ckzend FAILED! >View< not found\n");
80  $this->assertTrue($this->myassertText($page, "/>Info</"),
81  "ckzend FAILED! >Info< not found\n");
82  $this->assertTrue($this->myassertText($page, "/>Download</"),
83  "ckzend FAILED! >Download< not found\n");
84  $page = $this->mybrowser->clickLink('Testing');
85  $this->assertTrue($this->myassertText($page, '/Testing/'),
86  "ckzend FAILED! Could not find Testing folder\n");
87  $this->assertTrue($this->myassertText($page, "/$name/"),
88  "ckzend FAILED! did not find $name\n");
89 
90  /* Select archive */
91  //print "CKZDB: page before call parseBMenu:\n$page\n";
92 
93  $browse = new parseBrowseMenu($page, 'browsetbl', 1);
94  $browse->parseBrowseMenuFiles();
95  // get the View link for zend-license
96  $viewLink = $browse->browseList[$name]['View'];
97  $page = $this->mybrowser->get($viewLink);
98  $mini = new parseMiniMenu($page);
99  $miniMenu = $mini->parseMiniMenu();
100  $url = makeUrl($this->host, $miniMenu['License Browser']);
101  if($url === NULL) { $this->fail("ckzend Failed, host/url is not set"); }
102 
103  $this->assertTrue($this->myassertText($page, '/View File/'),
104  "ckzend FAILED! View File Title not found\n");
105  $page = $this->mybrowser->get($url);
106  // Check License
107  // Get the displayed result
108  $matched = preg_match("/<hr>\nThe(.*?)<div class='text'>--/", $page, $matches);
109  //print "DBCKZ: we found:\n";print_r($matches) . "\n";
110  $foundRaw = $matches[1];
111  $stripped = strip_tags($foundRaw);
112  $found = escapeDots($stripped);
113 
114  $stringToMatch = 'Nomos license detector found: Zend_v2\.0';
115  $this->assertTrue($found,"/$stringToMatch/",
116  "ckzend FAILED! Nomos license string does not match\n" .
117  "Expected: $stringToMatch\n" .
118  " Got: $found\n");
119  $this->assertTrue($this->myassertText($page, '/View License/'),
120  "ckzend FAILED! View License Title not found\n");
121  // Check One-shot Analysis
122  $urlOneShot = makeUrl($this->host, $miniMenu['One-Shot License']);
123  if($urlOneShot === NULL) { $this->fail("ckzend Failed, cannot make One-Shot url"); }
124  $page = $this->mybrowser->get($urlOneShot);
125  $this->assertTrue($this->myassertText($page, '/One-Shot License Analysis/'),
126  "ckzend FAILED! One-Shot License Analysis Title not found\n");
127  //$osLicText = '<strong>Zend_v2\.0';
128  //$this->assertTrue($this->myassertText($page, "/$osLicText/"),
129  //"ckzend FAILED! the text:\n$osLicText\n was not found\n");
130  }
131 }
132 ?>
Login($User=NULL, $Password=NULL)