~budgester/irm/trunk

« back to all changes in this revision

Viewing changes to testing/SetupFuncTest.php

  • Committer: budgester at budgester
  • Date: 2008-03-05 23:14:13 UTC
  • Revision ID: budgester@budgester.com-20080305231413-k5vqfuckfo09ju42
Initial import of IRM codebase

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
class SetupFuncTest extends IRM_WebTestCase
 
4
{
 
5
        function testSetupUpdate()
 
6
        {
 
7
                $this->get(TESTING_BASEURI);
 
8
                $this->_Login('Admin', 'admin');
 
9
                $this->get(TESTING_BASEURI.'/users/setup-irm.php');
 
10
                $this->assertTitle('IRM: System Setup');
 
11
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
12
 
 
13
                $this->assertWantedPattern('/Email Options/');
 
14
 
 
15
                $this->assertTrue($this->setField('notifynewtrackingbyemail', false));
 
16
                $this->assertTrue($this->setField('userupdates', false));
 
17
                $this->assertTrue($this->setField('showjobsonlogin', false));
 
18
                $this->assertTrue($this->setField('logo', 'irm-jr2.jpg'));
 
19
                $this->assertTrue($this->setField('stylesheet', 'green'));
 
20
                
 
21
                $this->clickSubmit('Update');
 
22
                
 
23
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
24
 
 
25
                $this->assertEqual(false, Config::Get('notifynewtrackingbyemail'));
 
26
                $this->assertEqual(false, Config::Get('userupdates'));
 
27
                $this->assertEqual(false, Config::Get('showjobsonlogin'));
 
28
                $this->assertEqual('irm-jr2.jpg', Config::Get('logo'));
 
29
                $this->assertEqual('green.css', Config::Get('stylesheet'));
 
30
        }
 
31
 
 
32
        function testTemplateUpdate()
 
33
        {
 
34
                $rows[] = "DELETE FROM templates";
 
35
                $rows[] = "INSERT INTO templates (ID, templname, os, osver)
 
36
                                VALUES (12, 'Unit Tester', 'SimpleTest', '0.3')";
 
37
 
 
38
                BulkQueries($rows);
 
39
                
 
40
                $this->_Login('Admin', 'admin');
 
41
                $this->clickLink('Setup');
 
42
                $this->clickLink('Manage Templates');
 
43
                $this->clickLink('Unit Tester');
 
44
                $this->assertTitle('IRM: Setup - Templates Editor');
 
45
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
46
                
 
47
                $this->assertTrue($this->setField('osver', '0.5'));
 
48
                $this->clickSubmit('Update');
 
49
                
 
50
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
51
                $this->assertDBField('0.5', 'templates', 'osver');
 
52
        }
 
53
 
 
54
        function testAddKnowledgeBaseCategory()
 
55
        {
 
56
                $this->_Login('Admin', 'admin');
 
57
                $this->clickLink('Setup');
 
58
                $this->clickLink('Setup the Knowledge Base');
 
59
                $this->assertTitle('IRM: Knowledge Base Setup');
 
60
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
61
                
 
62
                $this->assertTrue($this->setField('categoryname', 'Random Crap'));
 
63
                $this->assertTrue($this->setField('categorylist', 'Main'));
 
64
                $this->clickSubmit('Add');
 
65
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
66
                
 
67
                global $DB;
 
68
                $this->assertEqual('Random Crap', $DB->getOne("SELECT name FROM kbcategories WHERE name='Random Crap'"));
 
69
                $this->assertEqual('0', $DB->getOne("SELECT parentID FROM kbcategories WHERE name='Random Crap'"));
 
70
        }
 
71
 
 
72
        function testDeleteKnowledgeBaseCategory()
 
73
        {
 
74
                $this->_Login('Admin', 'admin');
 
75
                $this->clickLink('Setup');
 
76
                $this->clickLink('Setup the Knowledge Base');
 
77
                $this->assertTitle('IRM: Knowledge Base Setup');
 
78
                
 
79
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
80
        }
 
81
}
 
82
 
 
83
class UserSetupFuncTest extends IRM_WebTestCase
 
84
{
 
85
        function testUpdateUserDetails()
 
86
        {
 
87
                $rows[] = "DELETE FROM users";
 
88
                $rows[] = "INSERT INTO users (name, password, fullname, type)
 
89
                        VALUES ('user', md5('xyz'), 'Joe Usr', 'admin')";
 
90
                BulkQueries($rows);
 
91
                
 
92
                $this->_Login('user', 'xyz');
 
93
                $this->assertTrue($this->clickLink('Setup'));
 
94
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
95
                
 
96
                $this->assertTrue($this->clickLink('Setup Users'));
 
97
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
98
 
 
99
                $this->assertTrue($this->clickLink('[edit]'));
 
100
                $this->assertNoUnwantedPattern(PHP_ERROR_REGEX);
 
101
                $this->assertTitle('IRM: Users - User Update');
 
102
                
 
103
                $this->assertTrue($this->setField('fullname', 'Joe User'));
 
104
                $this->assertTrue($this->setField('location', 'Nowhere'));
 
105
                $this->assertTrue($this->setField('password', 'abc'));
 
106
                $this->clickSubmit('Update');
 
107
                
 
108
                $this->assertDBField('Joe User', 'users', 'fullname');
 
109
                $this->assertDBField('Nowhere', 'users', 'location');
 
110
                $this->assertDBField(md5('abc'), 'users', 'password');
 
111
 
 
112
                $adminpassword = "admin";
 
113
 
 
114
                $origrows[] = "DELETE FROM users";
 
115
                $origrows[] = "INSERT INTO users
 
116
                        (name, password, fullname, email,
 
117
                         location, phone, type)
 
118
                        VALUES
 
119
                        ('Admin',md5('$adminpassword'),'Administrator Guy','root@localhost',
 
120
                         'Admin Place (in front of the computer)','Use e-mail','admin')";
 
121
                $origrows[] = "INSERT INTO users
 
122
                        (name, password, fullname, type)
 
123
                        VALUES
 
124
                        ('Guest',md5('guest'),'Guest User','post-only')";
 
125
                $origrows[] = "INSERT INTO users
 
126
                        (name, password, fullname, email, type)
 
127
                        VALUES
 
128
                        ('Normal',md5('normal'),'Normal User','user@localhost','normal')";
 
129
                $origrows[] = "INSERT INTO users
 
130
                        (name, password, fullname, email, type)
 
131
                        VALUES
 
132
                        ('Tech',md5('tech'),'Technician User','tech@localhost','tech')";
 
133
                $origrows[] = "INSERT INTO users
 
134
                        (name, password, fullname, type)
 
135
                        VALUES
 
136
                        ('IRMConnect',md5('irmconnect'),'Special account','post-only')";
 
137
 
 
138
                BulkQueries($origrows);
 
139
 
 
140
        }
 
141
}