FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
dupUserTest.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 global $URL;
31 
33  public $mybrowser;
34  private $UserName;
35 
36  function setUP() {
37  global $URL;
38  $this->Login();
39  }
40 
41  function testDupUser() {
42  global $URL;
43 
44  print "starting DupUserTest\n";
45 
46  $loggedIn = $this->mybrowser->get($URL);
47  $this->assertTrue($this->myassertText($loggedIn, '/Admin/'));
48  $this->assertTrue($this->myassertText($loggedIn, '/Users/'));
49  $page = $this->mybrowser->get("$URL?mod=user_add");
50  $this->assertTrue($this->myassertText($page, '/Add A User/'));
51  $this->assertTrue($this->myassertText($page, '/To create a new user,/'));
52  $this->UserName = 'TestUserDup';
53  $this->addUser($this->UserName,'Created for Duplicate user testing','fosstester',1,1,'test');
54  /* Try to add the user again */
55  $page = $this->mybrowser->get("$URL?mod=user_add");
56  $this->assertTrue($this->myassertText($page, '/Add A User/'));
57  $this->assertTrue($this->myassertText($page, '/To create a new user,/'));
58  $result = $this->addUser($this->UserName,'Created for Duplicate user testing',
59  'fosstester',1,1,'test');
60  if(!empty($result)) {
61  $pattern = "/User already exists\. Not added/";
62  if(preg_match($pattern,$result,$match)) {
63  $this->pass();
64  }
65  else {
66  $this->fail("Did not match string, got:\n$result\n");
67  }
68  }
69  }
70  function tearDown(){
71  /* Cleanup: remove the user */
72  print "Removing user $this->UserName\n";
73  $this->deleteUser($this->UserName);
74  }
75 }
76 
77 ?>
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify= 'y')
Login($User=NULL, $Password=NULL)