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