FOSSology  4.4.0
Open Source License Compliance by Open Source Software
noEmailUserTest.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 
25  function setUP() {
26  global $URL;
27  $this->Login();
28  }
29  function testNoEmailUser() {
30  global $URL;
31 
32  /* Check that the user exists */
33  $loggedIn = $this->mybrowser->get($URL);
34  $this->assertTrue($this->myassertText($loggedIn, '/Admin/'));
35  $this->assertTrue($this->myassertText($loggedIn, '/Users/'));
36  $page = $this->mybrowser->get("$URL?mod=user_add");
37  $this->assertTrue($this->myassertText($page, '/Add A User/'));
38  $this->assertTrue($this->myassertText($page, '/To create a new user,/'));
39  $result = $this->addUser('UserNoEmail', 'No email notification user',
40  'fosstester', 1, 1, 'noetest', NULL);
41  if (!is_null($result)) {
42  /*
43  * The test is just creating the user so we can verify that email
44  * notification was not turned on. So, it's OK to have the user already
45  * there, for this test it's not an error.
46  */
47  if ($result != "User already exists. Not added") {
48  $this->fail("Did not add user UserwEmail result was:\n$result\n");
49  }
50  }
51 
52  /*
53  * Verify, check the db for this user to ensure email_notify is NOT set.
54  */
55  $dlink = new db('host=localhost dbname=fossology user=fosstester password=fosstester;');
56  print "Verifying User email notification setting\n";
57  $Sql = "SELECT user_name, email_notify FROM users WHERE user_name='UserNoEmail';";
58  $User = $dlink->dbQuery($Sql);
59  print "DB: User(SQL results) are:\n";print_r($User) . "\n";
60  if((int)$User[0]['email_notify'] == 0) {
61  $this->pass();
62  }
63  else {
64  $this->fail("Fail! User UserNoEmail email_notify is not NULL\n");
65  printf("in octal the entry for email_notify is:%o\n",$User[0]['email_notify']);
66  }
67  } //testNoEmailUser
68 }
Definition: db.php:28
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify='y')
Login($User=NULL, $Password=NULL)