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