FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
DeleteFolderTest.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 
32 require_once ('../../../tests/fossologyTestCase.php');
33 require_once ('../../../tests/TestEnvironment.php');
34 
35 /* every test must use these globals, at least $URL */
36 global $URL;
37 
39 {
40  public $folder_name;
41  public $mybrowser;
42 
43  function setUp()
44  {
45  global $URL;
46 
47  //print "starting setUp DeleteFoldertest\n";
48  $this->Login();
49  /* create a folder, which get's deleted below */
50  $page = $this->mybrowser->get("$URL?mod=folder_create");
51  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
52  /* select the folder to create this folder under */
53  $FolderId = $this->getFolderId('Basic-Testing', $page, 'parentid');
54  $this->assertTrue($this->mybrowser->setField('parentid', $FolderId));
55  $this->folder_name = 'DeleteMe';
56  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
57  $desc = 'Folder created by DeleteFolderTest as subfolder of Testing';
58  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
59  $page = $this->mybrowser->clickSubmit('Create!');
60  $this->assertTrue($page);
61  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
62  "FAIL! Folder $this->folder_name Created not found\n");
63  }
64 
65  function testDeleteFolder()
66  {
67  global $URL;
68 
69  print "starting DeleteFoldertest\n";
70 
71  $loggedIn = $this->mybrowser->get($URL);
72  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
73  "FAIL! Could not find Organize menu\n");
74  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
75  $this->assertTrue($this->myassertText($loggedIn, '/Delete Folder/'));
76  /* ok, this proves the text is on the page, let's see if we can
77  * go to the page and delete a folder
78  */
79  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
80  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
81  $FolderId = $this->getFolderId('DeleteMe', $page, 'folder');
82  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
83  $page = $this->mybrowser->clickSubmit('Delete!');
84  $this->assertTrue($page);
85  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->folder_name/"),
86  "FAIL! Deletion of $this->folder_name not found\n");
87  /* go to sleep for 30 seconds to see if the folder get's deleted */
88  sleep(120);
89  $page = $this->mybrowser->get("$URL?mod=browse");
90  $this->assertFalse($this->myassertText($page, '/DeleteMe/'),
91  "NOTE: Folder DeleteMe still exists after 120 seconds");
92  //print "************ page after Folder Delete! *************\n$page\n";
93  }
94 }
95 
96 ?>
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:65