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