FOSSology  4.4.0
Open Source License Compliance by Open Source Software
browseUploadedTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
16 require_once ('../../../tests/fossologyTestCase.php');
17 require_once ('../../../tests/TestEnvironment.php');
18 
19 global $URL;
20 
22 {
23  public $mybrowser;
24  public $host;
25 
26  function setUp()
27  {
28  /*
29  * This test needs to have file(s) uploaded to browse. The issue is
30  * that uploads can take an indeterminate amount of time. These
31  * jobs should be started before the tests are run? This is an
32  * ongoing issue for testing this product.
33  *
34  * For now, the setup will just verify the material is there?
35  */
36  global $URL;
37 
38  $this->Login();
39  }
40 
41  function testBrowseUploaded()
42  {
43  global $URL;
44 
45  print "starting BrowseUploadedtest\n";
46  $page = $this->mybrowser->get("$URL?mod=browse");
47  $this->assertTrue($this->myassertText($page, '/Browse/'),
48  "BrowseUploadedTest FAILED! Could not find Browse menu\n");
49  $this->assertTrue($this->myassertText($page, "/Browse/"),
50  "BrowseUploadedTest FAILED! Browse Title not found\n");
51  $this->assertTrue($this->myassertText($page, "|simpletest_1\.0\.1\.tar\.gz|"),
52  "BrowseUploadedTest FAILED did not find string simpletest_1.0.1.tar.gz\n");
53  $this->assertTrue($this->myassertText($page, "/>View</"),
54  "BrowseUploadedTest FAILED! Do not see >View< link\n");
55  $this->assertTrue($this->myassertText($page, "/>Info</"),
56  "BrowseUploadedTest FAILED!FAIL!Do not see >Info< not found\n");
57  $this->assertTrue($this->myassertText($page, "/>Download</"),
58  "BrowseUploadedTest FAILED!FAIL! Do not see >Download< not found\n");
59 
60  /* Select 'simpletest_1.0.1.tar.gz' */
61  $page = $this->mybrowser->clickLink('simpletest_1.0.1.tar.gz');
62  //print "*** Page after click simpletest_1.0.1.tar.gz\n$page\n";
63  $this->assertTrue($this->myassertText($page, "/simpletest\//"),
64  "BrowseUploadedTest FAILED! simpletest link not found\n)");
65  /*
66  * TODO: these asserts are bogus, they pass, when those strings are
67  * NOT on the page! wait, sirius, is way messed up....
68  */
69  $this->assertFalse($this->myassertText($page, "/>View</"),
70  "BrowseUploadedTest FAILED! Do not see >View< link\n");
71  $this->assertFalse($this->myassertText($page, "/>Info</"),
72  "BrowseUploadedTest FAILED! Do not see >Info< link\n");
73  $this->assertFalse($this->myassertText($page, "/>Download</"),
74  "BrowseUploadedTest FAILED! Do not see >Download< link\n");
75 
76  /* Select simpltest link */
77 
78  $page = $this->mybrowser->clickLink('simpletest');
79  print "*** Page after click simpletest\n$page\n";
80  $this->assertTrue($this->myassertText($page, "/HELP_MY_TESTS_DONT_WORK_ANYMORE/"));
81  $this->assertTrue($this->myassertText($page, "/$name/"),
82  "BrowseUploadedTest FAILED! did not find simpletest_1.0.1.tar.gz\n");
83  $this->assertTrue($this->myassertText($page, "/>View</"),
84  "BrowseUploadedTest FAILED! Do not see >View< link\n");
85  $this->assertTrue($this->myassertText($page, "/>Info</"),
86  "BrowseUploadedTest FAILED! Do not see >Info< link\n");
87  $this->assertTrue($this->myassertText($page, "/>Download</"),
88  "BrowseUploadedTest FAILED! Do not see >Download< link\n");
89 
90  /* Select the License link to View License Historgram */
91  $page = $this->mybrowser->clickLink('License');
92  $this->assertTrue($this->myassertText($page, '/License Browser/'),
93  "BrowseUploadedTest FAILED!FAIL! License Browser not found\n");
94  $this->assertTrue($this->myassertText($page, '/Total licenses: 3/'),
95  "BrowseUploadedTest FAILED!FAIL! Total Licenses does not equal 3\n");
96  //print "************ Should be a License Browser page *************\n$page\n";
97  /* Select Show in the table */
98  $showLink = $this->mybrowser->clickLink('Show');
99  /* view the license */
100  $licLink = $this->mybrowser->clickLink('LICENSE');
101  $viewLink = $this->makeUrl($this->host, $licLink);
102  $page = $this->mybrowser->get($viewLink);
103  $this->assertTrue($this->myassertText($page, '/View License/'),
104  "BrowseUploadedTest FAILED!FAIL! View License not found\n");
105  $licenseResult = $this->mybrowser->getContentAsText($viewLink);
106  $this->assertTrue($this->myassertText($licenseResult, '/100% view LGPL v2\.1/'),
107  "BrowseUploadedTest FAILED!FAIL! Did not find '100% view LGPL v2.1'\n In the License Table for simpletest\n");
108 
109  //print "************ page after Browse $nlink *************\n$page\n";
110  }
111 }
Login($User=NULL, $Password=NULL)