1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-18 06:21:19 +02:00

Merge branch 'develop' of https://github.com/phpbb/phpbb into feature/passwords

Conflicts:
	phpBB/config/services.yml
This commit is contained in:
Marc Alexander
2013-12-29 13:46:42 +01:00
619 changed files with 13392 additions and 5996 deletions

View File

@@ -50,6 +50,15 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
'avatar_delete' => array('tick', ''),
),
),
array(
'The URL you specified is invalid.',
'avatar_driver_remote',
array(
'avatar_remote_url' => 'https://www.phpbb.com/avatar/55502f40dc8b7c769880b10874abc9d0.jpg',
'avatar_remote_width' => 80,
'avatar_remote_height' => 80,
),
),
);
}
@@ -60,4 +69,13 @@ class phpbb_functional_avatar_acp_groups_test extends phpbb_functional_common_av
{
$this->assert_avatar_submit($expected, $avatar_type, $data);
}
// Test if avatar was really deleted
public function test_no_avatar_acp_groups()
{
$crawler = self::request('GET', $this->get_url() . '&sid=' . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$form_data = $form->getValues();
$this->assertEmpty($form_data['avatar_type']);
}
}

View File

@@ -45,7 +45,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// Insert our base data
$insert_rows = array(
array(
'ext_name' => 'foo',
'ext_name' => 'vendor2/foo',
'ext_active' => true,
'ext_state' => 'b:0;',
),
@@ -57,12 +57,12 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
// do not exist
array(
'ext_name' => 'test2',
'ext_name' => 'vendor/test2',
'ext_active' => true,
'ext_state' => 'b:0;',
),
array(
'ext_name' => 'test3',
'ext_name' => 'vendor/test3',
'ext_active' => false,
'ext_state' => 'b:0;',
),
@@ -77,58 +77,67 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
public function test_list()
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&sid=' . $this->sid);
$this->assertCount(1, $crawler->filter('.ext_enabled'));
$this->assertCount(5, $crawler->filter('.ext_disabled'));
$this->assertCount(1, $crawler->filter('.ext_enabled'));
$this->assertCount(4, $crawler->filter('.ext_disabled'));
$this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContainsLang('PURGE', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContains('phpBB Foo Extension', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContainsLang('EXTENSION_DISABLE', $crawler->filter('.ext_enabled')->eq(0)->text());
$this->assertContains('The "test2" extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
$this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(1)->text());
$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(1)->text());
$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(1)->text());
$this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(1)->text());
$this->assertContains('The "test3" extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text());
$this->assertContains('The “vendor/test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
$this->assertContains('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContainsLang('ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContainsLang('PURGE', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContains('The “vendor/test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(2)->text());
$this->assertContains('The "bar" extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text());
$this->assertContains('phpBB Bar Extension', $crawler->filter('.ext_disabled')->eq(3)->text());
$this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(3)->text());
$this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(3)->text());
// Check that invalid extensions are not listed.
$this->assertNotContains('phpBB BarFoo Extension', $crawler->filter('.table1')->text());
$this->assertNotContains('barfoo', $crawler->filter('.table1')->text());
$this->assertNotContains('vendor3/bar', $crawler->filter('.table1')->text());
}
public function test_details()
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid);
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=vendor2%2Ffoo&sid=' . $this->sid);
$validation = array(
'DISPLAY_NAME' => 'phpBB Foo Extension',
'CLEAN_NAME' => 'foo/example',
'DESCRIPTION' => 'An example/sample extension to be used for testing purposes in phpBB Development.',
'VERSION' => '1.0.0',
'TIME' => '2012-02-15 01:01:01',
'LICENCE' => 'GPL-2.0',
'PHPBB_VERSION' => '3.1.0-dev',
'PHP_VERSION' => '>=5.3',
'AUTHOR_NAME' => 'Nathan Guse',
'AUTHOR_EMAIL' => 'email@phpbb.com',
'AUTHOR_HOMEPAGE' => 'http://lithiumstudios.org',
'AUTHOR_ROLE' => 'N/A',
);
$validation = array(
'DISPLAY_NAME' => 'phpBB Foo Extension',
'CLEAN_NAME' => 'vendor2/foo',
'TYPE' => 'phpbb-extension',
'DESCRIPTION' => 'An example/sample extension to be used for testing purposes in phpBB Development.',
'VERSION' => '1.0.0',
'TIME' => '2012-02-15 01:01:01',
'LICENCE' => 'GPL-2.0',
'PHPBB_VERSION' => '3.1.*@dev',
'PHP_VERSION' => '>=5.3',
'AUTHOR_NAME' => 'John Smith',
'AUTHOR_EMAIL' => 'email@phpbb.com',
'AUTHOR_HOMEPAGE' => 'http://phpbb.com',
'AUTHOR_ROLE' => 'N/A',
);
for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
{
$text = $crawler->filter('dl')->eq($i)->text();
for ($i = 0; $i < $crawler->filter('dl')->count(); $i++)
{
$text = $crawler->filter('dl')->eq($i)->text();
$match = false;
$match = false;
foreach ($validation as $language_key => $expected)
{
if (strpos($text, $this->lang($language_key)) === 0)
{
$match = true;
foreach ($validation as $language_key => $expected)
{
if (strpos($text, $this->lang($language_key)) === 0)
{
$match = true;
$this->assertContains($expected, $text);
$this->assertContains($expected, $text);
}
}
@@ -142,46 +151,77 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case
public function test_enable_pre()
{
// Foo is already enabled (redirect to list)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=foo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('ENABLE_CONFIRM', $crawler->filter('html')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('.errorbox')->text());
}
public function test_disable_pre()
{
// Moo is not enabled (redirect to list)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('html')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('html')->text());
// Moo is not enabled (redirect to list)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=foo&sid=' . $this->sid);
$this->assertContainsLang('DISABLE_CONFIRM', $crawler->filter('html')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);
$this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text());
}
public function test_purge_pre()
public function test_delete_data_pre()
{
// test2 is not available (error)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=test2&sid=' . $this->sid);
$this->assertContains('The required file does not exist', $crawler->filter('html')->text());
// test2 is not available (error)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=test2&sid=' . $this->sid);
$this->assertContains('The required file does not exist', $crawler->filter('.errorbox')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge_pre&ext_name=foo&sid=' . $this->sid);
$this->assertContainsLang('PURGE_CONFIRM', $crawler->filter('html')->text());
// foo is not disabled (redirect to list)
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor2%2Ffoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_NAME', $crawler->filter('div.main thead')->text());
$this->assertContainsLang('EXTENSION_OPTIONS', $crawler->filter('div.main thead')->text());
$this->assertContainsLang('EXTENSION_ACTIONS', $crawler->filter('div.main thead')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContains('Are you sure that you wish to delete the data associated with “phpBB Moo Extension”?', $crawler->filter('.errorbox')->text());
}
public function test_actions()
{
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('ENABLE_SUCCESS', $crawler->filter('html')->text());
// Access enable page without hash
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('DISABLE_SUCCESS', $crawler->filter('html')->text());
// Correctly submit the enable form
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$form = $crawler->selectButton('enable')->form();
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_ENABLE_SUCCESS', $crawler->filter('.successbox')->text());
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=purge&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('PURGE_SUCCESS', $crawler->filter('html')->text());
// Access disable page without hash
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text());
// Correctly submit the disable form
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=disable_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$form = $crawler->selectButton('disable')->form();
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_DISABLE_SUCCESS', $crawler->filter('.successbox')->text());
// Access delete_data page without hash
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$this->assertContainsLang('FORM_INVALID', $crawler->filter('.errorbox')->text());
// Correctly submit the delete data form
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=delete_data_pre&ext_name=vendor%2Fmoo&sid=' . $this->sid);
$form = $crawler->selectButton('delete_data')->form();
$crawler = self::submit($form);
$this->assertContainsLang('EXTENSION_DELETE_DATA_SUCCESS', $crawler->filter('.successbox')->text());
// Attempt to enable invalid extension
$crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=enable_pre&ext_name=barfoo&sid=' . $this->sid);
$this->assertContainsLang('EXTENSION_DIR_INVALID', $crawler->filter('.errorbox')->text());
}
}
}

View File

@@ -19,6 +19,8 @@ class phpbb_functional_extension_controller_test extends phpbb_functional_test_c
static protected $fixtures = array(
'foo/bar/config/',
'foo/bar/controller/',
'foo/bar/event/',
'foo/bar/language/en/',
'foo/bar/styles/prosilver/template/',
);

View File

@@ -17,8 +17,9 @@ class phpbb_functional_extension_global_lang_test extends phpbb_functional_test_
static private $helper;
static protected $fixtures = array(
'foo/bar/language/en/',
'foo/bar/config/',
'foo/bar/event/',
'foo/bar/language/en/',
);
static public function setUpBeforeClass()

View File

@@ -80,18 +80,53 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case
);
$modules->update_module_data($module_data, true);
$parent_data = array(
'module_basename' => '',
'module_enabled' => 1,
'module_display' => 1,
'parent_id' => 0,
'module_class' => 'ucp',
'module_langname' => 'UCP_FOOBAR_TITLE',
'module_mode' => '',
'module_auth' => '',
);
$modules->update_module_data($parent_data, true);
$module_data = array(
'module_basename' => 'foo\\bar\\ucp\\main_module',
'module_enabled' => 1,
'module_display' => 1,
'parent_id' => $parent_data['module_id'],
'module_class' => 'ucp',
'module_langname' => 'UCP_FOOBAR_TITLE',
'module_mode' => 'mode',
'module_auth' => '',
);
$modules->update_module_data($module_data, true);
$this->purge_cache();
}
/**
* Check a controller for extension foo/bar.
*/
public function test_foo_bar()
public function test_acp()
{
$this->login();
$this->admin_login();
$crawler = self::request('GET', 'adm/index.php?i=foo%5cbar%5cacp%5cmain_module&mode=mode&sid=' . $this->sid);
$this->assertContains("Bertie rulez!", $crawler->filter('#main')->text());
$this->assertContains('Bertie rulez!', $crawler->filter('#main')->text());
}
public function test_ucp()
{
$this->login();
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid);
$this->assertContains('UCP_FOOBAR_TITLE', $crawler->filter('#tabs')->text());
$link = $crawler->selectLink('UCP_FOOBAR_TITLE')->link()->getUri();
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
$this->assertContains('UCP Extension Template Test Passed!', $crawler->filter('#content')->text());
$this->phpbb_extension_manager->purge('foo/bar');
}
}

