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