1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-08-09 18:26:32 +02:00

Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/10631

Conflicts:
	phpBB/common.php
	phpBB/download/file.php
This commit is contained in:
Unknown Bliss
2012-09-01 21:15:39 +01:00
47 changed files with 1172 additions and 288 deletions

View File

@@ -11,6 +11,11 @@ class phpbb_ext_testext_cron_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
public function get_name()
{
return get_class($this);
}
public function run()
{
self::$was_run++;

View File

@@ -11,6 +11,11 @@ class phpbb_cron_task_core_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
public function get_name()
{
return get_class($this);
}
public function run()
{
self::$was_run++;

View File

@@ -11,6 +11,11 @@ class phpbb_cron_task_core_second_dummy_task extends phpbb_cron_task_base
{
public static $was_run = 0;
public function get_name()
{
return get_class($this);
}
public function run()
{
self::$was_run++;

View File

@@ -18,10 +18,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->manager = new phpbb_cron_manager(array(
'phpbb_cron_task_core_dummy_task',
'phpbb_cron_task_core_second_dummy_task',
'phpbb_ext_testext_cron_dummy_task',
$this->manager = $this->create_cron_manager(array(
new phpbb_cron_task_core_dummy_task(),
new phpbb_cron_task_core_second_dummy_task(),
new phpbb_ext_testext_cron_dummy_task(),
));
$this->task_name = 'phpbb_cron_task_core_dummy_task';
}
@@ -33,13 +33,6 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$this->assertEquals($this->task_name, $task->get_name());
}
public function test_manager_instantiates_task_by_name()
{
$task = $this->manager->instantiate_task($this->task_name, array());
$this->assertInstanceOf('phpbb_cron_task_wrapper', $task);
$this->assertEquals($this->task_name, $task->get_name());
}
public function test_manager_finds_all_ready_tasks()
{
$tasks = $this->manager->find_all_ready_tasks();
@@ -54,10 +47,10 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
public function test_manager_finds_only_ready_tasks()
{
$manager = new phpbb_cron_manager(array(
'phpbb_cron_task_core_simple_ready',
'phpbb_cron_task_core_simple_not_runnable',
'phpbb_cron_task_core_simple_should_not_run',
$manager = $this->create_cron_manager(array(
new phpbb_cron_task_core_simple_ready(),
new phpbb_cron_task_core_simple_not_runnable(),
new phpbb_cron_task_core_simple_should_not_run(),
));
$tasks = $manager->find_all_ready_tasks();
$task_names = $this->tasks_to_names($tasks);
@@ -69,8 +62,15 @@ class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase
$names = array();
foreach ($tasks as $task)
{
$names[] = get_class($task->task);
$names[] = $task->get_name();
}
return $names;
}
private function create_cron_manager($tasks)
{
global $phpbb_root_path, $phpEx;
return new phpbb_cron_manager($tasks, $phpbb_root_path, $phpEx);
}
}

View File

@@ -11,31 +11,40 @@ class phpbb_cron_task_provider_test extends PHPUnit_Framework_TestCase
{
public function setUp()
{
$this->extension_manager = new phpbb_mock_extension_manager(
dirname(__FILE__) . '/',
array(
'testext' => array(
'ext_name' => 'testext',
'ext_active' => true,
'ext_path' => 'ext/testext/'
),
));
$this->provider = new phpbb_cron_task_provider($this->extension_manager);
$this->tasks = array(
'phpbb_cron_task_core_dummy_task',
'phpbb_cron_task_core_second_dummy_task',
'phpbb_ext_testext_cron_dummy_task',
);
$container = $this->getMock('Symfony\Component\DependencyInjection\TaggedContainerInterface');
$container
->expects($this->once())
->method('findTaggedServiceIds')
->will($this->returnValue(array_flip($this->tasks)));
$container
->expects($this->any())
->method('get')
->will($this->returnCallback(function ($name) {
return new $name;
}));
$this->provider = new phpbb_cron_task_provider($container);
}
public function test_manager_finds_shipped_tasks()
{
$tasks = array();
$task_names = array();
foreach ($this->provider as $task)
{
$tasks[] = $task;
$task_names[] = $task->get_name();
}
sort($tasks);
sort($task_names);
$this->assertEquals(array(
'phpbb_cron_task_core_dummy_task',
'phpbb_cron_task_core_second_dummy_task',
'phpbb_ext_testext_cron_dummy_task',
), $tasks);
), $task_names);
}
}

View File

@@ -2,6 +2,11 @@
class phpbb_cron_task_core_simple_not_runnable extends phpbb_cron_task_base
{
public function get_name()
{
return get_class($this);
}
public function run()
{
}

View File

@@ -2,6 +2,11 @@
class phpbb_cron_task_core_simple_ready extends phpbb_cron_task_base
{
public function get_name()
{
return get_class($this);
}
public function run()
{
}

View File

@@ -2,6 +2,11 @@
class phpbb_cron_task_core_simple_should_not_run extends phpbb_cron_task_base
{
public function get_name()
{
return get_class($this);
}
public function run()
{
}

View File

@@ -0,0 +1,102 @@
<?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_posting_test extends phpbb_functional_test_case
{
public function test_post_new_topic()
{
$this->login();
$this->add_lang('posting');
$crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
$this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text());
$hidden_fields = array();
$hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
});
$test_message = 'This is a test topic posted by the testing framework.';
$form_data = array(
'subject' => 'Test Topic 1',
'message' => $test_message,
'post' => true,
'f' => 2,
'mode' => 'post',
'sid' => $this->sid,
);
foreach ($hidden_fields as $fields)
{
foreach($fields as $field)
{
$form_data[$field['name']] = $field['value'];
}
}
// Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened)
// is not at least 2 seconds before submission, cancel the form
$form_data['lastclick'] = 0;
// I use a request because the form submission method does not allow you to send data that is not
// contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs)
// Instead, I send it as a request with the submit button "post" set to true.
$crawler = $this->client->request('POST', 'posting.php', $form_data);
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
$crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
$this->assertContains($test_message, $crawler->filter('html')->text());
}
public function test_post_reply()
{
$this->login();
$this->add_lang('posting');
$crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid);
$this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text());
$hidden_fields = array();
$hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
});
$test_message = 'This is a test post posted by the testing framework.';
$form_data = array(
'subject' => 'Re: Test Topic 1',
'message' => $test_message,
'post' => true,
't' => 2,
'f' => 2,
'mode' => 'reply',
'sid' => $this->sid,
);
foreach ($hidden_fields as $fields)
{
foreach($fields as $field)
{
$form_data[$field['name']] = $field['value'];
}
}
// For reasoning behind the following command, see the test_post_new_topic() test
$form_data['lastclick'] = 0;
// Submit the post
$crawler = $this->client->request('POST', 'posting.php', $form_data);
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
$crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
$this->assertContains($test_message, $crawler->filter('html')->text());
}
}

View File

@@ -45,6 +45,9 @@ class phpbb_session_append_sid_test extends phpbb_test_case
*/
public function test_append_sid($url, $params, $is_amp, $session_id, $expected, $description)
{
global $phpbb_dispatcher;
$phpbb_dispatcher = new phpbb_mock_event_dispatcher;
$this->assertEquals($expected, append_sid($url, $params, $is_amp, $session_id));
}
}

View File

@@ -199,7 +199,7 @@ class phpbb_functional_test_case extends phpbb_test_case
$this->do_request('create_table', $data);
$this->do_request('config_file', $data);
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true));
file_put_contents($phpbb_root_path . "config.$phpEx", phpbb_create_config_file_data($data, self::$config['dbms'], array(), true, true));
$this->do_request('final', $data);
copy($phpbb_root_path . "config.$phpEx", $phpbb_root_path . "config_test.$phpEx");