mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
Merge remote-tracking branch 'phpbb/develop' into ticket/11469
* phpbb/develop: [ticket/11476] Remove pass-by-reference from sql_mutli_insert [ticket/11466] Remove old database driver files from PHPUnit exclude [ticket/11448] Use of $user_id parameter to mark a user's notifications read [ticket/11460] Add default behaviour tests for notification and email types. [ticket/11460] Configure functional test board email using dummy SMTP data. [ticket/11460] Add test for whether post_email and topic_email are checked. [ticket/11460] Add methods for checkbox handling to phpbb_functional_test_case. [ticket/11460] Drop incorrect phpbb_notification_{type,method}_ prefix.
This commit is contained in:
commit
43b6ae3fee
8 changed files with 133 additions and 39 deletions
|
@ -568,12 +568,12 @@ class phpbb_db_driver
|
||||||
* Run more than one insert statement.
|
* Run more than one insert statement.
|
||||||
*
|
*
|
||||||
* @param string $table table name to run the statements on
|
* @param string $table table name to run the statements on
|
||||||
* @param array &$sql_ary multi-dimensional array holding the statement data.
|
* @param array $sql_ary multi-dimensional array holding the statement data.
|
||||||
*
|
*
|
||||||
* @return bool false if no statements were executed.
|
* @return bool false if no statements were executed.
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function sql_multi_insert($table, &$sql_ary)
|
function sql_multi_insert($table, $sql_ary)
|
||||||
{
|
{
|
||||||
if (!sizeof($sql_ary))
|
if (!sizeof($sql_ary))
|
||||||
{
|
{
|
||||||
|
|
|
@ -256,6 +256,7 @@ class phpbb_notification_manager
|
||||||
SET notification_read = 1
|
SET notification_read = 1
|
||||||
WHERE notification_time <= " . (int) $time .
|
WHERE notification_time <= " . (int) $time .
|
||||||
(($item_type !== false) ? ' AND ' . (is_array($item_type) ? $this->db->sql_in_set('item_type', $item_type) : " item_type = '" . $this->db->sql_escape($item_type) . "'") : '') .
|
(($item_type !== false) ? ' AND ' . (is_array($item_type) ? $this->db->sql_in_set('item_type', $item_type) : " item_type = '" . $this->db->sql_escape($item_type) . "'") : '') .
|
||||||
|
(($user_id !== false) ? ' AND ' . (is_array($user_id) ? $this->db->sql_in_set('user_id', $user_id) : 'user_id = ' . (int) $user_id) : '') .
|
||||||
(($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : '');
|
(($item_id !== false) ? ' AND ' . (is_array($item_id) ? $this->db->sql_in_set('item_id', $item_id) : 'item_id = ' . (int) $item_id) : '');
|
||||||
$this->db->sql_query($sql);
|
$this->db->sql_query($sql);
|
||||||
}
|
}
|
||||||
|
|
|
@ -777,9 +777,9 @@ INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogg');
|
||||||
INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm');
|
INSERT INTO phpbb_extensions (group_id, extension) VALUES (9, 'ogm');
|
||||||
|
|
||||||
# User Notification Options (for first user)
|
# User Notification Options (for first user)
|
||||||
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, '');
|
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('post', 0, 2, '');
|
||||||
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_post', 0, 2, 'phpbb_notification_method_email');
|
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('post', 0, 2, 'email');
|
||||||
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, '');
|
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('topic', 0, 2, '');
|
||||||
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('phpbb_notification_type_topic', 0, 2, 'phpbb_notification_method_email');
|
INSERT INTO phpbb_user_notifications (item_type, item_id, user_id, method) VALUES('topic', 0, 2, 'email');
|
||||||
|
|
||||||
# POSTGRES COMMIT #
|
# POSTGRES COMMIT #
|
||||||
|
|
|
@ -24,15 +24,6 @@
|
||||||
<whitelist>
|
<whitelist>
|
||||||
<directory suffix=".php">./phpBB/includes/</directory>
|
<directory suffix=".php">./phpBB/includes/</directory>
|
||||||
<exclude>
|
<exclude>
|
||||||
<file>./phpBB/includes/db/firebird.php</file>
|
|
||||||
<file>./phpBB/includes/db/mysql.php</file>
|
|
||||||
<file>./phpBB/includes/db/mysqli.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssql.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssql_odbc.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssqlnative.php</file>
|
|
||||||
<file>./phpBB/includes/db/oracle.php</file>
|
|
||||||
<file>./phpBB/includes/db/postgres.php</file>
|
|
||||||
<file>./phpBB/includes/db/sqlite.php</file>
|
|
||||||
<file>./phpBB/includes/search/fulltext_native.php</file>
|
<file>./phpBB/includes/search/fulltext_native.php</file>
|
||||||
<file>./phpBB/includes/search/fulltext_mysql.php</file>
|
<file>./phpBB/includes/search/fulltext_mysql.php</file>
|
||||||
<directory suffix=".php">./phpBB/includes/captcha/</directory>
|
<directory suffix=".php">./phpBB/includes/captcha/</directory>
|
||||||
|
|
|
@ -31,15 +31,6 @@
|
||||||
<whitelist>
|
<whitelist>
|
||||||
<directory suffix=".php">./phpBB/includes/</directory>
|
<directory suffix=".php">./phpBB/includes/</directory>
|
||||||
<exclude>
|
<exclude>
|
||||||
<file>./phpBB/includes/db/firebird.php</file>
|
|
||||||
<file>./phpBB/includes/db/mysql.php</file>
|
|
||||||
<file>./phpBB/includes/db/mysqli.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssql.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssql_odbc.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssqlnative.php</file>
|
|
||||||
<file>./phpBB/includes/db/oracle.php</file>
|
|
||||||
<file>./phpBB/includes/db/postgres.php</file>
|
|
||||||
<file>./phpBB/includes/db/sqlite.php</file>
|
|
||||||
<file>./phpBB/includes/search/fulltext_native.php</file>
|
<file>./phpBB/includes/search/fulltext_native.php</file>
|
||||||
<file>./phpBB/includes/search/fulltext_mysql.php</file>
|
<file>./phpBB/includes/search/fulltext_mysql.php</file>
|
||||||
<directory suffix=".php">./phpBB/includes/captcha/</directory>
|
<directory suffix=".php">./phpBB/includes/captcha/</directory>
|
||||||
|
|
|
@ -30,15 +30,6 @@
|
||||||
<whitelist>
|
<whitelist>
|
||||||
<directory suffix=".php">./phpBB/includes/</directory>
|
<directory suffix=".php">./phpBB/includes/</directory>
|
||||||
<exclude>
|
<exclude>
|
||||||
<file>./phpBB/includes/db/firebird.php</file>
|
|
||||||
<file>./phpBB/includes/db/mysql.php</file>
|
|
||||||
<file>./phpBB/includes/db/mysqli.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssql.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssql_odbc.php</file>
|
|
||||||
<file>./phpBB/includes/db/mssqlnative.php</file>
|
|
||||||
<file>./phpBB/includes/db/oracle.php</file>
|
|
||||||
<file>./phpBB/includes/db/postgres.php</file>
|
|
||||||
<file>./phpBB/includes/db/sqlite.php</file>
|
|
||||||
<file>./phpBB/includes/search/fulltext_native.php</file>
|
<file>./phpBB/includes/search/fulltext_native.php</file>
|
||||||
<file>./phpBB/includes/search/fulltext_mysql.php</file>
|
<file>./phpBB/includes/search/fulltext_mysql.php</file>
|
||||||
<directory suffix=".php">./phpBB/includes/captcha/</directory>
|
<directory suffix=".php">./phpBB/includes/captcha/</directory>
|
||||||
|
|
56
tests/functional/notification_test.php
Normal file
56
tests/functional/notification_test.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @package testing
|
||||||
|
* @copyright (c) 2013 phpBB Group
|
||||||
|
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @group functional
|
||||||
|
*/
|
||||||
|
class phpbb_functional_notification_test extends phpbb_functional_test_case
|
||||||
|
{
|
||||||
|
static public function user_subscription_data()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
// Rows inserted by phpBB/install/schemas/schema_data.sql
|
||||||
|
// Also see PHPBB3-11460
|
||||||
|
array('post_notification', true),
|
||||||
|
array('topic_notification', true),
|
||||||
|
array('post_email', true),
|
||||||
|
array('topic_email', true),
|
||||||
|
|
||||||
|
// Default behaviour for in-board notifications:
|
||||||
|
// If user did not opt-out, in-board notifications are on.
|
||||||
|
array('bookmark_notification', true),
|
||||||
|
array('quote_notification', true),
|
||||||
|
|
||||||
|
// Default behaviour for email notifications:
|
||||||
|
// If user did not opt-in, email notifications are off.
|
||||||
|
array('bookmark_email', false),
|
||||||
|
array('quote_email', false),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider user_subscription_data
|
||||||
|
*/
|
||||||
|
public function test_user_subscriptions($checkbox_name, $expected_status)
|
||||||
|
{
|
||||||
|
$this->login();
|
||||||
|
$crawler = $this->request('GET', 'ucp.php?i=ucp_notifications&mode=notification_options');
|
||||||
|
$this->assert_response_success();
|
||||||
|
|
||||||
|
$cplist = $crawler->filter('.cplist');
|
||||||
|
if ($expected_status)
|
||||||
|
{
|
||||||
|
$this->assert_checkbox_is_checked($cplist, $checkbox_name);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->assert_checkbox_is_unchecked($cplist, $checkbox_name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -196,12 +196,12 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
$parseURL = parse_url(self::$config['phpbb_functional_url']);
|
$parseURL = parse_url(self::$config['phpbb_functional_url']);
|
||||||
|
|
||||||
$data = array_merge($data, array(
|
$data = array_merge($data, array(
|
||||||
'email_enable' => false,
|
'email_enable' => true,
|
||||||
'smtp_delivery' => false,
|
'smtp_delivery' => true,
|
||||||
'smtp_host' => '',
|
'smtp_host' => 'nxdomain.phpbb.com',
|
||||||
'smtp_auth' => '',
|
'smtp_auth' => '',
|
||||||
'smtp_user' => '',
|
'smtp_user' => 'nxuser',
|
||||||
'smtp_pass' => '',
|
'smtp_pass' => 'nxpass',
|
||||||
'cookie_secure' => false,
|
'cookie_secure' => false,
|
||||||
'force_server_vars' => false,
|
'force_server_vars' => false,
|
||||||
'server_protocol' => $parseURL['scheme'] . '://',
|
'server_protocol' => $parseURL['scheme'] . '://',
|
||||||
|
@ -463,4 +463,68 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
$this->assertGreaterThan(0, count($nodes), $msg);
|
$this->assertGreaterThan(0, count($nodes), $msg);
|
||||||
return $nodes;
|
return $nodes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that exactly one checkbox with name $name exists within the scope
|
||||||
|
* of $crawler and that the checkbox is checked.
|
||||||
|
*
|
||||||
|
* @param Symfony\Component\DomCrawler\Crawler $crawler
|
||||||
|
* @param string $name
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function assert_checkbox_is_checked($crawler, $name, $message = '')
|
||||||
|
{
|
||||||
|
$this->assertSame(
|
||||||
|
'checked',
|
||||||
|
$this->assert_find_one_checkbox($crawler, $name)->attr('checked'),
|
||||||
|
$message ?: "Failed asserting that checkbox $name is checked."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Asserts that exactly one checkbox with name $name exists within the scope
|
||||||
|
* of $crawler and that the checkbox is unchecked.
|
||||||
|
*
|
||||||
|
* @param Symfony\Component\DomCrawler\Crawler $crawler
|
||||||
|
* @param string $name
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
|
public function assert_checkbox_is_unchecked($crawler, $name, $message = '')
|
||||||
|
{
|
||||||
|
$this->assertSame(
|
||||||
|
'',
|
||||||
|
$this->assert_find_one_checkbox($crawler, $name)->attr('checked'),
|
||||||
|
$message ?: "Failed asserting that checkbox $name is unchecked."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for an input element of type checkbox with the name $name using
|
||||||
|
* $crawler. Contains an assertion that only one such checkbox exists within
|
||||||
|
* the scope of $crawler.
|
||||||
|
*
|
||||||
|
* @param Symfony\Component\DomCrawler\Crawler $crawler
|
||||||
|
* @param string $name
|
||||||
|
* @param string $message
|
||||||
|
*
|
||||||
|
* @return Symfony\Component\DomCrawler\Crawler
|
||||||
|
*/
|
||||||
|
public function assert_find_one_checkbox($crawler, $name, $message = '')
|
||||||
|
{
|
||||||
|
$query = sprintf('//input[@type="checkbox" and @name="%s"]', $name);
|
||||||
|
$result = $crawler->filterXPath($query);
|
||||||
|
|
||||||
|
$this->assertEquals(
|
||||||
|
1,
|
||||||
|
sizeof($result),
|
||||||
|
$message ?: 'Failed asserting that exactly one checkbox with name' .
|
||||||
|
" $name exists in crawler scope."
|
||||||
|
);
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue