FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
editFolderNameOnlyTest.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  ***********************************************************/
30 require_once ('../../../tests/fossologyTestCase.php');
31 require_once ('../../../tests/TestEnvironment.php');
32 
33 /* every test must use these globals, at least $URL */
34 global $URL;
35 
37 {
38  public $folder_name;
39  public $mybrowser;
40  public $newname;
41 
42  function setUp()
43  {
44  global $URL;
45 
46  $this->Login();
47  /* create a folder, which is edited below */
48  $page = $this->mybrowser->get("$URL?mod=folder_create");
49  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
50  /* select the folder to create this folder under */
51  $FolderId = $this->getFolderId('Basic-Testing', $page, 'parentid');
52  $this->assertTrue($this->mybrowser->setField('parentid', $FolderId));
53  $this->folder_name = 'EditOnlyMe';
54  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
55  $desc = "Folder $this->folder_name created by EditNameOnlyTest as subfolder of Testing";
56  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
57  $page = $this->mybrowser->clickSubmit('Create!');
58  $this->assertTrue($page);
59  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
60  "FAIL! Folder $this->folder_name Created not found\n");
61  }
62 
63  function testEditNameOnlyFolder()
64  {
65  global $URL;
66 
67  print "starting EditFolderNameOnlytest\n";
68  $loggedIn = $this->mybrowser->get($URL);
69  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
70  "FAIL! Could not find Organize menu\n");
71  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
72  $this->assertTrue($this->myassertText($loggedIn, '/Edit Properties/'));
73  /* ok, this proves the text is on the page, let's see if we can
74  * go to the page and delete a folder
75  */
76  $page = $this->mybrowser->get("$URL?mod=folder_properties");
77  $this->assertTrue($this->myassertText($page, '/Edit Folder Properties/'));
78  $FolderId = $this->getFolderId($this->folder_name, $page, 'oldfolderid');
79  $this->assertTrue($FolderId);
80  $this->assertTrue($this->mybrowser->setField('oldfolderid', $FolderId));
81  /* edit the properties */
82  $pid = getmypid();
83  $this->newname = "FolderNameEditedByTest-$pid";
84  $this->assertTrue($this->mybrowser->setField('newname', "$this->newname"),
85  "FAIL! Folder rename Failed\n");
86  $page = $this->mybrowser->clickSubmit('Edit!');
87  $this->assertTrue($page);
88  $this->assertTrue($this->myassertText($page, "/Folder Properties changed/"),
89  "FAIL! Folder Properties changed not found\n");
90  /* check the browse page */
91  $page = $this->mybrowser->get("$URL?mod=browse");
92  $this->assertTrue($this->myassertText($page, "/$this->newname/"),
93  "FAIL! Folder $this->newname not found\n");
94  //print "************ page after Folder Delete! *************\n$page\n";
95  }
96  function tearDown()
97  {
98  global $URL;
99  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
100  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
101  $FolderId = $this->getFolderId($this->newname, $page, 'folder');
102  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
103  $page = $this->mybrowser->clickSubmit('Delete!');
104  $this->assertTrue($page);
105  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->newname/"),
106  "EditFolderOnlyTest tearDown FAILED! Deletion of $this->newname not found\n");
107  }
108 }
109 ?>
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:65