[ticket/9687] Fix ban session tests for real

PHPBB3-9687
This commit is contained in:
Oliver Schramm 2018-11-08 20:45:17 +01:00 committed by Marc Alexander
parent 40b1d1e6ff
commit 3563f20991
No known key found for this signature in database
GPG key ID: 50E0D2423696F995

View file

@ -33,8 +33,6 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
false, false, false, false, /* should be banned? -> */ false),
array('Matching values in the database, should be banned',
4, '127.0.0.1', 'bar@example.org', true, /* should be banned? -> */ true),
array('IP Banned, should not be banned',
false, '127.1.1.1', false, false, /* should be banned? -> */ false),
);
}
@ -53,7 +51,7 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
'BAN_TRIGGERED_BY_USER' => 'BAN_TRIGGERED_BY_USER',
];
global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem;
global $cache, $config, $phpbb_root_path, $phpEx, $phpbb_filesystem, $phpbb_container;
$phpbb_filesystem = new \phpbb\filesystem\filesystem();
@ -73,6 +71,18 @@ class phpbb_session_check_ban_test extends phpbb_session_test_case
$phpbb_root_path,
$phpEx
);
$phpbb_container = new phpbb_mock_container_builder();
$ban_type_email = new \phpbb\ban\type\email($this->db, 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys');
$ban_type_user = new \phpbb\ban\type\user($this->db, 'phpbb_users', 'phpbb_sessions', 'phpbb_sessions_keys');
$phpbb_container->set('ban.type.email', $ban_type_email);
$phpbb_container->set('ban.type.user', $ban_type_user);
$collection = new \phpbb\di\service_collection($phpbb_container);
$collection->add('ban.type.email');
$collection->add('ban.type.user');
$ban_manager = new \phpbb\ban\manager($collection, $cache, $this->db, 'phpbb_bans', 'phpbb_users');
$phpbb_container->set('ban.manager', $ban_manager);
}
protected function tearDown(): void