View File

@@ -17,8 +17,9 @@ class phpbb_functional_extension_permission_lang_test extends phpbb_functional_t
static private $helper;
static protected $fixtures = array(
'foo/bar/language/en/',
'foo/bar/config/',
'foo/bar/event/',
'foo/bar/language/en/',
);
static public function setUpBeforeClass()

View File

@@ -22,6 +22,25 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case
$this->login();
}
public function tearDown()
{
$iterator = new DirectoryIterator(__DIR__ . '/../../phpBB/files/');
foreach ($iterator as $fileinfo)
{
if (
$fileinfo->isDot()
|| $fileinfo->isDir()
|| $fileinfo->getFilename() === 'index.htm'
|| $fileinfo->getFilename() === '.htaccess'
)
{
continue;
}
unlink($fileinfo->getPathname());
}
}
private function upload_file($filename, $mimetype)
{
$file = array(

View File

@@ -1,6 +1,6 @@
{
"name": "foo/bar",
"type": "phpbb3-extension",
"type": "phpbb-extension",
"description": "Testing extensions",
"homepage": "",
"version": "1.0.0",
@@ -8,14 +8,13 @@
"licence": "GPL-2.0",
"authors": [{
"name": "Joas Schilling",
"username": "nickvergessen",
"email": "nickvergessen@phpbb.com",
"homepage": "http://www.phpbb.com",
"role": "Developer"
}],
"require": {
"php": ">=5.3",
"phpbb": ">=3.1.0-dev"
"phpbb/phpbb": "3.1.*@dev"
},
"extra": {
"display-name": "phpBB 3.1 Extension Testing"

View File

@@ -4,3 +4,12 @@ services:
arguments:
- @controller.helper
- @template
foo_bar.listener.permission:
class: foo\bar\event\permission
tags:
- { name: event.listener }
foo_bar.listener.user_setup:
class: foo\bar\event\user_setup
tags:
- { name: event.listener }

View File

@@ -10,15 +10,6 @@
namespace foo\bar\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Event listener
*/

View File

@@ -10,15 +10,6 @@
namespace foo\bar\event;
/**
* @ignore
*/
if (!defined('IN_PHPBB'))
{
exit;
}
/**
* Event listener
*/

View File

@@ -0,0 +1,3 @@
<!-- INCLUDE overall_header.html -->
<div id="content">UCP Extension Template Test Passed!</div>
<!-- INCLUDE overall_footer.html -->

View File

@@ -0,0 +1,26 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace foo\bar\ucp;
class main_info
{
function module()
{
return array(
'filename' => '\foo\bar\ucp\main_module',
'title' => 'ACP_FOOBAR_TITLE',
'version' => '1.0.0',
'modes' => array(
'mode' => array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),
),
);
}
}

View File

@@ -0,0 +1,22 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
namespace foo\bar\ucp;
class main_module
{
var $u_action;
function main($id, $mode)
{
$this->tpl_name = 'foobar';
$this->page_title = 'Bertie';
}
}

View File

@@ -0,0 +1,31 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_group_create_test extends phpbb_functional_test_case
{
public function test_create_group()
{
$this->login();
$this->admin_login();
$this->add_lang('acp/groups');
$crawler = self::request('GET', 'adm/index.php?i=acp_groups&mode=manage&sid=' . $this->sid);
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$crawler = self::submit($form, array('group_name' => 'testtest'));
$form = $crawler->selectButton($this->lang('SUBMIT'))->form();
$crawler = self::submit($form, array('group_name' => 'testtest'));
$this->assertContainsLang('GROUP_CREATED', $crawler->filter('#main')->text());
}
}

View File

@@ -52,4 +52,37 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case
$this->assert_checkbox_is_unchecked($cplist, $checkbox_name);
}
}
public function test_mark_notifications_read()
{
// Create a new standard user
$this->create_user('notificationtestuser');
$this->add_user_group('NEWLY_REGISTERED', array('notificationtestuser'));
$this->login('notificationtestuser');
$crawler = self::request('GET', 'index.php');
$this->assertContains('notificationtestuser', $crawler->filter('.icon-logout')->text());
// Post a new post that needs approval
$this->create_post(2, 1, 'Re: Welcome to phpBB3', 'This is a test [b]post[/b] posted by notificationtestuser.', array(), 'POST_STORED_MOD');
$crawler = self::request('GET', "viewtopic.php?t=1&sid={$this->sid}");
$this->assertNotContains('This is a test post posted by notificationtestuser.', $crawler->filter('html')->text());
// logout
$crawler = self::request('GET', 'ucp.php?sid=' . $this->sid . '&mode=logout');
// admin login
$this->login();
$this->add_lang('ucp');
$crawler = self::request('GET', 'ucp.php?i=ucp_notifications');
// At least one notification should exist
$this->assertGreaterThan(0, $crawler->filter('#notification_list_button strong')->text());
// Get form token
$link = $crawler->selectLink($this->lang('NOTIFICATIONS_MARK_ALL_READ'))->link()->getUri();
$crawler = self::request('GET', substr($link, strpos($link, 'ucp.')));
$form = $crawler->selectButton($this->lang('YES'))->form();
$crawler = self::submit($form);
$this->assertEquals(0, $crawler->filter('#notification_list_button strong')->text());
}
}

