FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
foss_ui.php
1 #!/usr/bin/php
2 
3 <?php
4 /***********************************************************
5  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License
9  version 2 as published by the Free Software Foundation.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc.,
18  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  ***********************************************************/
20 /*
21  * first try at testing web interface...
22  */
23 
24 class TestRepoLogin extends WebTestCase{
25 
26  function testLogin(){
27  $this->useProxy('http://web-proxy.fc.hp.com:8088', 'web-proxy', '');
28  $this->assertTrue($this->get('http://repo.fossology.org/'));
29  $this->assertAuthentication('Basic');
30  $this->authenticate('fossology', 'xxxxxxxx');
31  $this->assertText('Software Repository Viewer');
32  }
33 }
34 class TestAboutMenu extends WebTestCase {
35 
36  function testMenuAbout(){
37  $this->useProxy('http://web-proxy.fc.hp.com:8088', 'web-proxy', '');
38  $this->assertTrue($this->get('http://repo.fossology.org/'));
39  $this->assertAuthentication('Basic');
40  $this->authenticate('fossology', 'xxxxxxx');
41  $this->assertText('Software Repository');
42 
43  $this->click('About');
44  $this->assertText('FOSSology');
45  }
46 }
47 /*
48  * NOTE: the url is for the internal machines... fix this!
49  * they fail when run from home, can't seem to get a url to work on doc....
50  * They work when run from sirius.
51  */
52 class TestToolsMenu extends WebTestCase {
53 
54  function testMenuTools(){
55  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
56  //$this->assertAuthentication('Basic');
57  //$this->authenticate('fossology', 'xxxxxxx');
58  $this->assertText('Software Repository');
59 
60  $this->click('Tools');
61  $this->clicklink('Folders (refresh)', 0);
62  }
63 }
64 
65 class TestOrganizeFolders extends WebTestCase {
66 
67  function testFolderCreate(){
68  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
69  //$this->assertAuthentication('Basic');
70  //$this->authenticate('fossology', 'xxxxxxxx');
71  $this->assertText('Software Repository');
72 
73  $this->click('Organize');
74  $this->click('Folders');
75  $this->click('Create');
76  $this->assertText('Create a new');
77  $this->assertField('parentid', '1');
78  }
79  /*
80  * testFolderMove assumes that folder created in testFolderCreate above
81  * exists.
82  */
83  function testFolderMove(){
84  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
85  //$this->assertAuthentication('Basic');
86  //$this->authenticate('fossology', 'xxxxxxxx');
87  $this->assertText('Software Repository');
88 
89  $this->click('Organize');
90  $this->click('Folders');
91  $this->click('Move');
92  $this->assertText('Move Folder');
93  }
94 
95  function createfolder($name) {
96  // Web page load
97  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
98  //$this->assertAuthentication('Basic');
99  //$this->authenticate('fossology', 'xxxxxxxx');
100  $this->assertText('Software Repository');
101  // Navigate test (plugin is there)
102  $this->click('Organize');
103  $this->click('Folders');
104  $this->setField('parentid', 'Software Repository');
105  $this->setField('newname', '$name');
106  $this->setField('description', 'edit properties Test folder');
107  $this->clickSubmit('Create!');
108  }
109 
110  function testEditProperties(){
111  // Web page load
112  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
113  //$this->assertAuthentication('Basic');
114  //$this->authenticate('fossology', 'xxxxxxxx');
115  $this->assertText('Software Repository');
116  // Navigate test (plugin is there)
117  $this->click('Organize');
118  $this->click('Folders');
119  $this->click('Edit Properties');
120  $this->assertText('Edit Folder Properties');
121  // functional test name change, no description changed. (can't verify
122  // on the screen)
123  $this->setField('parentid', 'Software Repository');
124  $this->createfolder('epTfolder');
125  $this->setField('parentid', 'epTfolder');
126  $this->setField('newname', 'EditPropTest');
127  $this->clickSubmit('Edit!');
128  // functional test, don't change name, change description.
129  // Note, relys on the name change in the test case above.
130  $this->setField('parentid', 'EditPropTest');
131  $this->setField('description', 'Changed description for EditPropTest');
132  $this->clickSubmit('Edit!');
133  // This tests that the error text is shown (how do you tell if it's red?)
134  // and that the pulldown is reset to the root folder
135  // doesn't work that way! We are seeing the css sheet hmmmm
136  $this->setField('parentid', 'Software Repository');
137  $this->setField('description', 'Should see Please Select... in red');
138  $this->clickSubmit('Edit!');
139  // This doesn't work, need to investigate.
140  //$this->assertText('Please Select');
141  $this->setField('parentid', 'Software Repository');
142  }
143 
144 }
145 
146 class TestCreateFolder extends WebTestCase {
147 
148  function testFuncCreateFolder(){
149  $this->assertTrue($this->get('http://osrb-1.fc.hp.com/~markd/ui-md/'));
150  //$this->assertAuthentication('Basic');
151  //$this->authenticate('fossology', 'xxxxxxxx');
152  $this->assertText('Software Repository');
153 
154  $this->click('Organize');
155  $this->click('Folders');
156  $this->click('Create');
157  $this->assertTrue($this->setField('parentid', 'Software Repository'));
158  // Generate a random number so names will not collide with multiple
159  // test runs.
160  $tail = rand();
161  $folder_name = 'TestFolder' . "$tail";
162  $this->setField('newname', $folder_name);
163  $this->clickSubmit('Create!');
164  // Wonder why we don't have to click the OK button for the test to
165  // pass.
166  //$this->click('OK');
167  // The assertion below will try to set the pull down to the just created
168  // folder. If the folder did not get created, it will fail.
169  $this->click('Organize');
170  $this->click('Folders');
171  $this->click('Create');
172  echo "folder name:$folder_name\n";
173  $this->setField('parentid', $folder_name);
174  }
175 }
176 ?>