From 1ac94699e456e8358ab88a0eec959f21333cb687 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Tue, 19 Mar 2013 19:25:34 +0100 Subject: [PATCH 1/8] [ticket/11460] Drop incorrect phpbb_notification_{type,method}_ prefix. PHPBB3-11460 --- phpBB/install/schemas/schema_data.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index f118d330ba..c25925a9c8 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.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'); # 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('phpbb_notification_type_post', 0, 2, 'phpbb_notification_method_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('phpbb_notification_type_topic', 0, 2, 'phpbb_notification_method_email'); +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('post', 0, 2, 'email'); +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('topic', 0, 2, 'email'); # POSTGRES COMMIT # From 15aec0bbb24be10da850f78d85a3d10880c6f28a Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 21 Mar 2013 03:07:50 +0100 Subject: [PATCH 2/8] [ticket/11460] Add methods for checkbox handling to phpbb_functional_test_case. PHPBB3-11460 --- .../phpbb_functional_test_case.php | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 887dfea3b5..a62f5341ca 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -463,4 +463,68 @@ class phpbb_functional_test_case extends phpbb_test_case $this->assertGreaterThan(0, count($nodes), $msg); 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; + } } From 69df6b49db73d1a475d0b410f38fb4efb56d7451 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Thu, 21 Mar 2013 03:08:15 +0100 Subject: [PATCH 3/8] [ticket/11460] Add test for whether post_email and topic_email are checked. PHPBB3-11460 --- tests/functional/notification_test.php | 46 ++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 tests/functional/notification_test.php diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php new file mode 100644 index 0000000000..519fb8152b --- /dev/null +++ b/tests/functional/notification_test.php @@ -0,0 +1,46 @@ +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); + } + } +} From 02817158fc4209b57893eaba107f732274835fa7 Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Fri, 22 Mar 2013 22:42:05 +0100 Subject: [PATCH 4/8] [ticket/11460] Configure functional test board email using dummy SMTP data. PHPBB3-11460 --- tests/test_framework/phpbb_functional_test_case.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a62f5341ca..a411d9c98a 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -196,12 +196,12 @@ class phpbb_functional_test_case extends phpbb_test_case $parseURL = parse_url(self::$config['phpbb_functional_url']); $data = array_merge($data, array( - 'email_enable' => false, - 'smtp_delivery' => false, - 'smtp_host' => '', - 'smtp_auth' => '', - 'smtp_user' => '', - 'smtp_pass' => '', + 'email_enable' => true, + 'smtp_delivery' => true, + 'smtp_host' => 'nxdomain.phpbb.com', + 'smtp_auth' => '', + 'smtp_user' => 'nxuser', + 'smtp_pass' => 'nxpass', 'cookie_secure' => false, 'force_server_vars' => false, 'server_protocol' => $parseURL['scheme'] . '://', From d3decaeedff926f2945285b713e85c09c3de9daf Mon Sep 17 00:00:00 2001 From: Andreas Fischer Date: Sun, 24 Mar 2013 23:42:13 +0100 Subject: [PATCH 5/8] [ticket/11460] Add default behaviour tests for notification and email types. PHPBB3-11460 --- tests/functional/notification_test.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index 519fb8152b..ec495da602 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -15,12 +15,22 @@ 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), - - // PHPBB3-11460 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), ); } From 6dddc22ec7241cdf32cd28788ff04fb296648203 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 26 Mar 2013 17:07:20 -0400 Subject: [PATCH 6/8] [ticket/11448] Use of $user_id parameter to mark a user's notifications read Currently, the $user_id is a parameter but is not used. This patch fixes that. PHPBB3-11448 --- phpBB/includes/notification/manager.php | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/includes/notification/manager.php b/phpBB/includes/notification/manager.php index ff83d4bb37..4e26234390 100644 --- a/phpBB/includes/notification/manager.php +++ b/phpBB/includes/notification/manager.php @@ -256,6 +256,7 @@ class phpbb_notification_manager SET notification_read = 1 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) . "'") : '') . + (($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) : ''); $this->db->sql_query($sql); } From 6ab9ef54a20670b4620850b9aa62740470936f43 Mon Sep 17 00:00:00 2001 From: David King Date: Tue, 26 Mar 2013 17:21:35 -0400 Subject: [PATCH 7/8] [ticket/11466] Remove old database driver files from PHPUnit exclude As per the ticket comments, these can simply be removed, rather than having to be renamed to the new file locations. PHPBB3-11466 --- phpunit.xml.all | 9 --------- phpunit.xml.dist | 9 --------- phpunit.xml.functional | 9 --------- 3 files changed, 27 deletions(-) diff --git a/phpunit.xml.all b/phpunit.xml.all index fde3bbb1a7..3639843771 100644 --- a/phpunit.xml.all +++ b/phpunit.xml.all @@ -24,15 +24,6 @@ ./phpBB/includes/ - ./phpBB/includes/db/firebird.php - ./phpBB/includes/db/mysql.php - ./phpBB/includes/db/mysqli.php - ./phpBB/includes/db/mssql.php - ./phpBB/includes/db/mssql_odbc.php - ./phpBB/includes/db/mssqlnative.php - ./phpBB/includes/db/oracle.php - ./phpBB/includes/db/postgres.php - ./phpBB/includes/db/sqlite.php ./phpBB/includes/search/fulltext_native.php ./phpBB/includes/search/fulltext_mysql.php ./phpBB/includes/captcha/ diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 27dee48aac..f1cb4b9d09 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -31,15 +31,6 @@ ./phpBB/includes/ - ./phpBB/includes/db/firebird.php - ./phpBB/includes/db/mysql.php - ./phpBB/includes/db/mysqli.php - ./phpBB/includes/db/mssql.php - ./phpBB/includes/db/mssql_odbc.php - ./phpBB/includes/db/mssqlnative.php - ./phpBB/includes/db/oracle.php - ./phpBB/includes/db/postgres.php - ./phpBB/includes/db/sqlite.php ./phpBB/includes/search/fulltext_native.php ./phpBB/includes/search/fulltext_mysql.php ./phpBB/includes/captcha/ diff --git a/phpunit.xml.functional b/phpunit.xml.functional index 9facbcff8b..99f11477aa 100644 --- a/phpunit.xml.functional +++ b/phpunit.xml.functional @@ -30,15 +30,6 @@ ./phpBB/includes/ - ./phpBB/includes/db/firebird.php - ./phpBB/includes/db/mysql.php - ./phpBB/includes/db/mysqli.php - ./phpBB/includes/db/mssql.php - ./phpBB/includes/db/mssql_odbc.php - ./phpBB/includes/db/mssqlnative.php - ./phpBB/includes/db/oracle.php - ./phpBB/includes/db/postgres.php - ./phpBB/includes/db/sqlite.php ./phpBB/includes/search/fulltext_native.php ./phpBB/includes/search/fulltext_mysql.php ./phpBB/includes/captcha/ From c629b2c7b3bd8bcb836ed8d0b4e583170ede2558 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 27 Mar 2013 15:01:36 +0100 Subject: [PATCH 8/8] [ticket/11476] Remove pass-by-reference from sql_mutli_insert The method never writes to the array passed by reference. So it can be passed by value instead to avoid certain problems. PHPBB3-11476 --- phpBB/includes/db/driver/driver.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/db/driver/driver.php b/phpBB/includes/db/driver/driver.php index 8dda94bc2c..b915ee081b 100644 --- a/phpBB/includes/db/driver/driver.php +++ b/phpBB/includes/db/driver/driver.php @@ -568,12 +568,12 @@ class phpbb_db_driver * Run more than one insert statement. * * @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. * @access public */ - function sql_multi_insert($table, &$sql_ary) + function sql_multi_insert($table, $sql_ary) { if (!sizeof($sql_ary)) {