View File

@@ -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 < 20; $post_id++)
for ($post_id = 1; $post_id <= 11; $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 no19', $crawler->text());
$this->assertNotContains('post no11', $crawler->text());
$next_link = $crawler->filter('#viewtopic > fieldset > a.arrow-right')->attr('href');
$crawler = self::request('GET', $next_link);
$this->assertContains('post no19', $crawler->text());
$this->assertContains('post no11', $crawler->text());
$this->assertNotContains('post no9', $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 no19', $crawler->text());
$this->assertNotContains('post no11', $crawler->text());
}
}

View File

@@ -0,0 +1,149 @@
<?php
/**
*
* @package testing
* @copyright (c) 2012 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
class phpbb_functional_plupload_test extends phpbb_functional_test_case
{
const CHUNKS = 4;
private $path;
protected function set_extension_group_permission($val)
{
$db = $this->get_db();
$query = "
UPDATE phpbb_extension_groups
SET allow_in_pm = '$val'
WHERE group_name = 'IMAGES'
";
$db->sql_query($query);
}
public function setUp()
{
parent::setUp();
$this->set_extension_group_permission(1);
$this->path = __DIR__ . '/fixtures/files/';
$this->add_lang('posting');
$this->login();
}
public function tearDown()
{
$this->set_extension_group_permission(0);
$iterator = new DirectoryIterator(__DIR__ . '/../../phpBB/files/');
foreach ($iterator as $fileinfo)
{
if (
$fileinfo->isDot()
|| $fileinfo->isDir()
|| $fileinfo->getFilename() === 'index.htm'
|| $fileinfo->getFilename() === '.htaccess'
)
{
continue;
}
unlink($fileinfo->getPathname());
}
}
public function get_urls()
{
return array(
array('posting.php?mode=reply&f=2&t=1'),
array('ucp.php?i=pm&mode=compose'),
);
}
/**
* @dataProvider get_urls
*/
public function test_chunked_upload($url)
{
$chunk_size = ceil(filesize($this->path . 'valid.jpg') / self::CHUNKS);
$handle = fopen($this->path . 'valid.jpg', 'rb');
for ($i = 0; $i < self::CHUNKS; $i++)
{
$chunk = fread($handle, $chunk_size);
file_put_contents($this-> path . 'chunk', $chunk);
$file = array(
'tmp_name' => $this->path . 'chunk',
'name' => 'blob',
'type' => 'application/octet-stream',
'size' => strlen($chunk),
'error' => UPLOAD_ERR_OK,
);
self::$client->setServerParameter('HTTP_X_PHPBB_USING_PLUPLOAD', '1');
$crawler = self::$client->request(
'POST',
$url . '&sid=' . $this->sid,
array(
'chunk' => $i,
'chunks' => self::CHUNKS,
'name' => md5('valid') . '.jpg',
'real_filename' => 'valid.jpg',
'add_file' => $this->lang('ADD_FILE'),
),
array('fileupload' => $file),
array('X-PHPBB-USING-PLUPLOAD' => '1')
);
if ($i < self::CHUNKS - 1)
{
$this->assertContains('{"jsonrpc":"2.0","id":"id","result":null}', self::$client->getResponse()->getContent());
}
else
{
$response = json_decode(self::$client->getResponse()->getContent(), true);
$this->assertEquals('valid.jpg', $response[0]['real_filename']);
}
unlink($this->path . 'chunk');
}
fclose($handle);
}
/**
* @dataProvider get_urls
*/
public function test_normal_upload($url)
{
$file = array(
'tmp_name' => $this->path . 'valid.jpg',
'name' => 'valid.jpg',
'type' => 'image/jpeg',
'size' => filesize($this->path . 'valid.jpg'),
'error' => UPLOAD_ERR_OK,
);
$crawler = self::$client->request(
'POST',
$url . '&sid=' . $this->sid,
array(
'chunk' => '0',
'chunks' => '1',
'name' => md5('valid') . '.jpg',
'real_filename' => 'valid.jpg',
'add_file' => $this->lang('ADD_FILE'),
),
array('fileupload' => $file),
array('X-PHPBB-USING-PLUPLOAD' => '1')
);
$response = json_decode(self::$client->getResponse()->getContent(), true);
$this->assertEquals('valid.jpg', $response[0]['real_filename']);
}
}

