FOSSology  4.4.0
Open Source License Compliance by Open Source Software
moveFolderTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
17 require_once ('../../../tests/fossologyTestCase.php');
18 require_once ('../../../tests/TestEnvironment.php');
19 
20 global $URL;
21 
23 {
24  public $folder2Move;
25  public $moveFolder;
26  public $mybrowser;
27 
28  function setUp()
29  {
30  global $URL;
31 
32  print "starting setUp Foldertest\n";
33  $this->Login();
34  /*
35  * Create the MoveTest folder as a subfolder of the Testing folder
36  * first go to the move page so the folder id's can be found.
37  */
38  $this->mybrowser->get($URL);
39  $page = $this->mybrowser->clickLink('Move');
40  $FolderId = $this->getFolderId('Basic-Testing', $page, 'oldfolderid');
41  if(empty($FolderId))
42  {
43  $this->fail("MoveFolderTest will fail, no Testing folder to use.\n Please correct and rerun\n");
44  }
45  $pid = getmypid();
46  $this->moveFolder = "MoveTest-$pid";
47  $this->createFolder('Basic-Testing', $this->moveFolder);
48 
49  /* create a folder, which get's moved below */
50  $pid = getmypid();
51  $this->folder2Move = "MoveMe-$pid";
52  $this->createFolder('Basic-Testing', $this->folder2Move);
53 
54  }
62  function testMoveFolder()
63  {
64  global $URL;
65 
66  print "starting MoveFoldertest\n";
67  $loggedIn = $this->mybrowser->get($URL);
68  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
69  "FAIL! Could not find Organize menu\n");
70  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
71  $this->assertTrue($this->myassertText($loggedIn, '/Move/'));
72  $this->mvFolder($this->folder2Move, $this->moveFolder);
73  /* best we can do with simpletest is to see if the folder is still there.
74  * This is a place where selenium may be useful.
75  */
76  $page = $this->mybrowser->clickLink('Browse');
77  $this->assertTrue($this->myassertText($page, "/$this->folder2Move/"),
78  "MoveFolderTest FAILED! Folder $this->folder2Move no longer exists!\n");
79  //print "************ page after Move! *************\n$page\n";
80  }
81 
82  /* remove the test folders created above Only need to remove the top
83  * move folder, that should remove any subfolders in it.
84  */
85  function tearDown()
86  {
87 
88  global $URL;
89 
90  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
91  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
92  $FolderId = $this->getFolderId($this->moveFolder, $page, 'folder');
93  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
94  $page = $this->mybrowser->clickSubmit('Delete!');
95  $this->assertTrue($page);
96  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->moveFolder/"),
97  "MoveFoldeTest tearDown FAILED! Phrase 'Deletion of $this->moveFolder' not found\n");
98  }
99 }
mvFolder($folder, $destination)
createFolder($parent, $name, $description=null)
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)