FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
emailUserTest.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  protected $User;
36 
37  function setUP() {
38 
39  global $URL;
40  $this->Login();
41  }
42  function testEmailUser() {
43 
44  global $URL;
45  print "starting EmailUserTest\n";
46  /* Create the user */
47  print "Creating user: UserwEmail\n";
48  $loggedIn = $this->mybrowser->get($URL);
49  $this->assertTrue($this->myassertText($loggedIn, '/Admin/'));
50  $this->assertTrue($this->myassertText($loggedIn, '/Users/'));
51  $page = $this->mybrowser->get("$URL?mod=user_add");
52  $this->assertTrue($this->myassertText($page, '/Add A User/'));
53  $this->assertTrue($this->myassertText($page, '/To create a new user,/'));
54  $result = $this->addUser('UserwEmail', 'email notification user',
55  'fosstester', 1, 1, 'uwetest', 'y');
56  if (!is_null($result)) {
57  /*
58  * The test is just creating the user so we can verify that email
59  * notification was not turned on. So, it's OK to have the user already
60  * there, for this test it's not an error.
61  */
62  if ($result != "User already exists. Not added") {
63  $this->fail("Did not add user UserwEmail result was:\n$result\n");
64  }
65  }
66  /*
67  * Verify, check the db entry for the user and make sure email_notify is set.
68  */
69  print "Verifying User email notification\n";
70  $dlink = new db('host=localhost dbname=fossology user=fosstester password=fosstester');
71  $Sql = "SELECT user_name, email_notify FROM users WHERE user_name='UserwEmail';";
72  $User = $dlink->dbQuery($Sql);
73  //print "Entryies are: {$User[0]['user_name']}, {$User[0]['email_notify']}\n";
74  $this->assertEqual($User[0]['email_notify'],'y',
75  "Fail! User UserwEmail does not have email_notify set\n");
76  } //testEmailUser
77 };
78 ?>
Definition: db.php:41
addUser($UserName, $Description=NULL, $Email=NULL, $Access=1, $Folder=1, $Password=NULL, $EmailNotify= 'y')
Login($User=NULL, $Password=NULL)