FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
moveFolderTest.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  ***********************************************************/
28 require_once ('../../../tests/fossologyTestCase.php');
29 require_once ('../../../tests/TestEnvironment.php');
30 
31 global $URL;
32 
34 {
35  public $folder2Move;
36  public $moveFolder;
37  public $mybrowser;
38 
39  function setUp()
40  {
41  global $URL;
42 
43  print "starting setUp Foldertest\n";
44  $this->Login();
45  /*
46  * Create the MoveTest folder as a subfolder of the Testing folder
47  * first go to the move page so the folder id's can be found.
48  */
49  $this->mybrowser->get($URL);
50  $page = $this->mybrowser->clickLink('Move');
51  $FolderId = $this->getFolderId('Basic-Testing', $page, 'oldfolderid');
52  if(empty($FolderId))
53  {
54  $this->fail("MoveFolderTest will fail, no Testing folder to use.\n Please correct and rerun\n");
55  }
56  $pid = getmypid();
57  $this->moveFolder = "MoveTest-$pid";
58  $this->createFolder('Basic-Testing', $this->moveFolder);
59 
60  /* create a folder, which get's moved below */
61  $pid = getmypid();
62  $this->folder2Move = "MoveMe-$pid";
63  $this->createFolder('Basic-Testing', $this->folder2Move);
64 
65  }
73  function testMoveFolder()
74  {
75  global $URL;
76 
77  print "starting MoveFoldertest\n";
78  $loggedIn = $this->mybrowser->get($URL);
79  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
80  "FAIL! Could not find Organize menu\n");
81  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
82  $this->assertTrue($this->myassertText($loggedIn, '/Move/'));
83  $this->mvFolder($this->folder2Move, $this->moveFolder);
84  /* best we can do with simpletest is to see if the folder is still there.
85  * This is a place where selenium may be useful.
86  */
87  $page = $this->mybrowser->clickLink('Browse');
88  $this->assertTrue($this->myassertText($page, "/$this->folder2Move/"),
89  "MoveFolderTest FAILED! Folder $this->folder2Move no longer exists!\n");
90  //print "************ page after Move! *************\n$page\n";
91  }
92 
93  /* remove the test folders created above Only need to remove the top
94  * move folder, that should remove any subfolders in it.
95  */
96  function tearDown()
97  {
98 
99  global $URL;
100 
101  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
102  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
103  $FolderId = $this->getFolderId($this->moveFolder, $page, 'folder');
104  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
105  $page = $this->mybrowser->clickSubmit('Delete!');
106  $this->assertTrue($page);
107  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->moveFolder/"),
108  "MoveFoldeTest tearDown FAILED! Phrase 'Deletion of $this->moveFolder' not found\n");
109  }
110 }
111 ?>
createFolder($parent=null, $name, $description=null)
getFolderId($folderName, $page, $selectName)
mvFolder($folder, $destination)
Login($User=NULL, $Password=NULL)