FOSSology  4.4.0
Open Source License Compliance by Open Source Software
emailUserTest.php
1 <?php
2 /*
3  SPDX-FileCopyrightText: © 2008 Hewlett-Packard Development Company, L.P.
4 
5  SPDX-License-Identifier: GPL-2.0-only
6 */
15 require_once ('../../../tests/fossologyTestCase.php');
16 require_once ('../../../tests/TestEnvironment.php');
17 require_once (TESTROOT . '/testClasses/db.php');
18 
19 global $URL;
20 
22 
23  public $mybrowser;
24  protected $User;
25 
26  function setUP() {
27 
28  global $URL;
29  $this->Login();
30  }
31  function testEmailUser() {
32 
33  global $URL;
34  print "starting EmailUserTest\n";
35  /* Create the user */
36  print "Creating user: UserwEmail\n";
37  $loggedIn = $this->mybrowser->get($URL);
38  $this->assertTrue($this->myassertText($loggedIn, '/Admin/'));
39  $this->assertTrue($this->myassertText($loggedIn, '/Users/'));
40  $page = $this->mybrowser->get("$URL?mod=user_add");
41  $this->assertTrue($this->myassertText($page, '/Add A User/'));
42  $this->assertTrue($this->myassertText($page, '/To create a new user,/'));
43  $result = $this->addUser('UserwEmail', 'email notification user',
44  'fosstester', 1, 1, 'uwetest', 'y');
45  if (!is_null($result)) {
46  /*
47  * The test is just creating the user so we can verify that email
48  * notification was not turned on. So, it's OK to have the user already
49  * there, for this test it's not an error.
50  */
51  if ($result != "User already exists. Not added") {
52  $this->fail("Did not add user UserwEmail result was:\n$result\n");
53  }
54  }
55  /*
56  * Verify, check the db entry for the user and make sure email_notify is set.
57  */
58  print "Verifying User email notification\n";
59  $dlink = new db('host=localhost dbname=fossology user=fosstester password=fosstester');
60  $Sql = "SELECT user_name, email_notify FROM users WHERE user_name='UserwEmail';";
61  $User = $dlink->dbQuery($Sql);
62  //print "Entryies are: {$User[0]['user_name']}, {$User[0]['email_notify']}\n";
63  $this->assertEqual($User[0]['email_notify'],'y',
64  "Fail! User UserwEmail does not have email_notify set\n");
65  } //testEmailUser
66 };
Definition: db.php:28
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify='y')
Login($User=NULL, $Password=NULL)