View File

@@ -0,0 +1,95 @@
<?php
/**
*
* @package testing
* @copyright (c) 2013 phpBB Group
* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
*
*/
/**
* @group functional
*/
abstract class phpbb_functional_search_base extends phpbb_functional_test_case
{
protected function assert_search_found($keywords)
{
$crawler = self::request('GET', 'search.php?keywords=' . $keywords);
$this->assertEquals(1, $crawler->filter('.postbody')->count());
$this->assertEquals(3, $crawler->filter('.posthilit')->count());
}
protected function assert_search_not_found($keywords)
{
$crawler = self::request('GET', 'search.php?keywords=' . $keywords);
$this->assertEquals(0, $crawler->filter('.postbody')->count());
$split_keywords_string = str_replace(array('+', '-'), ' ', $keywords);
$this->assertEquals($split_keywords_string, $crawler->filter('#keywords')->attr('value'));
}
public function test_search_backend()
{
$this->login();
$this->admin_login();
$crawler = self::request('GET', 'adm/index.php?i=acp_search&mode=settings&sid=' . $this->sid);
$form = $crawler->selectButton('Submit')->form();
$values = $form->getValues();
if ($values["config[search_type]"] != $this->search_backend)
{
$values["config[search_type]"] = $this->search_backend;
$form->setValues($values);
$crawler = self::submit($form);
$form = $crawler->selectButton('Yes')->form();
$values = $form->getValues();
$crawler = self::submit($form);
// check if search backend is not supported
if ($crawler->filter('.errorbox')->count() > 0)
{
$this->markTestSkipped("Search backend is not supported/running");
}
$this->create_search_index();
}
$this->logout();
$this->assert_search_found('phpbb3+installation');
$this->assert_search_not_found('loremipsumdedo');
$this->login();
$this->admin_login();
$this->delete_search_index();
}
protected function create_search_index()
{
$this->add_lang('acp/search');
$crawler = self::request(
'POST',
'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
array(
'search_type' => $this->search_backend,
'action' => 'create',
'submit' => true,
)
);
$this->assertContainsLang('SEARCH_INDEX_CREATED', $crawler->text());
}
protected function delete_search_index()
{
$this->add_lang('acp/search');
$crawler = self::request(
'POST',
'adm/index.php?i=acp_search&mode=index&sid=' . $this->sid,
array(
'search_type' => $this->search_backend,
'action' => 'delete',
'submit' => true,
)
);
$this->assertContainsLang('SEARCH_INDEX_REMOVED', $crawler->text());
}
}

View File

@@ -0,0 +1,23 @@
<?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__) . '/base.php';
/**
* @group functional
*/
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');
}
}

View File

@@ -0,0 +1,23 @@
<?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__) . '/base.php';
/**
* @group functional
*/
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');
}
}

View File

@@ -0,0 +1,23 @@
<?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__) . '/base.php';
/**
* @group functional
*/
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');
}
}

View File

@@ -0,0 +1,23 @@
<?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__) . '/base.php';
/**
* @group functional
*/
class phpbb_functional_search_sphinx_test extends phpbb_functional_search_base
{
protected $search_backend = '\phpbb\search\fulltext_sphinx';
public function test_search_backend()
{
$this->markTestIncomplete('Sphinx Tests are not supported');
}
}