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