FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
mytest.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 /* every test must use these includes, adjust the paths based on where the
28  * tests are in the source tree.
29  */
30 require_once ('TestEnvironment.php');
31 require_once ('fossologyTestCase.php');
32 
33 global $URL;
34 
36 {
37  public $mybrowser;
38  public $testFolder;
39 
40  /*
41  * Every Test needs to login so we use the setUp method for that.
42  * setUp is called before any other method by default.
43  *
44  * If other actions like creating a folder or something are needed,
45  * put them in the setUp method after login.
46  *
47  */
48  function setUp()
49  {
50  $this->Login();
51  }
52 /* all runnable test names (methods/functions) must start with 'test' */
53  function testmytest()
54  {
55  global $URL;
56  print "starting testmytest\n";
57  $page = $this->mybrowser->get($URL);
58  $page = $this->mybrowser->clickLink('Browse');
59  //print "page after Browse is:\n$page\n";
60  $this->assertTrue($this->myassertText($page,'/Folder Navigation/'),
61  "testmyTest FAILED! There is no Folder Navigation Title\n");
62  $page = $this->mybrowser->clickLink('Create');
63  $this->testFolder = 'Sample-Folder';
64  $this->createFolder('Testing', $this->testFolder, null);
65  /* normally one should verify that the folder was created. You could
66  * see if it was in the Software Repository listing, you could find
67  * it's folder_pk in the page and verify that by looking in the
68  * db... for this sample, the tear down method will also serve as a
69  * verify method. If teardown fails, because it can't find the
70  * folder, then we know that the folder create failed. Additionally
71  * the createFolder routine verifies it saw the folder created
72  * message... so for this example, I skipped it.
73  */
74  }
75  /* use the tearDown method to clean up after a test. This method like
76  * setUp will run after every test.
77  */
78 
79  function tearDown()
80  {
81  global $URL;
82  print "mytest: in tearDown\n";
83  $page = $this->mybrowser->get("$URL?mod=admin_folder_delete");
84  $this->assertTrue($this->myassertText($page, '/Delete Folder/'));
85  $FolderId = $this->getFolderId($this->testFolder, $page);
86  $this->assertTrue($this->mybrowser->setField('folder', $FolderId));
87  $page = $this->mybrowser->clickSubmit('Delete!');
88  $this->assertTrue(page);
89  $this->assertTrue($this->myassertText($page, "/Deletion of folder $this->testFolder/"),
90  "FolderTest tearDown FAILED! Deletion of $this->testFolder not found\n");
91  }
92 }
93 ?>
createFolder($parent=null, $name, $description=null)
getFolderId($folderName, $page, $selectName)
Login($User=NULL, $Password=NULL)