aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/download_test.php2
-rw-r--r--tests/functional/paging_test.php14
-rw-r--r--tests/functional/prune_shadow_topic_test.php2
-rw-r--r--tests/functional/softdelete_test.php4
-rw-r--r--tests/functions_content/phpbb_clean_search_string_test.php38
-rw-r--r--tests/log/fixtures/full_log.xml12
-rw-r--r--tests/log/function_view_log_test.php43
-rw-r--r--tests/path_helper/web_root_path_test.php7
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php4
9 files changed, 109 insertions, 17 deletions
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php
index 24366992d5..087250157d 100644
--- a/tests/functional/download_test.php
+++ b/tests/functional/download_test.php
@@ -57,7 +57,7 @@ class phpbb_functional_download_test extends phpbb_functional_test_case
$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');
+ $this->data['posts']['Re: Download Topic #1-#2'] = (int) $post2['post_id'];
}
public function test_download_accessible()
diff --git a/tests/functional/paging_test.php b/tests/functional/paging_test.php
index 91f14cb75d..b0e4743d5b 100644
--- a/tests/functional/paging_test.php
+++ b/tests/functional/paging_test.php
@@ -18,22 +18,22 @@ class phpbb_functional_paging_test extends phpbb_functional_test_case
$this->login();
$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
- for ($post_id = 1; $post_id <= 11; $post_id++)
+ for ($post_id = 1; $post_id <= 16; $post_id++)
{
$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post no' . $post_id . ' posted by the testing framework.');
}
$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
- $this->assertContains('post no9', $crawler->text());
- $this->assertNotContains('post no11', $crawler->text());
+ $this->assertContains('post no4', $crawler->text());
+ $this->assertNotContains('post no16', $crawler->text());
$next_link = $crawler->filter('#viewtopic > fieldset > a.arrow-right')->attr('href');
$crawler = self::request('GET', $next_link);
- $this->assertContains('post no11', $crawler->text());
- $this->assertNotContains('post no9', $crawler->text());
+ $this->assertNotContains('post no4', $crawler->text());
+ $this->assertContains('post no16', $crawler->text());
$prev_link = $crawler->filter('#viewtopic > fieldset > a.arrow-left')->attr('href');
$crawler = self::request('GET', $prev_link);
- $this->assertContains('post no9', $crawler->text());
- $this->assertNotContains('post no11', $crawler->text());
+ $this->assertContains('post no4', $crawler->text());
+ $this->assertNotContains('post no16', $crawler->text());
}
}
diff --git a/tests/functional/prune_shadow_topic_test.php b/tests/functional/prune_shadow_topic_test.php
index 901cedb389..a9fd2457bb 100644
--- a/tests/functional/prune_shadow_topic_test.php
+++ b/tests/functional/prune_shadow_topic_test.php
@@ -76,7 +76,7 @@ class phpbb_functional_prune_shadow_topic_test extends phpbb_functional_test_cas
$crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
$this->assertContains('Re: Prune Shadow #1-#2', $crawler->filter('html')->text());
- $this->data['posts']['Re: Prune Shadow #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
+ $this->data['posts']['Re: Prune Shadow #1-#2'] = (int) $post2['post_id'];
$this->assert_forum_details($this->data['forums']['Prune Shadow'], array(
'forum_posts_approved' => 2,
diff --git a/tests/functional/softdelete_test.php b/tests/functional/softdelete_test.php
index bd4d34cf99..1c86d00b9b 100644
--- a/tests/functional/softdelete_test.php
+++ b/tests/functional/softdelete_test.php
@@ -83,7 +83,7 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case
$crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
$this->assertContains('Re: Soft Delete Topic #1-#2', $crawler->filter('html')->text());
- $this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p');
+ $this->data['posts']['Re: Soft Delete Topic #1-#2'] = (int) $post2['post_id'];
$this->assert_forum_details($this->data['forums']['Soft Delete #1'], array(
'forum_posts_approved' => 2,
@@ -410,7 +410,7 @@ class phpbb_functional_softdelete_test extends phpbb_functional_test_case
$crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}");
$this->add_lang('mcp');
- $form = $crawler->selectButton($this->lang('RESTORE'))->form();
+ $form = $crawler->filter('#p' . $this->data['posts']['Soft Delete Topic #1'])->selectButton($this->lang('RESTORE'))->form();
$crawler = self::submit($form);
$this->assertContainsLang('RESTORE_POST', $crawler->text());
diff --git a/tests/functions_content/phpbb_clean_search_string_test.php b/tests/functions_content/phpbb_clean_search_string_test.php
new file mode 100644
index 0000000000..de642c9040
--- /dev/null
+++ b/tests/functions_content/phpbb_clean_search_string_test.php
@@ -0,0 +1,38 @@
+<?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_content.php';
+
+class phpbb_functions_content_phpbb_clean_search_string_test extends phpbb_test_case
+{
+ public function phpbb_clean_search_string_data()
+ {
+ return array(
+ array('*', ''),
+ array('* *', ''),
+ array('test', 'test'),
+ array(' test ', 'test'),
+ array(' test * ', 'test'),
+ array('test* *', 'test*'),
+ array('* *test*', '*test*'),
+ array('test test * test', 'test test test'),
+ array(' some wild*cards * between wo*rds ', 'some wild*cards between wo*rds'),
+ array(' we * now have*** multiple wild***cards * ', 'we now have* multiple wild*cards'),
+ array('pi is *** . * **** * *****', 'pi is .'),
+ );
+ }
+
+ /**
+ * @dataProvider phpbb_clean_search_string_data
+ */
+ public function test_phpbb_clean_search_string($search_string, $expected)
+ {
+ $this->assertEquals($expected, phpbb_clean_search_string($search_string));
+ }
+}
diff --git a/tests/log/fixtures/full_log.xml b/tests/log/fixtures/full_log.xml
index a10c224e0e..4e5538d5a9 100644
--- a/tests/log/fixtures/full_log.xml
+++ b/tests/log/fixtures/full_log.xml
@@ -119,6 +119,18 @@
<value>LOG_USER</value>
<value>a:1:{i:0;s:5:"guest";}</value>
</row>
+ <row>
+ <value>10</value>
+ <value>3</value>
+ <value>1</value>
+ <value>0</value>
+ <value>0</value>
+ <value>0</value>
+ <value>127.0.0.1</value>
+ <value>1</value>
+ <value>LOG_SINGULAR_PLURAL</value>
+ <value>a:1:{i:0;i:2;}</value>
+ </row>
</table>
<table name="phpbb_users">
<column>user_id</column>
diff --git a/tests/log/function_view_log_test.php b/tests/log/function_view_log_test.php
index 9148d23bb4..2f64459062 100644
--- a/tests/log/function_view_log_test.php
+++ b/tests/log/function_view_log_test.php
@@ -164,7 +164,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'topic_id' => 45,
'viewforum' => '',
- 'action' => '{LOG MOD2}',
+ 'action' => 'LOG_MOD2',
'viewtopic' => '',
'viewlogs' => '',
),
@@ -185,7 +185,7 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'topic_id' => 0,
'viewforum' => '',
- 'action' => '{LOG USER}<br />admin',
+ 'action' => 'LOG_USER admin',
),
9 => array(
'id' => 9,
@@ -204,7 +204,26 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'topic_id' => 0,
'viewforum' => '',
- 'action' => '{LOG USER}<br />guest',
+ 'action' => 'LOG_USER guest',
+ ),
+ 10 => array(
+ 'id' => 10,
+
+ 'reportee_id' => 0,
+ 'reportee_username' => '',
+ 'reportee_username_full'=> '',
+
+ 'user_id' => 1,
+ 'username' => 'Anonymous',
+ 'username_full' => 'Anonymous',
+
+ 'ip' => '127.0.0.1',
+ 'time' => 1,
+ 'forum_id' => 0,
+ 'topic_id' => 0,
+
+ 'viewforum' => '',
+ 'action' => 'LOG_SINGULAR_PLURAL 2',
),
);
@@ -277,10 +296,20 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
'user', 0, 5, 0, 0, 0, 2,
),
array(
- 'expected' => array(8, 9),
+ 'expected' => array(8, 9, 10),
'expected_returned' => 0,
'users', 0,
),
+ array(
+ 'expected' => array(1),
+ 'expected_returned' => 0,
+ 'admin', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'install',
+ ),
+ array(
+ 'expected' => array(10),
+ 'expected_returned' => 0,
+ 'user', false, 5, 0, 0, 0, 0, 0, 'l.log_id ASC', 'plural',
+ ),
);
foreach ($test_cases as $case => $case_data)
@@ -331,6 +360,12 @@ class phpbb_log_function_view_log_test extends phpbb_database_test_case
// Test sprintf() of the data into the action
$user->lang = array(
'LOG_INSTALL_INSTALLED' => 'installed: %s',
+ 'LOG_USER' => 'User<br /> %s',
+ 'LOG_MOD2' => 'Mod2',
+ 'LOG_SINGULAR_PLURAL' => array(
+ 1 => 'singular',
+ 2 => 'plural (%d)',
+ ),
);
$phpbb_log = new \phpbb\log\log($db, $user, $auth, $phpbb_dispatcher, $phpbb_root_path, 'adm/', $phpEx, LOG_TABLE);
diff --git a/tests/path_helper/web_root_path_test.php b/tests/path_helper/web_root_path_test.php
index 2c22511402..ec04135997 100644
--- a/tests/path_helper/web_root_path_test.php
+++ b/tests/path_helper/web_root_path_test.php
@@ -116,6 +116,13 @@ class phpbb_path_helper_web_root_path_test extends phpbb_test_case
'/phpbb3-fork/phpBB/foo/template',
'/phpbb3-fork/phpBB/app.php',
),
+ array(
+ $this->phpbb_root_path . 'test.php',
+ $this->phpbb_root_path . '../test.php',
+ '/',
+ '/phpbb3-fork/phpBB/app.php/',
+ '/phpbb3-fork/phpBB/app.php',
+ ),
);
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 1f372fff0c..95ed334ed0 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -522,8 +522,8 @@ class phpbb_functional_test_case extends phpbb_test_case
'user_email' => 'nobody@example.com',
'user_type' => 0,
'user_lang' => 'en',
- 'user_timezone' => 0,
- 'user_dateformat' => '',
+ 'user_timezone' => 'UTC',
+ 'user_dateformat' => 'r',
'user_password' => $passwords_manager->hash($username . $username),
);
return user_add($user_row);