FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
templateTest.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 
31 /* every test must use these includes, adjust the paths based on where the
32  * tests are in the source tree.
33  */
34 require_once ('../../../../tests/fossologyTestCase.php');
35 require_once ('../../../../tests/TestEnvironment.php');
36 
37 /* Globals for test use, most tests need $URL, only login needs the others */
38 global $URL;
39 global $USER;
40 global $PASSWORD;
41 
42 /* The class name should end in Test */
43 
44 /* NOTE: You MUST remove the abstract or the test will not get run */
45 abstract class someTest extends fossologyTestCase
46 {
47  public $mybrowser; // must have
48  public $someOtherVariable;
49 
50  /*
51  * Every Test needs to login so we use the setUp method for that.
52  * setUp is called before any other method by default.
53  *
54  * If other actions like creating a folder or something are needed,
55  * put them in the setUp method after login.
56  *
57  */
58  function setUp()
59  {
60  global $URL;
61  $this->Login();
62  }
63 
64  /*
65  * usually the test will only have one method. For a test to be
66  * run the method name must start with 'test'.
67  *
68  * Every Test should print a start message, this is useful to help
69  * determine where a test failed. Most assert's can take an optional
70  * string to be printed on failure of the assertion. This is a good
71  * practice to help someone running the tests figure out what went
72  * wrong.
73  *
74  * Every test should login to the site, so that it can be run
75  * standalone. Use the Login method (defined in fossologyTest).
76  *
77  * The login method will get a browser object and store that in the
78  * instance variable/class property $mybrowser. The login method also
79  * sets the cookie so the test doesn't get logged out.
80  */
81  function testsome()
82  {
83  global $URL;
84 
85  print "starting testSome\n";
86 
87  /* at this point the test is ready to naviate to the url it wants to
88  * test and starts testing.
89  *
90  * For example, the lines below navigate to the browse screen and
91  * look for a title called Folder Navigation and the standard root
92  * folder (Software Repository.)
93  *
94  * Just for fun it checks to see if /tmp exists. :)
95  */
96  $page = $this->mybrowser->clickLink('Browse');
97  $this->assertTrue(assertText('/Folder Navigation/'),
98  "FAIL! There is no Folder Navigation Title\n");
99  $this->assertTrue(assertText('/>S.*?y<//'),
100  "FAIL! There is no Root Folder!\n");
101  $this->assertTrue(is_dir('/tmp'),
102  "FAIL! There is no /tmp\n");
103  }
104 
105  /* use the tearDown method to clean up after a test. This method like
106  * setUp will run after every test.
107  */
108  function tearDown()
109  {
110  return(TRUE);
111  }
112 }
113 
114 ?>
Login($User=NULL, $Password=NULL)