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