FOSSology  4.4.0
Open Source License Compliance by Open Source Software
CreateFolderTest.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 
16 require_once ('../../../tests/fossologyTestCase.php');
17 require_once ('../../../tests/TestEnvironment.php');
18 
19 /* every test must use these globals, at least $URL */
20 global $URL;
21 
23 {
24  public $folder_name;
25  public $mybrowser;
26 
27  function setUp()
28  {
29  global $URL;
30  $this->Login();
31  }
32 
33  function testCreateFolder()
34  {
35  global $URL;
36 
37  print "starting CreateFoldertest\n";
38  $loggedIn = $this->mybrowser->get($URL);
39  $this->assertTrue($this->myassertText($loggedIn, '/Organize/'),
40  "FAIL! Could not find Organize menu\n");
41  $this->assertTrue($this->myassertText($loggedIn, '/Folders /'));
42  $this->assertTrue($this->myassertText($loggedIn, '/Create/'));
43  /* ok, this proves the text is on the page, let's see if we can
44  * go to the page and create a folder
45  */
46  $page = $this->mybrowser->get("$URL?mod=folder_create");
47  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
48  /* select the folder to create this folder under */
49  $FolderId = $this->getFolderId('Basic-Testing', $page, 'parentid');
50  $this->assertTrue($this->mybrowser->setField('parentid', $FolderId));
51  /* create unique name and insert into form */
52  $id = getmypid();
53  $this->folder_name = 'TestCreateFolder-' . "$id";
54 
55  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
56  $desc = 'Folder created by CreateFolderTest as subfolder of Basic-Testing';
57  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
58  $page = $this->mybrowser->clickSubmit('Create!');
59  $this->assertTrue($page);
60  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
61  "FAIL! Folder $this->folder_name Created not found\n");
62 
63  //print "************ page after Folder Create! *************\n$page\n";
64  }
65  function tearDown()
66  {
67  global $URL;
68  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
69  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
70  $FolderId = $this->getFolderId($this->folder_name, $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  "CreateFoldeTest tearDown FAILED! Deletion of $this->folder_name not found\n");
76  }
77 }
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:54