FOSSology  4.4.0
Open Source License Compliance by Open Source Software
DupFolderTest.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 
17 require_once ('../../../tests/fossologyTestCase.php');
18 require_once ('../../../tests/TestEnvironment.php');
19 
20 /* every test must use these globals, at least $URL */
21 global $URL;
22 
24 {
25  public $folder_name;
26  public $mybrowser;
27 
28  function setUP()
29  {
30  global $URL;
31 
32  $this->Login();
33  }
34 
35  function testCreateFolder()
36  {
37  global $URL;
38 
39  print "starting DupFoldertest\n";
40  /* try to create the same folder twice */
41  for ($i = 0; $i < 2; $i++)
42  {
43  $this->mybrowser->get($URL);
44  $page = $this->mybrowser->clickLink('Create');
45  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
46  /* select the folder to create this folder under */
47  $this->assertTrue($this->mybrowser->setField('parentid', 1));
48  /* create unique name and insert into form */
49  $id = getmypid();
50  $this->folder_name = 'TestCreateFolder-' . "$id";
51  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
52  $desc = 'Folder created by DupFolderTest as subfolder of RootFolder';
53  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
54  $page = $this->mybrowser->clickSubmit('Create!');
55  $this->assertTrue($page);
56  /* On the second try, we SHOULD NOT see Folder xxx Created */
57  if($i == 1)
58  {
59  $this->assertFalse($this->myassertText($page, "/Folder $this->folder_name Created/"),
60  "FAIL! Folder $this->folder_name Created Was seen,\n");
61  }
62  else
63  {
64  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
65  "FAIL! Folder $this->folder_name Created not found\n");
66  }
67  //print "************ page after Folder Create! *************\n$page\n";
68  }
69  }
70 
71  function tearDown()
72  {
73  global $URL;
74  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
75  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
76  $FolderId = $this->getFolderId($this->folder_name, $page, 'folder');
77  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
78  $page = $this->mybrowser->clickSubmit('Delete!');
79  $this->assertTrue($page);
80  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->folder_name/"),
81  "DupFoldeTest tearDown FAILED! Deletion of $this->folder_name not found\n");
82  }
83 }
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:54