Skip to content

Commit 564c96e

Browse files
authored
Merge pull request #56 from iMattPro/tests
Update tests
2 parents 4f1f623 + 7890e91 commit 564c96e

8 files changed

Lines changed: 19 additions & 16 deletions

tests/event/delete_log_security_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@ public function test_delete_logs_security($mode, $log_type, $expected_log_type)
5151

5252
$new_events = $event->get_data_filtered($event_data);
5353

54-
$this->assertSame($expected_log_type, $new_events['log_type']);
54+
self::assertSame($expected_log_type, $new_events['log_type']);
5555
}
5656
}

tests/event/email_change_notification_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,13 @@ public function test_email_change_notification($listener, $enabled, $in_watch_gr
155155

156156
$this->set_listener();
157157

158-
$this->listener->expects($this->atMost(1))
158+
$this->listener->expects(self::atMost(1))
159159
->method('in_watch_group')
160160
->willReturn($in_watch_group);
161161

162162
// Check send_message once if conditions are true,
163163
// otherwise check that it is never called.
164-
$this->listener->expects(($enabled && $this->user->data['user_email'] != $data['email'] && $in_watch_group) ? $this->once() : $this->never())
164+
$this->listener->expects(($enabled && $this->user->data['user_email'] != $data['email'] && $in_watch_group) ? self::once() : self::never())
165165
->method('send_message')
166166
->with($expected);
167167

tests/event/event_listener_test.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@ class event_listener_test extends listener_base
1818
public function test_construct()
1919
{
2020
$this->set_listener();
21-
$this->assertInstanceOf('\Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener);
21+
self::assertInstanceOf('\Symfony\Component\EventDispatcher\EventSubscriberInterface', $this->listener);
2222
}
2323

2424
/**
2525
* Test the event listener is subscribing events
2626
*/
2727
public function test_getSubscribedEvents()
2828
{
29-
$this->assertEquals(array(
29+
self::assertEquals(array(
3030
'core.user_setup',
3131
'core.acp_users_overview_before',
3232
'core.ucp_display_module_before',

tests/event/failed_logins_test.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ public function log_failed_login_attempts_data()
2121
{
2222
return array(
2323
array(true, true, array('user_row' => array('user_id' => 2))),
24-
array(false, true, array()),
25-
array(true, false, array()),
26-
array(false, false, array()),
24+
array(false, true, array('user_row' => array('user_id' => 0))),
25+
array(true, false, array('user_row' => array('user_id' => 0))),
26+
array(false, false, array('user_row' => array('user_id' => 0))),
2727
);
2828
}
2929

@@ -40,13 +40,13 @@ public function test_log_failed_login_attempts($enabled, $in_watch_group, $resul
4040

4141
$this->set_listener();
4242

43-
$this->listener->expects($this->atMost(1))
43+
$this->listener->expects(self::atMost(1))
4444
->method('in_watch_group')
4545
->willReturn($in_watch_group);
4646

4747
// Check log->add is called once with expected data if enabled and in_watch_group are true,
4848
// otherwise check that it is never called.
49-
$this->log->expects(($enabled && $in_watch_group) ? $this->once() : $this->never())
49+
$this->log->expects(($enabled && $in_watch_group) ? self::once() : self::never())
5050
->method('add')
5151
->with('user', $result['user_row']['user_id'], $this->user->ip, 'LOG_TEAM_AUTH_FAIL', time(), array('reportee_id' => $result['user_row']['user_id']));
5252

tests/event/listener_base.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class listener_base extends \phpbb_test_case
3636
/**
3737
* Setup test environment
3838
*/
39-
public function setUp()
39+
protected function setUp(): void
4040
{
4141
parent::setUp();
4242

@@ -50,6 +50,9 @@ public function setUp()
5050
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
5151
$this->lang = new \phpbb\language\language($lang_loader);
5252
$this->user = new \phpbb\user($this->lang, '\phpbb\datetime');
53+
$this->user->data['user_id'] = 100;
54+
$this->user->data['username'] = '';
55+
$this->user->data['user_email'] = '';
5356
$this->root_path = $phpbb_root_path;
5457
$this->php_ext = $phpEx;
5558
$phpbb_dispatcher = new \phpbb_mock_event_dispatcher();

tests/event/load_language_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public function test_load_language_on_setup($lang_set_ext, $expected_contains)
7171

7272
foreach ($expected_contains as $expected)
7373
{
74-
$this->assertContains($expected, $lang_set_ext);
74+
self::assertContains($expected, $lang_set_ext);
7575
}
7676
}
7777
}

tests/event/login_notification_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function test_acp_login_notification($enabled, $admin, $username, $ip, $e
5757

5858
// Check send_message once if enabled and admin are true,
5959
// otherwise check that it is never called.
60-
$this->listener->expects(($enabled && $admin) ? $this->once() : $this->never())
60+
$this->listener->expects(($enabled && $admin) ? self::once() : self::never())
6161
->method('send_message')
6262
->with($expected);
6363

tests/event/team_passwords_test.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public function test_set_team_password_configs($listener, $mode, $user_row, $sec
5151

5252
$this->set_listener();
5353

54-
$this->listener->expects($this->atMost(1))
54+
$this->listener->expects(self::atMost(1))
5555
->method('in_watch_group')
5656
->willReturn($in_watch_group);
5757

@@ -62,7 +62,7 @@ public function test_set_team_password_configs($listener, $mode, $user_row, $sec
6262
$event = new \phpbb\event\data(compact($event_data));
6363
$dispatcher->dispatch($listener, $event);
6464

65-
$this->assertEquals($expected, $this->config['pass_complex']);
66-
$this->assertEquals($sec_min_pass_chars, $this->config['min_pass_chars']);
65+
self::assertEquals($expected, $this->config['pass_complex']);
66+
self::assertEquals($sec_min_pass_chars, $this->config['min_pass_chars']);
6767
}
6868
}

0 commit comments

Comments
 (0)