aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auth/fixtures/user.xml6
-rw-r--r--tests/auth/fixtures/user_533.xml6
-rw-r--r--tests/auth/provider_apache_test.php8
-rw-r--r--tests/content_visibility/fixtures/delete_post.xml4
-rw-r--r--tests/content_visibility/fixtures/set_post_visibility.xml8
-rw-r--r--tests/content_visibility/fixtures/set_topic_visibility.xml4
-rw-r--r--tests/controller/controller_test.php18
-rw-r--r--tests/controller/ext/foo/config/routing_2.yml3
-rw-r--r--tests/controller/ext/vendor2/foo/config/routing.yml (renamed from tests/controller/ext/foo/config/routing.yml)0
-rw-r--r--tests/controller/ext/vendor2/foo/config/routing_2.yml6
-rw-r--r--tests/controller/ext/vendor2/foo/config/services.yml (renamed from tests/controller/ext/foo/config/services.yml)0
-rw-r--r--tests/controller/ext/vendor2/foo/controller.php (renamed from tests/controller/ext/foo/controller.php)0
-rw-r--r--tests/controller/helper_route_test.php128
-rw-r--r--tests/controller/helper_url_test.php119
-rw-r--r--tests/dbal/fixtures/massmail_crossjoin.xml8
-rw-r--r--tests/dbal/fixtures/three_users.xml8
-rw-r--r--tests/dbal/migration/schema.php44
-rw-r--r--tests/dbal/migrator_test.php25
-rw-r--r--tests/dbal/write_sequence_test.php2
-rw-r--r--tests/extension/manager_test.php3
-rw-r--r--tests/extension/metadata_manager_test.php3
-rw-r--r--tests/functional/download_test.php345
-rw-r--r--tests/functional/fileupload_form_test.php22
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/routing.yml12
-rw-r--r--tests/functional/fixtures/ext/foo/bar/controller/controller.php31
-rw-r--r--tests/functional/forgot_password_test.php13
-rw-r--r--tests/functional/search/mysql_test.php4
-rw-r--r--tests/functional/search/native_test.php5
-rw-r--r--tests/functional/search/postgres_test.php4
-rw-r--r--tests/functional/user_password_reset_test.php122
-rw-r--r--tests/functions/fixtures/obtain_online.xml22
-rw-r--r--tests/functions/fixtures/validate_email.xml4
-rw-r--r--tests/functions/fixtures/validate_username.xml6
-rw-r--r--tests/functions_user/fixtures/group_user_attributes.xml8
-rw-r--r--tests/log/fixtures/full_log.xml6
-rw-r--r--tests/migrator/get_schema_steps_test.php200
-rw-r--r--tests/notification/fixtures/convert.xml14
-rw-r--r--tests/notification/fixtures/group_request.xml6
-rw-r--r--tests/notification/fixtures/submit_post_bookmark.xml14
-rw-r--r--tests/notification/fixtures/submit_post_post.xml14
-rw-r--r--tests/notification/fixtures/submit_post_post_in_queue.xml18
-rw-r--r--tests/notification/fixtures/submit_post_quote.xml14
-rw-r--r--tests/pagination/config/routing.yml6
-rw-r--r--tests/pagination/pagination_test.php80
-rw-r--r--tests/pagination/templates/on_page.html4
-rw-r--r--tests/pagination/templates/pagination.html3
-rw-r--r--tests/privmsgs/fixtures/delete_user_pms.xml10
-rw-r--r--tests/profile/custom_test.php10
-rw-r--r--tests/profile/get_profile_value_test.php42
-rw-r--r--tests/search/native_test.php61
-rw-r--r--tests/security/hash_test.php2
-rw-r--r--tests/security/redirect_test.php33
-rw-r--r--tests/session/fixtures/sessions_banlist.xml4
-rw-r--r--tests/session/fixtures/sessions_empty.xml8
-rw-r--r--tests/session/fixtures/sessions_full.xml8
-rw-r--r--tests/session/fixtures/sessions_garbage.xml4
-rw-r--r--tests/session/fixtures/sessions_key.xml4
-rw-r--r--tests/template/template_test.php34
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php20
-rw-r--r--tests/tree/nestedset_forum_get_data_test.php16
-rw-r--r--tests/user/fixtures/user_loader.xml8
61 files changed, 1164 insertions, 480 deletions
diff --git a/tests/auth/fixtures/user.xml b/tests/auth/fixtures/user.xml
index 6d475930a4..77f707bab3 100644
--- a/tests/auth/fixtures/user.xml
+++ b/tests/auth/fixtures/user.xml
@@ -12,8 +12,6 @@
<column>user_login_attempts</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>foobar</value>
@@ -26,8 +24,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -41,8 +37,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/auth/fixtures/user_533.xml b/tests/auth/fixtures/user_533.xml
index c2a86ea0f9..b64f376e5b 100644
--- a/tests/auth/fixtures/user_533.xml
+++ b/tests/auth/fixtures/user_533.xml
@@ -12,8 +12,6 @@
<column>user_login_attempts</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>foobar</value>
@@ -26,8 +24,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -41,8 +37,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/auth/provider_apache_test.php b/tests/auth/provider_apache_test.php
index 1231c16a4c..23d6910843 100644
--- a/tests/auth/provider_apache_test.php
+++ b/tests/auth/provider_apache_test.php
@@ -193,15 +193,7 @@ class phpbb_auth_provider_apache_test extends phpbb_database_test_case
'user_sig' => '',
'user_sig_bbcode_uid' => '',
'user_sig_bbcode_bitfield' => '',
- 'user_from' => '',
- 'user_icq' => '',
- 'user_aim' => '',
- 'user_yim' => '',
- 'user_msnm' => '',
'user_jabber' => '',
- 'user_website' => '',
- 'user_occ' => '',
- 'user_interests' => '',
'user_actkey' => '',
'user_newpasswd' => '',
'user_form_salt' => '',
diff --git a/tests/content_visibility/fixtures/delete_post.xml b/tests/content_visibility/fixtures/delete_post.xml
index deca9c74b6..c29ad23019 100644
--- a/tests/content_visibility/fixtures/delete_post.xml
+++ b/tests/content_visibility/fixtures/delete_post.xml
@@ -151,8 +151,6 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>4</value>
@@ -160,8 +158,6 @@
<value>user 1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/content_visibility/fixtures/set_post_visibility.xml b/tests/content_visibility/fixtures/set_post_visibility.xml
index 722525deaa..5f792d0f05 100644
--- a/tests/content_visibility/fixtures/set_post_visibility.xml
+++ b/tests/content_visibility/fixtures/set_post_visibility.xml
@@ -126,8 +126,6 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>1</value>
@@ -135,8 +133,6 @@
<value>user 1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -145,8 +141,6 @@
<value>user 2</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -155,8 +149,6 @@
<value>user 3</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/content_visibility/fixtures/set_topic_visibility.xml b/tests/content_visibility/fixtures/set_topic_visibility.xml
index a875012d4f..02ab5f16fe 100644
--- a/tests/content_visibility/fixtures/set_topic_visibility.xml
+++ b/tests/content_visibility/fixtures/set_topic_visibility.xml
@@ -120,8 +120,6 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>6</value>
@@ -129,8 +127,6 @@
<value>user 1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php
index 588adbcfb1..550679ff07 100644
--- a/tests/controller/controller_test.php
+++ b/tests/controller/controller_test.php
@@ -21,20 +21,18 @@ class phpbb_controller_controller_test extends phpbb_test_case
$this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
array(
- 'foo' => array(
- 'ext_name' => 'foo',
+ 'vendor2/foo' => array(
+ 'ext_name' => 'vendor2/foo',
'ext_active' => '1',
- 'ext_path' => 'ext/foo/',
+ 'ext_path' => 'ext/vendor2/foo/',
),
));
}
public function test_provider()
{
- $provider = new \phpbb\controller\provider;
- $routes = $provider
- ->import_paths_from_finder($this->extension_manager->get_finder())
- ->find(__DIR__);
+ $provider = new \phpbb\controller\provider($this->extension_manager->get_finder());
+ $routes = $provider->find(__DIR__)->get_routes();
// This will need to be updated if any new routes are defined
$this->assertInstanceOf('Symfony\Component\Routing\Route', $routes->get('core_controller'));
@@ -52,7 +50,7 @@ class phpbb_controller_controller_test extends phpbb_test_case
$container = new ContainerBuilder();
// YamlFileLoader only uses one path at a time, so we need to loop
// through all of the ones we are using.
- foreach (array(__DIR__.'/config', __DIR__.'/ext/foo/config') as $path)
+ foreach (array(__DIR__.'/config', __DIR__ . '/ext/vendor2/foo/config') as $path)
{
$loader = new YamlFileLoader($container, new FileLocator($path));
$loader->load('services.yml');
@@ -60,9 +58,9 @@ class phpbb_controller_controller_test extends phpbb_test_case
// Autoloading classes within the tests folder does not work
// so I'll include them manually.
- if (!class_exists('foo\\controller'))
+ if (!class_exists('vendor2\\foo\\controller'))
{
- include(__DIR__.'/ext/foo/controller.php');
+ include(__DIR__ . '/ext/vendor2/foo/controller.php');
}
if (!class_exists('phpbb\\controller\\foo'))
{
diff --git a/tests/controller/ext/foo/config/routing_2.yml b/tests/controller/ext/foo/config/routing_2.yml
deleted file mode 100644
index 35fff27037..0000000000
--- a/tests/controller/ext/foo/config/routing_2.yml
+++ /dev/null
@@ -1,3 +0,0 @@
-controller2:
- pattern: /bar
- defaults: { _controller: foo.controller:handle }
diff --git a/tests/controller/ext/foo/config/routing.yml b/tests/controller/ext/vendor2/foo/config/routing.yml
index 6cc275d96d..6cc275d96d 100644
--- a/tests/controller/ext/foo/config/routing.yml
+++ b/tests/controller/ext/vendor2/foo/config/routing.yml
diff --git a/tests/controller/ext/vendor2/foo/config/routing_2.yml b/tests/controller/ext/vendor2/foo/config/routing_2.yml
new file mode 100644
index 0000000000..d987a65aea
--- /dev/null
+++ b/tests/controller/ext/vendor2/foo/config/routing_2.yml
@@ -0,0 +1,6 @@
+controller2:
+ pattern: /bar
+ defaults: { _controller: foo.controller:handle }
+controller3:
+ pattern: /bar/p-{p}
+ defaults: { _controller: foo.controller:handle }
diff --git a/tests/controller/ext/foo/config/services.yml b/tests/controller/ext/vendor2/foo/config/services.yml
index 9ed67d5bc2..9ed67d5bc2 100644
--- a/tests/controller/ext/foo/config/services.yml
+++ b/tests/controller/ext/vendor2/foo/config/services.yml
diff --git a/tests/controller/ext/foo/controller.php b/tests/controller/ext/vendor2/foo/controller.php
index ce2233b3c9..ce2233b3c9 100644
--- a/tests/controller/ext/foo/controller.php
+++ b/tests/controller/ext/vendor2/foo/controller.php
diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php
new file mode 100644
index 0000000000..5264c788c7
--- /dev/null
+++ b/tests/controller/helper_route_test.php
@@ -0,0 +1,128 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+
+class phpbb_controller_helper_route_test extends phpbb_test_case
+{
+ public function setUp()
+ {
+ global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
+ $this->user = $this->getMock('\phpbb\user');
+ $phpbb_path_helper = new \phpbb\path_helper(
+ new \phpbb\symfony_request(
+ new phpbb_mock_request()
+ ),
+ new \phpbb\filesystem(),
+ $phpbb_root_path,
+ $phpEx
+ );
+ $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
+ $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $this->config, $this->user, new \phpbb\template\context());
+
+ $finder = new \phpbb\extension\finder(
+ new phpbb_mock_extension_manager(
+ dirname(__FILE__) . '/',
+ array(
+ 'vendor2/foo' => array(
+ 'ext_name' => 'vendor2/foo',
+ 'ext_active' => '1',
+ 'ext_path' => 'ext/vendor2/foo/',
+ ),
+ )
+ ),
+ new \phpbb\filesystem(),
+ dirname(__FILE__) . '/',
+ new phpbb_mock_cache()
+ );
+ $this->provider = new \phpbb\controller\provider($finder);
+ $this->provider->find(dirname(__FILE__) . '/');
+ }
+
+ public function helper_url_data_no_rewrite()
+ {
+ return array(
+ array('controller2', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'app.php/foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'app.php/foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+
+ // Custom sid parameter
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+
+ // Testing anchors
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'app.php/foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+
+ // Anchors and custom sid
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'app.php/foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+
+ // Empty parameters should not append the &amp; or ?
+ array('controller2', array(), true, false, 'app.php/foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, 'app.php/foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, 'app.php/foo/bar/p-3', 'no params using empty array'),
+ );
+ }
+
+ /**
+ * @dataProvider helper_url_data_no_rewrite()
+ */
+ public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
+ {
+ $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $this->provider, '', 'php');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
+ }
+
+ public function helper_url_data_with_rewrite()
+ {
+ return array(
+ array('controller2', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller2', array('t' => 1, 'f' => 2), false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, false, 'foo/bar/p-3?t=1&amp;f=2', 'parameters in params-argument as array'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), false, false, 'foo/bar/p-3?t=1&f=2', 'parameters in params-argument as array'),
+
+ // Custom sid parameter
+ array('controller2', array('t' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2), false, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid', 'params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2), true, 'custom-sid', 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid', 'params-argument (array) using session_id'),
+
+ // Testing anchors
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, false, 'foo/bar?t=1&f=2#anchor', 'anchor in params-argument (array)'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar/p-3?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
+
+ // Anchors and custom sid
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller2', array('t' => 1, 'f' => 2, '#' => 'anchor'), false, 'custom-sid', 'foo/bar?t=1&f=2&sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+ array('controller3', array('p' => 3, 't' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar/p-3?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
+
+ // Empty parameters should not append the &amp; or ?
+ array('controller2', array(), true, false, 'foo/bar', 'no params using empty array'),
+ array('controller2', array(), false, false, 'foo/bar', 'no params using empty array'),
+ array('controller3', array('p' => 3), true, false, 'foo/bar/p-3', 'no params using empty array'),
+ );
+ }
+
+ /**
+ * @dataProvider helper_url_data_with_rewrite()
+ */
+ public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
+ {
+ $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
+ $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $this->provider, '', 'php');
+ $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id));
+ }
+}
diff --git a/tests/controller/helper_url_test.php b/tests/controller/helper_url_test.php
deleted file mode 100644
index 33fc6c4f1b..0000000000
--- a/tests/controller/helper_url_test.php
+++ /dev/null
@@ -1,119 +0,0 @@
-<?php
-/**
-*
-* @package testing
-* @copyright (c) 2013 phpBB Group
-* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
-*
-*/
-
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
-
-class phpbb_controller_helper_url_test extends phpbb_test_case
-{
-
- public function helper_url_data_no_rewrite()
- {
- return array(
- array('foo/bar?t=1&amp;f=2', false, true, false, 'app.php/foo/bar?t=1&amp;f=2', 'parameters in url-argument'),
- array('foo/bar', 't=1&amp;f=2', true, false, 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument using amp'),
- array('foo/bar', 't=1&f=2', false, false, 'app.php/foo/bar?t=1&f=2', 'parameters in params-argument using &'),
- array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'app.php/foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
-
- // Custom sid parameter
- array('foo/bar', 't=1&amp;f=2', true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
-
- // Testing anchors
- array('foo/bar?t=1&amp;f=2#anchor', false, true, false, 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in url-argument'),
- array('foo/bar', 't=1&amp;f=2#anchor', true, false, 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument'),
- array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'app.php/foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
-
- // Anchors and custom sid
- array('foo/bar?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
- array('foo/bar', 't=1&amp;f=2#anchor', true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
- array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'app.php/foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
-
- // Empty parameters should not append the &amp;
- array('foo/bar', false, true, false, 'app.php/foo/bar', 'no params using bool false'),
- array('foo/bar', '', true, false, 'app.php/foo/bar', 'no params using empty string'),
- array('foo/bar', array(), true, false, 'app.php/foo/bar', 'no params using empty array'),
- );
- }
-
- /**
- * @dataProvider helper_url_data_no_rewrite()
- */
- public function test_helper_url_no_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
- {
- global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
-
- $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->user = $this->getMock('\phpbb\user');
- $phpbb_path_helper = new \phpbb\path_helper(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- new \phpbb\filesystem(),
- $phpbb_root_path,
- $phpEx
- );
- $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context());
-
- // We don't use mod_rewrite in these tests
- $config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php');
- $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected);
- }
-
- public function helper_url_data_with_rewrite()
- {
- return array(
- array('foo/bar?t=1&amp;f=2', false, true, false, 'foo/bar?t=1&amp;f=2', 'parameters in url-argument'),
- array('foo/bar', 't=1&amp;f=2', true, false, 'foo/bar?t=1&amp;f=2', 'parameters in params-argument using amp'),
- array('foo/bar', 't=1&f=2', false, false, 'foo/bar?t=1&f=2', 'parameters in params-argument using &'),
- array('foo/bar', array('t' => 1, 'f' => 2), true, false, 'foo/bar?t=1&amp;f=2', 'parameters in params-argument as array'),
-
- // Custom sid parameter
- array('foo/bar', 't=1&amp;f=2', true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid', 'using session_id'),
-
- // Testing anchors
- array('foo/bar?t=1&amp;f=2#anchor', false, true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in url-argument'),
- array('foo/bar', 't=1&amp;f=2#anchor', true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument'),
- array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, false, 'foo/bar?t=1&amp;f=2#anchor', 'anchor in params-argument (array)'),
-
- // Anchors and custom sid
- array('foo/bar?t=1&amp;f=2#anchor', false, true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in url-argument using session_id'),
- array('foo/bar', 't=1&amp;f=2#anchor', true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument using session_id'),
- array('foo/bar', array('t' => 1, 'f' => 2, '#' => 'anchor'), true, 'custom-sid', 'foo/bar?t=1&amp;f=2&amp;sid=custom-sid#anchor', 'anchor in params-argument (array) using session_id'),
-
- // Empty parameters should not append the &amp;
- array('foo/bar', false, true, false, 'foo/bar', 'no params using bool false'),
- array('foo/bar', '', true, false, 'foo/bar', 'no params using empty string'),
- array('foo/bar', array(), true, false, 'foo/bar', 'no params using empty array'),
- );
- }
-
- /**
- * @dataProvider helper_url_data_with_rewrite()
- */
- public function test_helper_url_with_rewrite($route, $params, $is_amp, $session_id, $expected, $description)
- {
- global $phpbb_dispatcher, $phpbb_root_path, $phpEx;
-
- $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->user = $this->getMock('\phpbb\user');
- $phpbb_path_helper = new \phpbb\path_helper(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- new \phpbb\filesystem(),
- $phpbb_root_path,
- $phpEx
- );
- $this->template = new \phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context());
-
- $config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
- $helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php');
- $this->assertEquals($helper->url($route, $params, $is_amp, $session_id), $expected);
- }
-}
diff --git a/tests/dbal/fixtures/massmail_crossjoin.xml b/tests/dbal/fixtures/massmail_crossjoin.xml
index ef0a2b7149..1050ba067e 100644
--- a/tests/dbal/fixtures/massmail_crossjoin.xml
+++ b/tests/dbal/fixtures/massmail_crossjoin.xml
@@ -14,16 +14,12 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>mass email</value>
<value>mass email</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -31,8 +27,6 @@
<value>banned</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -40,8 +34,6 @@
<value>not in group</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_group">
diff --git a/tests/dbal/fixtures/three_users.xml b/tests/dbal/fixtures/three_users.xml
index a50e3e8634..a601e539e1 100644
--- a/tests/dbal/fixtures/three_users.xml
+++ b/tests/dbal/fixtures/three_users.xml
@@ -5,31 +5,23 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>barfoo</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
<value>foobar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>bertie</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/dbal/migration/schema.php b/tests/dbal/migration/schema.php
new file mode 100644
index 0000000000..98407eb1bd
--- /dev/null
+++ b/tests/dbal/migration/schema.php
@@ -0,0 +1,44 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-license.php GNU Public License
+*
+*/
+
+class phpbb_dbal_migration_schema extends \phpbb\db\migration\migration
+{
+ function update_schema()
+ {
+ return array(
+ 'add_columns' => array(
+ $this->table_prefix . 'config' => array(
+ 'test_column1' => array('BOOL', 1),
+ ),
+ ),
+ 'add_tables' => array(
+ $this->table_prefix . 'foobar' => array(
+ 'COLUMNS' => array(
+ 'module_id' => array('UINT:3', NULL, 'auto_increment'),
+ ),
+ 'PRIMARY_KEY' => 'module_id',
+ ),
+ ),
+ );
+ }
+
+ function revert_schema()
+ {
+ return array(
+ 'drop_columns' => array(
+ $this->table_prefix . 'config' => array(
+ 'test_column1',
+ ),
+ ),
+ 'drop_tables' => array(
+ $this->table_prefix . 'foobar',
+ ),
+ );
+ }
+}
diff --git a/tests/dbal/migrator_test.php b/tests/dbal/migrator_test.php
index c6b4c289d3..f22f5f5b30 100644
--- a/tests/dbal/migrator_test.php
+++ b/tests/dbal/migrator_test.php
@@ -16,6 +16,7 @@ require_once dirname(__FILE__) . '/migration/revert.php';
require_once dirname(__FILE__) . '/migration/revert_with_dependency.php';
require_once dirname(__FILE__) . '/migration/fail.php';
require_once dirname(__FILE__) . '/migration/installed.php';
+require_once dirname(__FILE__) . '/migration/schema.php';
class phpbb_dbal_migrator_test extends phpbb_database_test_case
{
@@ -49,7 +50,8 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
dirname(__FILE__) . '/../../phpBB/',
'php',
'phpbb_',
- $tools
+ $tools,
+ new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
@@ -267,4 +269,25 @@ class phpbb_dbal_migrator_test extends phpbb_database_test_case
$this->fail('Installed test failed');
}
}
+
+ public function test_schema()
+ {
+ $this->migrator->set_migrations(array('phpbb_dbal_migration_schema'));
+
+ while (!$this->migrator->finished())
+ {
+ $this->migrator->update();
+ }
+
+ $this->assertTrue($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
+ $this->assertTrue($this->db_tools->sql_table_exists('phpbb_foobar'));
+
+ while ($this->migrator->migration_state('phpbb_dbal_migration_schema'))
+ {
+ $this->migrator->revert('phpbb_dbal_migration_schema');
+ }
+
+ $this->assertFalse($this->db_tools->sql_column_exists('phpbb_config', 'test_column1'));
+ $this->assertFalse($this->db_tools->sql_table_exists('phpbb_foobar'));
+ }
}
diff --git a/tests/dbal/write_sequence_test.php b/tests/dbal/write_sequence_test.php
index f382a971a5..5fe0fe8de9 100644
--- a/tests/dbal/write_sequence_test.php
+++ b/tests/dbal/write_sequence_test.php
@@ -42,8 +42,6 @@ class phpbb_dbal_write_sequence_test extends phpbb_database_test_case
'username_clean' => $username,
'user_permissions' => '',
'user_sig' => '',
- 'user_occ' => '',
- 'user_interests' => '',
));
$db->sql_query($sql);
diff --git a/tests/extension/manager_test.php b/tests/extension/manager_test.php
index cc32a6af4e..789dc20d14 100644
--- a/tests/extension/manager_test.php
+++ b/tests/extension/manager_test.php
@@ -106,7 +106,8 @@ class phpbb_extension_manager_test extends phpbb_database_test_case
$phpbb_root_path,
$php_ext,
$table_prefix,
- array()
+ array(),
+ new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
diff --git a/tests/extension/metadata_manager_test.php b/tests/extension/metadata_manager_test.php
index 592421f9e7..a3c4cc89e9 100644
--- a/tests/extension/metadata_manager_test.php
+++ b/tests/extension/metadata_manager_test.php
@@ -62,7 +62,8 @@ class phpbb_extension_metadata_manager_test extends phpbb_database_test_case
$this->phpbb_root_path,
'php',
$this->table_prefix,
- array()
+ array(),
+ new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
new file mode 100644
index 0000000000..24366992d5
--- /dev/null
+++ b/tests/functional/download_test.php
@@ -0,0 +1,345 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_posting.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/utf/utf_tools.php';
+
+/**
+* @group functional
+*/
+class phpbb_functional_download_test extends phpbb_functional_test_case
+{
+ protected $data = array();
+
+ public function test_setup_forums()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}");
+ $form = $crawler->selectButton('addforum')->form(array(
+ 'forum_name' => 'Download #1',
+ ));
+ $crawler = self::submit($form);
+ $form = $crawler->selectButton('update')->form(array(
+ 'forum_perm_from' => 2,
+ ));
+ $crawler = self::submit($form);
+ }
+
+ public function test_create_post()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Download #1',
+ ),
+ ));
+
+ // Test creating topic
+ $post = $this->create_topic($this->data['forums']['Download #1'], 'Download Topic #1', 'This is a test topic posted by the testing framework.', array('upload_files' => 1));
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+
+ $this->assertContains('Download Topic #1', $crawler->filter('html')->text());
+ $this->data['topics']['Download Topic #1'] = (int) $post['topic_id'];
+ $this->data['posts']['Download Topic #1'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
+
+ // Test creating a reply
+ $post2 = $this->create_post($this->data['forums']['Download #1'], $post['topic_id'], 'Re: Download Topic #1-#2', 'This is a test post posted by the testing framework.', array('upload_files' => 1));
+ $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+
+ $this->assertContains('Re: Download Topic #1-#2', $crawler->filter('html')->text());
+ $this->data['posts']['Re: Download Topic #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
+ }
+
+ public function test_download_accessible()
+ {
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Download #1',
+ ),
+ 'topics' => array(
+ 'Download Topic #1',
+ ),
+ 'posts' => array(
+ 'Download Topic #1',
+ 'Re: Download Topic #1-#2',
+ ),
+ 'attachments' => true,
+ ));
+
+ // Download topic archive as guest
+ $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // Download post archive as guest
+ $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // Download attachment as guest
+ $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('image/jpeg', $finfo->buffer($content));
+ }
+
+ public function test_softdelete_post()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Download #1',
+ ),
+ 'topics' => array(
+ 'Download Topic #1',
+ ),
+ 'posts' => array(
+ 'Download Topic #1',
+ 'Re: Download Topic #1-#2',
+ ),
+ ));
+ $this->add_lang('posting');
+
+ $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Download #1']}&p={$this->data['posts']['Re: Download Topic #1-#2']}&sid={$this->sid}");
+ $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
+
+ $form = $crawler->selectButton('Yes')->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('POST_DELETED', $crawler->text());
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}");
+ $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text());
+ }
+
+ public function test_download_softdeleted_post()
+ {
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Download #1',
+ ),
+ 'topics' => array(
+ 'Download Topic #1',
+ ),
+ 'posts' => array(
+ 'Download Topic #1',
+ 'Re: Download Topic #1-#2',
+ ),
+ 'attachments' => true,
+ ));
+ $this->add_lang('viewtopic');
+
+ // Download topic archive as guest: still works
+ $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // No download post archive as guest
+ $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
+ self::assert_response_html(404);
+ $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
+
+ // No download attachment as guest
+ $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
+ self::assert_response_html(404);
+ $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
+
+ // Login as admin and try again, should work now.
+ $this->login();
+
+ // Download topic archive as admin
+ $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // Download post archive as admin
+ $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // Download attachment as admin
+ $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('image/jpeg', $finfo->buffer($content));
+ }
+
+ public function test_softdelete_topic()
+ {
+ $this->login();
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Download #1',
+ ),
+ 'topics' => array(
+ 'Download Topic #1',
+ ),
+ 'posts' => array(
+ 'Download Topic #1',
+ 'Re: Download Topic #1-#2',
+ ),
+ ));
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}");
+
+ $this->add_lang('posting');
+ $form = $crawler->selectButton('Go')->eq(2)->form();
+ $form['action']->select('delete_topic');
+ $crawler = self::submit($form);
+ $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text());
+
+ $this->add_lang('mcp');
+ $form = $crawler->selectButton('Yes')->form();
+ $crawler = self::submit($form);
+ $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text());
+
+ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&sid={$this->sid}");
+ $this->assertContains('Download Topic #1', $crawler->filter('h2')->text());
+ }
+
+ public function test_download_softdeleted_topic()
+ {
+ $this->load_ids(array(
+ 'forums' => array(
+ 'Download #1',
+ ),
+ 'topics' => array(
+ 'Download Topic #1',
+ ),
+ 'posts' => array(
+ 'Download Topic #1',
+ 'Re: Download Topic #1-#2',
+ ),
+ 'attachments' => true,
+ ));
+ $this->add_lang('viewtopic');
+
+ // Download topic archive as guest: still works
+ $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
+ self::assert_response_html(404);
+ $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
+
+ // No download post archive as guest
+ $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
+ self::assert_response_html(404);
+ $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
+
+ // No download attachment as guest
+ $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
+ self::assert_response_html(404);
+ $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text());
+
+ // Login as admin and try again, should work now.
+ $this->login();
+
+ // Download topic archive as admin
+ $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // Download post archive as admin
+ $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('application/zip', $finfo->buffer($content));
+
+ // Download attachment as admin
+ $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false);
+ self::assert_response_status_code(200);
+ $content = self::$client->getResponse()->getContent();
+ $finfo = new finfo(FILEINFO_MIME_TYPE);
+ self::assertEquals('image/jpeg', $finfo->buffer($content));
+ }
+
+ public function load_ids($data)
+ {
+ $this->db = $this->get_db();
+
+ if (!empty($data['forums']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_forums
+ WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['forum_name'], $data['forums']))
+ {
+ $this->data['forums'][$row['forum_name']] = (int) $row['forum_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ if (!empty($data['topics']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_topics
+ WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['topic_title'], $data['topics']))
+ {
+ $this->data['topics'][$row['topic_title']] = (int) $row['topic_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+ }
+
+ $post_ids = array();
+ if (!empty($data['posts']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_posts
+ WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ if (in_array($row['post_subject'], $data['posts']))
+ {
+ $this->data['posts'][$row['post_subject']] = (int) $row['post_id'];
+ $post_ids[] = (int) $row['post_id'];
+ }
+ }
+ $this->db->sql_freeresult($result);
+
+ if (isset($data['attachments']))
+ {
+ $sql = 'SELECT *
+ FROM phpbb_attachments
+ WHERE in_message = 0 AND ' . $this->db->sql_in_set('post_msg_id', $post_ids);
+ $result = $this->db->sql_query($sql);
+ while ($row = $this->db->sql_fetchrow($result))
+ {
+ $this->data['attachments'][(int) $row['post_msg_id']] = (int) $row['attach_id'];
+ }
+ $this->db->sql_freeresult($result);
+ }
+ }
+ }
+}
diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php
index ad01d7b2df..c291712c71 100644
--- a/tests/functional/fileupload_form_test.php
+++ b/tests/functional/fileupload_form_test.php
@@ -19,7 +19,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
parent::setUp();
$this->path = __DIR__ . '/fixtures/files/';
$this->add_lang('posting');
- $this->login();
}
public function tearDown()
@@ -63,30 +62,39 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
public function test_empty_file()
{
- $this->markTestIncomplete('Test fails intermittently.');
+ $this->login();
+
$crawler = $this->upload_file('empty.png', 'image/png');
- $this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $this->assert_filter($crawler, 'div#message p')->text());
+ $this->assertEquals($this->lang('EMPTY_FILEUPLOAD'), $crawler->filter('p.error')->text());
}
public function test_invalid_extension()
{
+ $this->login();
+
$crawler = $this->upload_file('illegal-extension.bif', 'application/octet-stream');
$this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text());
}
public function test_too_large()
{
- $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.');
+ $this->create_user('fileupload');
+ $this->login('fileupload');
+
$crawler = $this->upload_file('too-large.png', 'image/png');
$this->assertEquals($this->lang('WRONG_FILESIZE', '256', 'KiB'), $crawler->filter('p.error')->text());
}
public function test_valid_file()
{
- $this->markTestIncomplete('Test fails intermittently.');
+ $this->login();
+
$crawler = $this->upload_file('valid.jpg', 'image/jpeg');
- // ensure there was no error message rendered
+
+ // Ensure there was no error message rendered
$this->assertNotContains('<h2>' . $this->lang('INFORMATION') . '</h2>', $this->get_content());
- $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text());
+
+ // Also the file name should be in the first row of the files table
+ $this->assertEquals('valid.jpg', $crawler->filter('span.file-name')->eq(1)->text());
}
}
diff --git a/tests/functional/fixtures/ext/foo/bar/config/routing.yml b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
index 9b1ce3cfd7..d4d256c293 100644
--- a/tests/functional/fixtures/ext/foo/bar/config/routing.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/routing.yml
@@ -17,3 +17,15 @@ foo_exception_controller:
foo_redirect_controller:
pattern: /foo/redirect
defaults: { _controller: foo_bar.controller:redirect }
+
+foo_index_controller:
+ pattern: /index
+ defaults: { _controller: foo_bar.controller:redirect }
+
+foo_tests_index_controller:
+ pattern: /tests/index
+ defaults: { _controller: foo_bar.controller:redirect }
+
+foo_tests_dotdot_index_controller:
+ pattern: /tests/../index
+ defaults: { _controller: foo_bar.controller:redirect }
diff --git a/tests/functional/fixtures/ext/foo/bar/controller/controller.php b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
index 558b202948..45246f8a97 100644
--- a/tests/functional/fixtures/ext/foo/bar/controller/controller.php
+++ b/tests/functional/fixtures/ext/foo/bar/controller/controller.php
@@ -63,40 +63,19 @@ class controller
'tests/index.php',
),
array(
- $this->helper->url('index'),
+ $this->helper->route('foo_index_controller'),
$rewrite_prefix . 'index',
),
array(
- $this->helper->url('tests/index'),
+ $this->helper->route('foo_tests_index_controller'),
$rewrite_prefix . 'tests/index',
),
+ /**
+ * Symfony does not allow /../ in routes
array(
- $this->helper->url('tests/../index'),
+ $this->helper->route('foo_tests_dotdot_index_controller'),
$rewrite_prefix . 'index',
),
- /*
- // helper URLs starting with ../ are prone to failure.
- // Do not test them right now.
- array(
- $this->helper->url('../index'),
- '../index',
- ),
- array(
- $this->helper->url('../../index'),
- '../index',
- ),
- array(
- $this->helper->url('../tests/index'),
- $rewrite_prefix . '../tests/index',
- ),
- array(
- $this->helper->url('../tests/../index'),
- '../index',
- ),
- array(
- $this->helper->url('../../tests/index'),
- '../tests/index',
- ),
*/
);
diff --git a/tests/functional/forgot_password_test.php b/tests/functional/forgot_password_test.php
index 906224efbb..3b6fd15d02 100644
--- a/tests/functional/forgot_password_test.php
+++ b/tests/functional/forgot_password_test.php
@@ -41,4 +41,17 @@ class phpbb_functional_forgot_password_test extends phpbb_functional_test_case
}
+ public function tearDown()
+ {
+ $this->login();
+ $this->admin_login();
+
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=security');
+
+ // Enable allow_password_reset again after test
+ $form = $crawler->selectButton('Submit')->form(array(
+ 'config[allow_password_reset]' => 1,
+ ));
+ $crawler = self::submit($form);
+ }
}
diff --git a/tests/functional/search/mysql_test.php b/tests/functional/search/mysql_test.php
index 7af8051417..52a7b14f40 100644
--- a/tests/functional/search/mysql_test.php
+++ b/tests/functional/search/mysql_test.php
@@ -16,8 +16,4 @@ class phpbb_functional_search_mysql_test extends phpbb_functional_search_base
{
protected $search_backend = '\phpbb\search\fulltext_mysql';
- protected function assert_search_not_found($keywords)
- {
- $this->markTestIncomplete('MySQL search when fails doesn\'t show the search query');
- }
}
diff --git a/tests/functional/search/native_test.php b/tests/functional/search/native_test.php
index ce568df616..512c6f2830 100644
--- a/tests/functional/search/native_test.php
+++ b/tests/functional/search/native_test.php
@@ -15,9 +15,4 @@ require_once dirname(__FILE__) . '/base.php';
class phpbb_functional_search_native_test extends phpbb_functional_search_base
{
protected $search_backend = '\phpbb\search\fulltext_native';
-
- protected function assert_search_not_found($keywords)
- {
- $this->markTestIncomplete('Native search when fails doesn\'t show the search query');
- }
}
diff --git a/tests/functional/search/postgres_test.php b/tests/functional/search/postgres_test.php
index 487b8aeebb..974b417659 100644
--- a/tests/functional/search/postgres_test.php
+++ b/tests/functional/search/postgres_test.php
@@ -16,8 +16,4 @@ class phpbb_functional_search_postgres_test extends phpbb_functional_search_base
{
protected $search_backend = '\phpbb\search\fulltext_postgres';
- protected function assert_search_not_found($keywords)
- {
- $this->markTestIncomplete('Postgres search when fails doesn\'t show the search query');
- }
}
diff --git a/tests/functional/user_password_reset_test.php b/tests/functional/user_password_reset_test.php
new file mode 100644
index 0000000000..65222c1aa6
--- /dev/null
+++ b/tests/functional/user_password_reset_test.php
@@ -0,0 +1,122 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_user_password_reset_test extends phpbb_functional_test_case
+{
+ protected $user_data;
+
+ public function test_password_reset()
+ {
+ $this->add_lang('ucp');
+ $user_id = $this->create_user('reset-password-test-user');
+
+ $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form(array(
+ 'username' => 'reset-password-test-user',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('NO_EMAIL_USER', $crawler->text());
+
+ $crawler = self::request('GET', "ucp.php?mode=sendpassword&sid={$this->sid}");
+ $form = $crawler->selectButton('submit')->form(array(
+ 'username' => 'reset-password-test-user',
+ 'email' => 'nobody@example.com',
+ ));
+ $crawler = self::submit($form);
+ $this->assertContainsLang('PASSWORD_UPDATED', $crawler->text());
+
+ // Check if columns in database were updated for password reset
+ $this->get_user_data();
+ $this->assertNotNull($this->user_data['user_actkey']);
+ $this->assertNotNull($this->user_data['user_newpasswd']);
+
+ // Make sure we know the password
+ $db = $this->get_db();
+ $this->passwords_manager = $this->get_passwords_manager();
+ $sql = 'UPDATE ' . USERS_TABLE . "
+ SET user_newpasswd = '" . $db->sql_escape($this->passwords_manager->hash('reset-password-test-user')) . "'
+ WHERE user_id = " . $user_id;
+ $db->sql_query($sql);
+ }
+
+ public function test_login_after_reset()
+ {
+ $this->login('reset-password-test-user');
+ }
+
+ public function data_activate_new_password()
+ {
+ return array(
+ array('WRONG_ACTIVATION', false, 'FOOBAR'),
+ array('ALREADY_ACTIVATED', 2, 'FOOBAR'),
+ array('PASSWORD_ACTIVATED', false, false),
+ array('ALREADY_ACTIVATED', false, false),
+ );
+ }
+
+ /**
+ * @dataProvider data_activate_new_password
+ */
+ public function test_activate_new_password($expected, $user_id, $act_key)
+ {
+ $this->add_lang('ucp');
+ $this->get_user_data();
+ $user_id = (!$user_id) ? $this->user_data['user_id'] : $user_id;
+ $act_key = (!$act_key) ? $this->user_data['user_actkey'] : $act_key;
+
+ $crawler = self::request('GET', "ucp.php?mode=activate&u=$user_id&k=$act_key&sid={$this->sid}");
+ $this->assertContainsLang($expected, $crawler->text());
+ }
+
+ public function test_login()
+ {
+ $this->add_lang('ucp');
+ $crawler = self::request('GET', 'ucp.php');
+ $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
+
+ $form = $crawler->selectButton($this->lang('LOGIN'))->form();
+ $crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-user'));
+ $this->assertNotContains($this->lang('LOGIN'), $crawler->filter('.navbar')->text());
+
+ $cookies = self::$cookieJar->all();
+
+ // The session id is stored in a cookie that ends with _sid - we assume there is only one such cookie
+ foreach ($cookies as $cookie);
+ {
+ if (substr($cookie->getName(), -4) == '_sid')
+ {
+ $this->sid = $cookie->getValue();
+ }
+ }
+
+ $this->logout();
+
+ $crawler = self::request('GET', 'ucp.php');
+ $this->assertContains($this->lang('LOGIN_EXPLAIN_UCP'), $crawler->filter('html')->text());
+
+ $form = $crawler->selectButton($this->lang('LOGIN'))->form();
+ // Try logging in with the old password
+ $crawler = self::submit($form, array('username' => 'reset-password-test-user', 'password' => 'reset-password-test-userreset-password-test-user'));
+ $this->assertContains($this->lang('LOGIN_ERROR_PASSWORD', '', ''), $crawler->filter('html')->text());
+ }
+
+ protected function get_user_data()
+ {
+ $db = $this->get_db();
+ $sql = 'SELECT user_id, username, user_type, user_email, user_newpasswd, user_lang, user_notify_type, user_actkey, user_inactive_reason
+ FROM ' . USERS_TABLE . "
+ WHERE username = 'reset-password-test-user'";
+ $result = $db->sql_query($sql);
+ $this->user_data = $db->sql_fetchrow($result);
+ $db->sql_freeresult($result);
+ }
+}
diff --git a/tests/functions/fixtures/obtain_online.xml b/tests/functions/fixtures/obtain_online.xml
index 05bbe6a05e..14621a3287 100644
--- a/tests/functions/fixtures/obtain_online.xml
+++ b/tests/functions/fixtures/obtain_online.xml
@@ -15,8 +15,6 @@
<column>user_allow_viewonline</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>anonymous</value>
@@ -24,8 +22,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -34,8 +30,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -44,8 +38,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
@@ -54,8 +46,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
@@ -64,8 +54,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>6</value>
@@ -74,8 +62,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>7</value>
@@ -84,8 +70,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>8</value>
@@ -94,8 +78,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>9</value>
@@ -104,8 +86,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>10</value>
@@ -114,8 +94,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/functions/fixtures/validate_email.xml b/tests/functions/fixtures/validate_email.xml
index de7fce8a08..eb4fd90217 100644
--- a/tests/functions/fixtures/validate_email.xml
+++ b/tests/functions/fixtures/validate_email.xml
@@ -6,8 +6,6 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<column>user_email_hash</column>
<row>
<value>1</value>
@@ -15,8 +13,6 @@
<value>admin</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
<value>143317126117</value>
</row>
</table>
diff --git a/tests/functions/fixtures/validate_username.xml b/tests/functions/fixtures/validate_username.xml
index fbe398469c..1b85a2f06d 100644
--- a/tests/functions/fixtures/validate_username.xml
+++ b/tests/functions/fixtures/validate_username.xml
@@ -14,16 +14,12 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>admin</value>
<value>admin</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -31,8 +27,6 @@
<value>moderator</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/functions_user/fixtures/group_user_attributes.xml b/tests/functions_user/fixtures/group_user_attributes.xml
index f4edbdca49..9b1f1f504b 100644
--- a/tests/functions_user/fixtures/group_user_attributes.xml
+++ b/tests/functions_user/fixtures/group_user_attributes.xml
@@ -32,8 +32,6 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>1</value>
@@ -42,8 +40,6 @@
<value>barfoo</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -53,8 +49,6 @@
<value>foobar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -64,8 +58,6 @@
<value>bertie</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_group">
diff --git a/tests/log/fixtures/full_log.xml b/tests/log/fixtures/full_log.xml
index 2ce2643d26..a10c224e0e 100644
--- a/tests/log/fixtures/full_log.xml
+++ b/tests/log/fixtures/full_log.xml
@@ -126,16 +126,12 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>Anonymous</value>
<value>Anonymous</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -143,8 +139,6 @@
<value>admin</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_topics">
diff --git a/tests/migrator/get_schema_steps_test.php b/tests/migrator/get_schema_steps_test.php
new file mode 100644
index 0000000000..226535754e
--- /dev/null
+++ b/tests/migrator/get_schema_steps_test.php
@@ -0,0 +1,200 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class get_schema_steps_test extends phpbb_test_case
+{
+ public function setUp()
+ {
+ parent::setUp();
+
+ $this->helper = new \phpbb\db\migration\helper();
+ }
+
+ public function schema_provider()
+ {
+ return array(
+ array(
+ array(
+ 'add_tables' => array(
+ 'foo' => array(
+ 'COLUMNS' => array(
+ 'foobar' => array('BOOL', 0),
+ 'foobar2' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('foobar'),
+ ),
+ 'bar' => array(
+ 'COLUMNS' => array(
+ 'barfoo' => array('BOOL', 0),
+ 'barfoor2' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('barfoo'),
+ ),
+ ),
+ 'drop_tables' => array('table1', 'table2', 'table3'),
+ 'add_index' => array(
+ 'table1' => array(
+ 'index1' => 'column1',
+ 'index2' => 'column2',
+ ),
+ 'table2' => array(
+ 'index1' => 'column1',
+ 'index2' => 'column2',
+ ),
+ ),
+ 'add_columns' => array(
+ 'table1' => array(
+ 'column1' => array('foo'),
+ 'column2' => array('bar'),
+ ),
+ ),
+ 'change_columns' => array(
+ 'table1' => array(
+ 'column1' => array('foo'),
+ 'column2' => array('bar'),
+ ),
+ ),
+ 'drop_columns' => array(
+ 'table1' => array(
+ 'column1',
+ 'column2',
+ ),
+ ),
+ 'add_unique_index' => array(
+ 'table1' => array(
+ 'index1' => 'column1',
+ 'index2' => 'column2',
+ ),
+ ),
+ 'drop_keys' => array(
+ 'table1' => array(
+ 'column1',
+ 'column2',
+ ),
+ ),
+ 'add_primary_keys' => array(
+ 'table1' => array('foo'),
+ 'table2' => array('bar'),
+ 'table3' => array('foobar'),
+ ),
+ ),
+ array(
+ array('dbtools.perform_schema_changes', array(array('drop_tables' => array('table1')))),
+ array('dbtools.perform_schema_changes', array(array('drop_tables' => array('table2')))),
+ array('dbtools.perform_schema_changes', array(array('drop_tables' => array('table3')))),
+ array('dbtools.perform_schema_changes', array(array('add_tables' => array(
+ 'foo' => array(
+ 'COLUMNS' => array(
+ 'foobar' => array('BOOL', 0),
+ 'foobar2' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('foobar'),
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_tables' => array(
+ 'bar' => array(
+ 'COLUMNS' => array(
+ 'barfoo' => array('BOOL', 0),
+ 'barfoor2' => array('BOOL', 0),
+ ),
+ 'PRIMARY_KEY' => array('barfoo'),
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('change_columns' => array(
+ 'table1' => array(
+ 'column1' => array('foo'),
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('change_columns' => array(
+ 'table1' => array(
+ 'column2' => array('bar'),
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_columns' => array(
+ 'table1' => array(
+ 'column1' => array('foo'),
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_columns' => array(
+ 'table1' => array(
+ 'column2' => array('bar'),
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('drop_keys' => array(
+ 'table1' => array(
+ 0 => 'column1',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('drop_keys' => array(
+ 'table1' => array(
+ 1 => 'column2',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('drop_columns' => array(
+ 'table1' => array(
+ 0 => 'column1',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('drop_columns' => array(
+ 'table1' => array(
+ 1 => 'column2',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_primary_keys' => array(
+ 'table1' => array('foo'),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_primary_keys' => array(
+ 'table2' => array('bar'),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_primary_keys' => array(
+ 'table3' => array('foobar'),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_unique_index' => array(
+ 'table1' => array(
+ 'index1' => 'column1',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_unique_index' => array(
+ 'table1' => array(
+ 'index2' => 'column2',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_index' => array(
+ 'table1' => array(
+ 'index1' => 'column1',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_index' => array(
+ 'table1' => array(
+ 'index2' => 'column2',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_index' => array(
+ 'table2' => array(
+ 'index1' => 'column1',
+ ),
+ )))),
+ array('dbtools.perform_schema_changes', array(array('add_index' => array(
+ 'table2' => array(
+ 'index2' => 'column2',
+ ),
+ )))),
+ ),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider schema_provider
+ */
+ public function test_get_schema_steps($schema_changes, $expected)
+ {
+ $this->assertEquals($expected, $this->helper->get_schema_steps($schema_changes));
+ }
+}
diff --git a/tests/notification/fixtures/convert.xml b/tests/notification/fixtures/convert.xml
index 3f0a065cc4..c9d8fafa97 100644
--- a/tests/notification/fixtures/convert.xml
+++ b/tests/notification/fixtures/convert.xml
@@ -8,8 +8,6 @@
<column>user_notify_pm</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>1</value>
@@ -18,8 +16,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -29,8 +25,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -40,8 +34,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
@@ -51,8 +43,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
@@ -62,8 +52,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>6</value>
@@ -73,8 +61,6 @@
<value>1</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/notification/fixtures/group_request.xml b/tests/notification/fixtures/group_request.xml
index 1eb73f1e15..fbaee0a326 100644
--- a/tests/notification/fixtures/group_request.xml
+++ b/tests/notification/fixtures/group_request.xml
@@ -6,16 +6,12 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>2</value>
<value>2</value>
<value>2</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -23,8 +19,6 @@
<value>3</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/notification/fixtures/submit_post_bookmark.xml b/tests/notification/fixtures/submit_post_bookmark.xml
index d4bf8df73f..525d0484e0 100644
--- a/tests/notification/fixtures/submit_post_bookmark.xml
+++ b/tests/notification/fixtures/submit_post_bookmark.xml
@@ -79,55 +79,41 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>2</value>
<value>poster</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>test</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
<value>unauthorized</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
<value>notified</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>6</value>
<value>disabled</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>7</value>
<value>default</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_notifications">
diff --git a/tests/notification/fixtures/submit_post_post.xml b/tests/notification/fixtures/submit_post_post.xml
index b0ffa042c5..a38ca77ea0 100644
--- a/tests/notification/fixtures/submit_post_post.xml
+++ b/tests/notification/fixtures/submit_post_post.xml
@@ -109,55 +109,41 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>2</value>
<value>poster</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>test</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
<value>unauthorized</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
<value>notified</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>6</value>
<value>disabled</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>7</value>
<value>default</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_notifications">
diff --git a/tests/notification/fixtures/submit_post_post_in_queue.xml b/tests/notification/fixtures/submit_post_post_in_queue.xml
index 090e90ea49..28cb69be36 100644
--- a/tests/notification/fixtures/submit_post_post_in_queue.xml
+++ b/tests/notification/fixtures/submit_post_post_in_queue.xml
@@ -51,71 +51,53 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>2</value>
<value>poster</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>test</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
<value>unauthorized-mod</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
<value>unauthorized-read</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>6</value>
<value>notified</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>7</value>
<value>disabled</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>8</value>
<value>default</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>9</value>
<value>test glboal-permissions</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_notifications">
diff --git a/tests/notification/fixtures/submit_post_quote.xml b/tests/notification/fixtures/submit_post_quote.xml
index f22ed97d91..2b11992e54 100644
--- a/tests/notification/fixtures/submit_post_quote.xml
+++ b/tests/notification/fixtures/submit_post_quote.xml
@@ -51,55 +51,41 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>2</value>
<value>poster</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>test</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
<value>unauthorized</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
<value>notified</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>6</value>
<value>disabled</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>7</value>
<value>default</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_user_notifications">
diff --git a/tests/pagination/config/routing.yml b/tests/pagination/config/routing.yml
new file mode 100644
index 0000000000..dd667274cd
--- /dev/null
+++ b/tests/pagination/config/routing.yml
@@ -0,0 +1,6 @@
+core_controller:
+ pattern: /test
+ defaults: { _controller: core_foo.controller:bar, page: 1}
+core_page_controller:
+ pattern: /test/page/{page}
+ defaults: { _controller: core_foo.controller:bar}
diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php
index 4e8083b47f..71206dff58 100644
--- a/tests/pagination/pagination_test.php
+++ b/tests/pagination/pagination_test.php
@@ -21,11 +21,27 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
public function setUp()
{
parent::setUp();
- $user = $this->getMock('\phpbb\user');
- $user->expects($this->any())
+
+ global $phpbb_dispatcher;
+
+ $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
+ $this->user = $this->getMock('\phpbb\user');
+ $this->user->expects($this->any())
->method('lang')
->will($this->returnCallback(array($this, 'return_callback_implode')));
- $this->pagination = new \phpbb\pagination($this->template, $user);
+
+ $this->finder = new \phpbb\extension\finder(
+ new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()),
+ new \phpbb\filesystem(),
+ dirname(__FILE__) . '/',
+ new phpbb_mock_cache()
+ );
+
+ $this->config = new \phpbb\config\config(array('enable_mod_rewrite' => '1'));
+ $provider = new \phpbb\controller\provider($this->finder);
+ $provider->find(dirname(__FILE__) . '/');
+ $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $provider, '', 'php');
+ $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper);
}
public function generate_template_pagination_data()
@@ -38,6 +54,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
10,
10,
'pagination
+ :per_page:10
+ :current_page:2
+ :base_url:page.php
:previous::page.php
:else:1:page.php
:current:2:page.php?start=10
@@ -57,6 +76,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
10,
20,
'pagination
+ :per_page:10
+ :current_page:3
+ :base_url:page.php
:previous::page.php?start=10
:else:1:page.php
:else:2:page.php?start=10
@@ -71,12 +93,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
:u_next:page.php?start=30',
),
array(
- 'test/page/%d',
- '/page/%d',
+ array('routes' => array(
+ 'core_controller',
+ 'core_page_controller',
+ )),
+ 'page',
95,
10,
10,
'pagination
+ :per_page:10
+ :current_page:2
+ :base_url:
:previous::test
:else:1:test
:current:2:test/page/2
@@ -90,12 +118,18 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
:u_next:test/page/3',
),
array(
- 'test/page/%d',
- '/page/%d',
+ array('routes' => array(
+ 'core_controller',
+ 'core_page_controller',
+ )),
+ 'page',
95,
10,
20,
'pagination
+ :per_page:10
+ :current_page:3
+ :base_url:
:previous::test/page/2
:else:1:test
:else:2:test/page/2
@@ -127,15 +161,10 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
{
return array(
array(
- 'page.php',
10,
10,
0,
'PAGE_OF-1-1',
- 'on_page
- per_page:10
- on_page:1
- base_url:page.php',
),
);
}
@@ -143,36 +172,47 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
/**
* @dataProvider on_page_data
*/
- public function test_on_page($base_url, $num_items, $per_page, $start_item, $expect_return, $expect)
+ public function test_on_page($num_items, $per_page, $start_item, $expect_return)
{
- $this->assertEquals($expect_return, $this->pagination->on_page($base_url, $num_items, $per_page, $start_item));
-
- $this->template->set_filenames(array('test' => 'on_page.html'));
-
- $this->assertEquals(str_replace("\t", '', $expect), $this->display('test'));
+ $this->assertEquals($expect_return, $this->pagination->on_page($num_items, $per_page, $start_item));
}
public function validate_start_data()
{
return array(
array(
+ 0,
+ 0,
+ 0,
+ ),
+ array(
-1,
+ 20,
0,
),
array(
+ 20,
+ -30,
0,
+ ),
+ array(
+ 0,
+ 20,
0,
),
array(
10,
+ 20,
10,
),
array(
20,
+ 20,
10,
),
array(
30,
+ 20,
10,
),
);
@@ -181,9 +221,9 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case
/**
* @dataProvider validate_start_data
*/
- public function test_validate_start($start, $expect)
+ public function test_validate_start($start, $num_items, $expect)
{
- $this->assertEquals($expect, $this->pagination->validate_start($start, 10, 20));
+ $this->assertEquals($expect, $this->pagination->validate_start($start, 10, $num_items));
}
public function reverse_start_data()
diff --git a/tests/pagination/templates/on_page.html b/tests/pagination/templates/on_page.html
deleted file mode 100644
index 364bcf9f5e..0000000000
--- a/tests/pagination/templates/on_page.html
+++ /dev/null
@@ -1,4 +0,0 @@
-on_page
-per_page:{PER_PAGE}
-on_page:{ON_PAGE}
-base_url:{BASE_URL}
diff --git a/tests/pagination/templates/pagination.html b/tests/pagination/templates/pagination.html
index 7f2a329804..db63258585 100644
--- a/tests/pagination/templates/pagination.html
+++ b/tests/pagination/templates/pagination.html
@@ -1,4 +1,7 @@
pagination
+:per_page:{PER_PAGE}
+:current_page:{CURRENT_PAGE}
+:base_url:{BASE_URL}
<!-- BEGIN pagination -->
<!-- IF pagination.S_IS_PREV -->:previous:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
<!-- ELSEIF pagination.S_IS_CURRENT -->:current:{pagination.PAGE_NUMBER}:{pagination.PAGE_URL}
diff --git a/tests/privmsgs/fixtures/delete_user_pms.xml b/tests/privmsgs/fixtures/delete_user_pms.xml
index 9a86501b7a..5f705c9fd2 100644
--- a/tests/privmsgs/fixtures/delete_user_pms.xml
+++ b/tests/privmsgs/fixtures/delete_user_pms.xml
@@ -8,8 +8,6 @@
<column>user_unread_privmsg</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>2</value>
<value>sender</value>
@@ -18,8 +16,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -29,8 +25,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
@@ -40,8 +34,6 @@
<value>2</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>5</value>
@@ -51,8 +43,6 @@
<value>0</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_privmsgs">
diff --git a/tests/profile/custom_test.php b/tests/profile/custom_test.php
index 654c9f6e5a..e68f1f7c4b 100644
--- a/tests/profile/custom_test.php
+++ b/tests/profile/custom_test.php
@@ -55,16 +55,6 @@ class phpbb_profile_custom_test extends phpbb_database_test_case
$cp = new \phpbb\profilefields\type\type_dropdown(
new \phpbb\profilefields\lang_helper($db, $table_prefix . 'profile_fields_lang'),
- new \phpbb\profilefields\profilefields(
- $this->getMock('\phpbb\auth\auth'),
- $db,
- $request,
- $template,
- $user,
- $table_prefix . 'profile_fields',
- $table_prefix . 'profile_lang',
- $table_prefix . 'profile_fields_data'
- ),
$request,
$template,
$user
diff --git a/tests/profile/get_profile_value_test.php b/tests/profile/get_profile_value_test.php
new file mode 100644
index 0000000000..e867455a03
--- /dev/null
+++ b/tests/profile/get_profile_value_test.php
@@ -0,0 +1,42 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2014 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+class phpbb_profile_get_profile_value_test extends phpbb_test_case
+{
+ static public function get_profile_value_int_data()
+ {
+ return array(
+ array('\phpbb\profilefields\type\type_int', '10', true, 10),
+ array('\phpbb\profilefields\type\type_int', '0', true, 0),
+ array('\phpbb\profilefields\type\type_int', '', true, 0),
+ array('\phpbb\profilefields\type\type_int', null, true, 0),
+ array('\phpbb\profilefields\type\type_int', '10', false, 10),
+ array('\phpbb\profilefields\type\type_int', '0', false, 0),
+ array('\phpbb\profilefields\type\type_int', '', false, null),
+ array('\phpbb\profilefields\type\type_int', null, false, null),
+ );
+ }
+
+ /**
+ * @dataProvider get_profile_value_int_data
+ */
+ public function test_get_profile_value_int($type, $value, $show_novalue, $expected)
+ {
+ $cp = new $type(
+ $this->getMock('\phpbb\request\request'),
+ $this->getMock('\phpbb\template\template'),
+ $this->getMock('\phpbb\user')
+ );
+
+ $this->assertSame($expected, $cp->get_profile_value($value, array(
+ 'field_type' => $type,
+ 'field_show_novalue' => $show_novalue,
+ )));
+ }
+}
diff --git a/tests/search/native_test.php b/tests/search/native_test.php
index 18c6df2445..e860a4f89a 100644
--- a/tests/search/native_test.php
+++ b/tests/search/native_test.php
@@ -106,17 +106,66 @@ class phpbb_search_native_test extends phpbb_search_test_case
array(
'-foo',
'all',
- false,
- null,
- null,
+ true,
+ array(),
+ array(1),
array(),
),
array(
'-foo -bar',
'all',
- false,
- null,
- null,
+ true,
+ array(),
+ array(1, 2),
+ array(),
+ ),
+ array(
+ 'foo -foo',
+ 'all',
+ true,
+ array(1),
+ array(1),
+ array(),
+ ),
+ array(
+ '-foo foo',
+ 'all',
+ true,
+ array(1),
+ array(1),
+ array(),
+ ),
+ // some creative edge cases
+ array(
+ 'foo foo-',
+ 'all',
+ true,
+ array(1),
+ array(),
+ array(),
+ ),
+ array(
+ 'foo- foo',
+ 'all',
+ true,
+ array(1),
+ array(),
+ array(),
+ ),
+ array(
+ 'foo-bar',
+ 'all',
+ true,
+ array(1, 2),
+ array(),
+ array(),
+ ),
+ array(
+ 'foo-bar-foo',
+ 'all',
+ true,
+ array(1, 2),
+ array(),
array(),
),
// all common
diff --git a/tests/security/hash_test.php b/tests/security/hash_test.php
index bc1bebd87a..32aa234316 100644
--- a/tests/security/hash_test.php
+++ b/tests/security/hash_test.php
@@ -7,7 +7,7 @@
*
*/
-require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_compatibility.php';
class phpbb_security_hash_test extends phpbb_test_case
{
diff --git a/tests/security/redirect_test.php b/tests/security/redirect_test.php
index 77dc955c26..e5ff3b1541 100644
--- a/tests/security/redirect_test.php
+++ b/tests/security/redirect_test.php
@@ -15,11 +15,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
{
protected $path_helper;
- protected $controller_helper;
-
public function provider()
{
- $this->controller_helper = $this->get_controller_helper();
// array(Input -> redirect(), expected triggered error (else false), expected returned result url (else false))
return array(
array('data://x', false, false, 'http://localhost/phpBB'),
@@ -38,8 +35,8 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
array('./../foo/bar', false, false, 'http://localhost/foo/bar'),
array('./../foo/bar', true, false, 'http://localhost/foo/bar'),
array('app.php/', false, false, 'http://localhost/phpBB/app.php/'),
- array($this->controller_helper->url('a'), false, false, 'http://localhost/phpBB/app.php/a'),
- array($this->controller_helper->url(''), false, false, 'http://localhost/phpBB/app.php/'),
+ array('app.php/a', false, false, 'http://localhost/phpBB/app.php/a'),
+ array('app.php/a/b', false, false, 'http://localhost/phpBB/app.php/a/b'),
array('./app.php/', false, false, 'http://localhost/phpBB/app.php/'),
array('foobar', false, false, 'http://localhost/phpBB/foobar'),
array('./foobar', false, false, 'http://localhost/phpBB/foobar'),
@@ -69,31 +66,6 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
return $this->path_helper;
}
- protected function get_controller_helper()
- {
- if (!($this->controller_helper instanceof \phpbb\controller\helper))
- {
- global $phpbb_dispatcher;
-
- $phpbb_dispatcher = new phpbb_mock_event_dispatcher;
- $this->user = $this->getMock('\phpbb\user');
- $phpbb_path_helper = new \phpbb\path_helper(
- new \phpbb\symfony_request(
- new phpbb_mock_request()
- ),
- new \phpbb\filesystem(),
- $phpbb_root_path,
- $phpEx
- );
- $this->template = new phpbb\template\twig\twig($phpbb_path_helper, $config, $this->user, new \phpbb\template\context());
-
- // We don't use mod_rewrite in these tests
- $config = new \phpbb\config\config(array('enable_mod_rewrite' => '0'));
- $this->controller_helper = new \phpbb\controller\helper($this->template, $this->user, $config, '', 'php');
- }
- return $this->controller_helper;
- }
-
protected function setUp()
{
parent::setUp();
@@ -103,7 +75,6 @@ class phpbb_security_redirect_test extends phpbb_security_test_base
);
$this->path_helper = $this->get_path_helper();
- $this->controller_helper = $this->get_controller_helper();
}
/**
diff --git a/tests/session/fixtures/sessions_banlist.xml b/tests/session/fixtures/sessions_banlist.xml
index 9422fc0665..e720e35f0a 100644
--- a/tests/session/fixtures/sessions_banlist.xml
+++ b/tests/session/fixtures/sessions_banlist.xml
@@ -5,15 +5,11 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>anonymous</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_sessions">
diff --git a/tests/session/fixtures/sessions_empty.xml b/tests/session/fixtures/sessions_empty.xml
index 0e6ddccd88..2acba58f45 100644
--- a/tests/session/fixtures/sessions_empty.xml
+++ b/tests/session/fixtures/sessions_empty.xml
@@ -5,31 +5,23 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>anonymous</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>foo</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
<value>bar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_sessions">
diff --git a/tests/session/fixtures/sessions_full.xml b/tests/session/fixtures/sessions_full.xml
index 6bbaf1c9d5..4fb6b9dfd4 100644
--- a/tests/session/fixtures/sessions_full.xml
+++ b/tests/session/fixtures/sessions_full.xml
@@ -5,31 +5,23 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value>anonymous</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
<value>foo</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>4</value>
<value>bar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_sessions">
diff --git a/tests/session/fixtures/sessions_garbage.xml b/tests/session/fixtures/sessions_garbage.xml
index 23c44a975b..5eace839d0 100644
--- a/tests/session/fixtures/sessions_garbage.xml
+++ b/tests/session/fixtures/sessions_garbage.xml
@@ -5,15 +5,11 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>4</value>
<value>bar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
<table name="phpbb_sessions">
diff --git a/tests/session/fixtures/sessions_key.xml b/tests/session/fixtures/sessions_key.xml
index 246d284557..4f349cd282 100644
--- a/tests/session/fixtures/sessions_key.xml
+++ b/tests/session/fixtures/sessions_key.xml
@@ -30,15 +30,11 @@
<column>username_clean</column>
<column>user_permissions</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>4</value>
<value>bar</value>
<value></value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 6e9b7d3ee9..aaf55fd15c 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -562,6 +562,40 @@ EOT
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
}
+ public function assign_block_vars_array_data()
+ {
+ return array(
+ array(
+ array(
+ 'outer' => array(
+ array('VARIABLE' => 'Test assigning block vars array loop 0:'),
+ array('VARIABLE' => 'Test assigning block vars array loop 1:'),
+ ),
+ 'outer.middle' => array(
+ array('VARIABLE' => '1st iteration',),
+ array('VARIABLE' => '2nd iteration',),
+ array('VARIABLE' => '3rd iteration',),
+ ),
+ )
+ )
+ );
+ }
+
+ /**
+ * @dataProvider assign_block_vars_array_data
+ */
+ public function test_assign_block_vars_array($block_data)
+ {
+ $this->template->set_filenames(array('test' => 'loop_nested.html'));
+
+ foreach ($block_data as $blockname => $block_vars_array)
+ {
+ $this->template->assign_block_vars_array($blockname, $block_vars_array);
+ }
+
+ $this->assertEquals("outer - 0 - Test assigning block vars array loop 0:outer - 1 - Test assigning block vars array loop 1:middle - 0 - 1st iterationmiddle - 1 - 2nd iterationmiddle - 2 - 3rd iteration", $this->display('test'), 'Ensuring assigning block vars array to template is working correctly');
+ }
+
/**
* @expectedException Twig_Error_Syntax
*/
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 71d03746a9..e40efdec03 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -194,7 +194,8 @@ class phpbb_functional_test_case extends phpbb_test_case
$phpbb_root_path,
$php_ext,
self::$config['table_prefix'],
- array()
+ array(),
+ new \phpbb\db\migration\helper()
);
$container = new phpbb_mock_container_builder();
$container->set('migrator', $migrator);
@@ -927,6 +928,23 @@ class phpbb_functional_test_case extends phpbb_test_case
$crawler = self::request('GET', $posting_url);
$this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
+ if (!empty($form_data['upload_files']))
+ {
+ for ($i = 0; $i < $form_data['upload_files']; $i++)
+ {
+ $file = array(
+ 'tmp_name' => __DIR__ . '/../functional/fixtures/files/valid.jpg',
+ 'name' => 'valid.jpg',
+ 'type' => 'image/jpeg',
+ 'size' => filesize(__DIR__ . '/../functional/fixtures/files/valid.jpg'),
+ 'error' => UPLOAD_ERR_OK,
+ );
+
+ $crawler = self::$client->request('POST', $posting_url, array('add_file' => $this->lang('ADD_FILE')), array('fileupload' => $file));
+ }
+ unset($form_data['upload_files']);
+ }
+
$hidden_fields = array(
$crawler->filter('[type="hidden"]')->each(function ($node, $i) {
return array('name' => $node->attr('name'), 'value' => $node->attr('value'));
diff --git a/tests/tree/nestedset_forum_get_data_test.php b/tests/tree/nestedset_forum_get_data_test.php
index ca1863e55e..a0d0778e82 100644
--- a/tests/tree/nestedset_forum_get_data_test.php
+++ b/tests/tree/nestedset_forum_get_data_test.php
@@ -116,4 +116,20 @@ class phpbb_tests_tree_nestedset_forum_get_data_test extends phpbb_tests_tree_ne
$forum_data['forum_parents'] = $forum_parents;
$this->assertEquals($expected, array_keys($this->set->get_path_basic_data($forum_data)));
}
+
+ public function get_all_tree_data_data()
+ {
+ return array(
+ array(true, array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)),
+ array(false, array(11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1)),
+ );
+ }
+
+ /**
+ * @dataProvider get_all_tree_data_data
+ */
+ public function test_get_all_tree_data($order_asc, $expected)
+ {
+ $this->assertEquals($expected, array_keys($this->set->get_all_tree_data($order_asc)));
+ }
}
diff --git a/tests/user/fixtures/user_loader.xml b/tests/user/fixtures/user_loader.xml
index 1fed8b5838..f676f468a6 100644
--- a/tests/user/fixtures/user_loader.xml
+++ b/tests/user/fixtures/user_loader.xml
@@ -6,16 +6,12 @@
<column>username</column>
<column>username_clean</column>
<column>user_sig</column>
- <column>user_occ</column>
- <column>user_interests</column>
<row>
<value>1</value>
<value></value>
<value>Guest</value>
<value>guest</value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>2</value>
@@ -23,8 +19,6 @@
<value>Admin</value>
<value>admin</value>
<value></value>
- <value></value>
- <value></value>
</row>
<row>
<value>3</value>
@@ -32,8 +26,6 @@
<value>Test</value>
<value>test</value>
<value></value>
- <value></value>
- <value></value>
</row>
</table>
</dataset>