FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
DupFolderTest.php
1 <?php
2 /***********************************************************
3  Copyright (C) 2008 Hewlett-Packard Development Company, L.P.
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License along
15  with this program; if not, write to the Free Software Foundation, Inc.,
16  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  ***********************************************************/
18 
28 require_once ('../../../tests/fossologyTestCase.php');
29 require_once ('../../../tests/TestEnvironment.php');
30 
31 /* every test must use these globals, at least $URL */
32 global $URL;
33 
35 {
36  public $folder_name;
37  public $mybrowser;
38 
39  function setUP()
40  {
41  global $URL;
42 
43  $this->Login();
44  }
45 
46  function testCreateFolder()
47  {
48  global $URL;
49 
50  print "starting DupFoldertest\n";
51  /* try to create the same folder twice */
52  for ($i = 0; $i < 2; $i++)
53  {
54  $this->mybrowser->get($URL);
55  $page = $this->mybrowser->clickLink('Create');
56  $this->assertTrue($this->myassertText($page, '/Create a new Fossology folder/'));
57  /* select the folder to create this folder under */
58  $this->assertTrue($this->mybrowser->setField('parentid', 1));
59  /* create unique name and insert into form */
60  $id = getmypid();
61  $this->folder_name = 'TestCreateFolder-' . "$id";
62  $this->assertTrue($this->mybrowser->setField('newname', $this->folder_name));
63  $desc = 'Folder created by DupFolderTest as subfolder of RootFolder';
64  $this->assertTrue($this->mybrowser->setField('description', "$desc"));
65  $page = $this->mybrowser->clickSubmit('Create!');
66  $this->assertTrue($page);
67  /* On the second try, we SHOULD NOT see Folder xxx Created */
68  if($i == 1)
69  {
70  $this->assertFalse($this->myassertText($page, "/Folder $this->folder_name Created/"),
71  "FAIL! Folder $this->folder_name Created Was seen,\n");
72  }
73  else
74  {
75  $this->assertTrue($this->myassertText($page, "/Folder $this->folder_name Created/"),
76  "FAIL! Folder $this->folder_name Created not found\n");
77  }
78  //print "************ page after Folder Create! *************\n$page\n";
79  }
80  }
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  "DupFoldeTest tearDown FAILED! Deletion of $this->folder_name not found\n");
93  }
94 }
95 ?>
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)
const char * folder_name
Definition: sqlstatements.h:65