FOSSology  4.4.0
Open Source License Compliance by Open Source Software
editFolderNameOnlyTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
19 require_once ('../../../tests/fossologyTestCase.php');
20 require_once ('../../../tests/TestEnvironment.php');
21 
22 /* every test must use these globals, at least $URL */
23 global $URL;
24 
26 {
27  public $folder_name;
28  public $mybrowser;
29  public $newname;
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  $this->folder_name = 'EditOnlyMe';
43  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
44  $desc = "Folder $this->folder_name created by EditNameOnlyTest as subfolder of Testing";
45  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
46  $page = $this->mybrowser->clickSubmit('Create!');
47  $this->assertTrue($page);
48  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
49  "FAIL! Folder $this->folder_name Created not found\n");
50  }
51 
52  function testEditNameOnlyFolder()
53  {
54  global $URL;
55 
56  print "starting EditFolderNameOnlytest\n";
57  $loggedIn = $this->mybrowser->get($URL);
58  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
59  "FAIL! Could not find Organize menu\n");
60  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
61  $this->assertTrue($this->myassertText($loggedIn, '/Edit Properties/'));
62  /* ok, this proves the text is on the page, let's see if we can
63  * go to the page and delete a folder
64  */
65  $page = $this->mybrowser->get("$URL?mod=folder_properties");
66  $this->assertTrue($this->myassertText($page, '/Edit Folder Properties/'));
67  $FolderId = $this->getFolderId($this->folder_name, $page, 'oldfolderid');
68  $this->assertTrue($FolderId);
69  $this->assertTrue($this->mybrowser->setField('oldfolderid', $FolderId));
70  /* edit the properties */
71  $pid = getmypid();
72  $this->newname = "FolderNameEditedByTest-$pid";
73  $this->assertTrue($this->mybrowser->setField('newname', "$this->newname"),
74  "FAIL! Folder rename Failed\n");
75  $page = $this->mybrowser->clickSubmit('Edit!');
76  $this->assertTrue($page);
77  $this->assertTrue($this->myassertText($page, "/Folder Properties changed/"),
78  "FAIL! Folder Properties changed not found\n");
79  /* check the browse page */
80  $page = $this->mybrowser->get("$URL?mod=browse");
81  $this->assertTrue($this->myassertText($page, "/$this->newname/"),
82  "FAIL! Folder $this->newname not found\n");
83  //print "************ page after Folder Delete! *************\n$page\n";
84  }
85  function tearDown()
86  {
87  global $URL;
88  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
89  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
90  $FolderId = $this->getFolderId($this->newname, $page, 'folder');
91  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
92  $page = $this->mybrowser->clickSubmit('Delete!');
93  $this->assertTrue($page);
94  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->newname/"),
95  "EditFolderOnlyTest tearDown FAILED! Deletion of $this->newname not found\n");
96  }
97 }
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:54