Skip to content

Commit 9f9c178

Browse files
committed
Fix
1 parent e4df596 commit 9f9c178

6 files changed

Lines changed: 19 additions & 17 deletions

File tree

tests/TestHelper.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function setupDB() {
1818
}
1919

2020
public static function teardownDB() {
21-
FOO\Auth::setUserId(0);
21+
FOO\Auth::setUser(null);
2222
FOO\Cookie::setWrite(true);
2323
FOO\DB::disconnect();
2424
}
@@ -32,17 +32,19 @@ public static function populateDB($arr) {
3232

3333
public static function populateUsers() {
3434
self::populateDB([
35-
[FOO\User::$TABLE, 1, 0, 'admin', 'Admin', '', 'test@test.com', true, '', 0, 0, 0],
36-
[FOO\User::$TABLE, 2, 0, 'user', 'User', '', 'test@test.com', false, '', 0, 0, 0],
35+
[FOO\User::$TABLE, 1, 0, 'admin', 'Admin', '', 'test@test.com', true, '', 'a', 0, 0, 0],
36+
[FOO\User::$TABLE, 2, 0, 'user', 'User', '', 'test@test.com', false, '', 'u', 0, 0, 0],
3737
]);
3838
}
3939

4040
public static function becomeAdmin() {
41-
FOO\Auth::setUserId(1);
41+
$user = FOO\UserFinder::getById(1);
42+
FOO\Auth::setUser($user);
4243
}
4344

4445
public static function becomeUser() {
45-
FOO\Auth::setUserId(2);
46+
$user = FOO\UserFinder::getById(2);
47+
FOO\Auth::setUser($user);
4648
}
4749

4850
public static function populateSite() {

tests/unit/AlertLogTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,24 @@ public function testGetDescription() {
55
$alertlog = new FOO\AlertLog();
66

77
$alertlog['action'] = FOO\AlertLog::A_NOTE;
8-
$this->assertSame('Unknown added a note', $alertlog->getDescription());
8+
$this->assertSame('System added a note', $alertlog->getDescription());
99

1010
$alertlog['action'] = FOO\AlertLog::A_ESCALATE;
1111
$alertlog['a'] = 1;
12-
$this->assertSame('Unknown escalated', $alertlog->getDescription());
12+
$this->assertSame('System escalated', $alertlog->getDescription());
1313

1414
$alertlog['action'] = FOO\AlertLog::A_ASSIGN;
1515
$alertlog['a'] = 1;
16-
$this->assertSame('Unknown assigned to Unknown', $alertlog->getDescription());
16+
$this->assertSame('System assigned to System', $alertlog->getDescription());
1717
$alertlog['a'] = 0;
18-
$this->assertSame('Unknown unassigned', $alertlog->getDescription());
18+
$this->assertSame('System unassigned', $alertlog->getDescription());
1919

2020
$alertlog['action'] = FOO\AlertLog::A_SWITCH;
2121
$alertlog['a'] = 0;
22-
$this->assertSame('Unknown marked New', $alertlog->getDescription());
22+
$this->assertSame('System marked New', $alertlog->getDescription());
2323
$alertlog['a'] = 2;
2424
$alertlog['b'] = 0;
25-
$this->assertSame('Unknown marked Resolved (Not an issue)', $alertlog->getDescription());
25+
$this->assertSame('System marked Resolved (Not an issue)', $alertlog->getDescription());
2626
}
2727

2828
public function testFinderGetRecentForRollup() {

tests/unit/AssigneeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22

33
class AssigneeTest extends DBTestCase {
44
public function testGet() {
5-
$this->assertSame('Unknown', FOO\Assignee::getName(0, 0));
5+
$this->assertSame('System', FOO\Assignee::getName(0, 0));
66

77
TestHelper::populateDB([
8-
[FOO\User::$TABLE, 1, 0, 'user', 'User', '', 'test@test.com', false, '', 0, 0, 0],
8+
[FOO\User::$TABLE, 1, 0, 'user', 'User', '', 'test@test.com', false, '', '', 0, 0, 0],
99
[FOO\Group::$TABLE, 2, 0, FOO\Group::T_ALL, 0, 'Group', 0, 0, 0],
1010
[FOO\GroupTarget::$TABLE, 1, 0, 2, FOO\GroupTarget::T_USER, 1, '', 0, 0, 0],
1111
[FOO\GroupTarget::$TABLE, 2, 0, 2, FOO\GroupTarget::T_EMAIL, 1, 'test@example.com', 0, 0, 0],

tests/unit/AuthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,14 @@
22

33
class AuthTest extends DBTestCase {
44
public function testLogout() {
5-
FOO\Auth::setUserId(1);
5+
TestHelper::becomeAdmin();
66
FOO\Auth::logout();
77
$this->assertFalse(FOO\Auth::isAuthenticated());
88
}
99

1010
public function testLogin() {
1111
TestHelper::populateDB([
12-
[FOO\User::$TABLE, 1, 0, 'admin', 'Admin', password_hash('pass', PASSWORD_DEFAULT), 'test@test.com', true, '', 0, 0, 0],
12+
[FOO\User::$TABLE, 1, 0, 'admin', 'Admin', password_hash('pass', PASSWORD_DEFAULT), 'test@test.com', true, '', '', 0, 0, 0],
1313
]);
1414

1515
$this->assertNull(FOO\Auth::login('admin', ''));

tests/unit/GroupTargetTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class GroupTargetTest extends DBTestCase {
44
public function testGetEmail() {
55
TestHelper::populateDB([
6-
[FOO\User::$TABLE, 1, 0, 'user', 'User', '', 'user@test.com', false, '', 0, 0, 0]
6+
[FOO\User::$TABLE, 1, 0, 'user', 'User', '', 'user@test.com', false, '', '', 0, 0, 0]
77
]);
88

99
$grouptarget = new FOO\GroupTarget();

tests/unit/UserTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class UserTest extends DBTestCase {
44
public function testFinderGetByName() {
55
TestHelper::populateDB([
6-
[FOO\User::$TABLE, 1, 0, 'user', 'User', '', 'user@test.com', false, '', 0, 0, 0]
6+
[FOO\User::$TABLE, 1, 0, 'user', 'User', '', 'user@test.com', false, '', '', 0, 0, 0]
77
]);
88

99
$this->assertSame(1, FOO\UserFinder::getByName('user')['id']);

0 commit comments

Comments
 (0)