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