FOSSology  4.4.0
Open Source License Compliance by Open Source Software
DeleteFolderTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
7 
21 require_once ('../../../tests/fossologyTestCase.php');
22 require_once ('../../../tests/TestEnvironment.php');
23 
24 /* every test must use these globals, at least $URL */
25 global $URL;
26 
28 {
29  public $folder_name;
30  public $mybrowser;
31 
32  function setUp()
33  {
34  global $URL;
35 
36  //print "starting setUp DeleteFoldertest\n";
37  $this->Login();
38  /* create a folder, which get's deleted below */
39  $page = $this->mybrowser->get("$URL?mod=folder_create");
40  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
41  /* select the folder to create this folder under */
42  $FolderId = $this->getFolderId('Basic-Testing', $page, 'parentid');
43  $this->assertTrue($this->mybrowser->setField('parentid', $FolderId));
44  $this->folder_name = 'DeleteMe';
45  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
46  $desc = 'Folder created by DeleteFolderTest as subfolder of Testing';
47  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
48  $page = $this->mybrowser->clickSubmit('Create!');
49  $this->assertTrue($page);
50  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
51  "FAIL! Folder $this->folder_name Created not found\n");
52  }
53 
54  function testDeleteFolder()
55  {
56  global $URL;
57 
58  print "starting DeleteFoldertest\n";
59 
60  $loggedIn = $this->mybrowser->get($URL);
61  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
62  "FAIL! Could not find Organize menu\n");
63  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
64  $this->assertTrue($this->myassertText($loggedIn, '/Delete Folder/'));
65  /* ok, this proves the text is on the page, let's see if we can
66  * go to the page and delete a folder
67  */
68  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
69  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
70  $FolderId = $this->getFolderId('DeleteMe', $page, 'folder');
71  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
72  $page = $this->mybrowser->clickSubmit('Delete!');
73  $this->assertTrue($page);
74  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->folder_name/"),
75  "FAIL! Deletion of $this->folder_name not found\n");
76  /* go to sleep for 30 seconds to see if the folder get's deleted */
77  sleep(120);
78  $page = $this->mybrowser->get("$URL?mod=browse");
79  $this->assertFalse($this->myassertText($page, '/DeleteMe/'),
80  "NOTE: Folder DeleteMe still exists after 120 seconds");
81  //print "************ page after Folder Delete! *************\n$page\n";
82  }
83 }
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:54