aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2013-11-27 14:55:05 +0100
committerMarc Alexander <admin@m-a-styles.de>2013-11-27 14:55:24 +0100
commit33f4d267ef9a3b65a1fbda82afa13ecc486b5c80 (patch)
tree2e19c6d0b72144d50197c01dcc2ad000913553ef /tests
parent0d4bf3ff45a76dcb763c76502944aa7bf78b690b (diff)
parent125e76f9aa83141534387a965e8373c9b9cd5c4d (diff)
downloadforums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar
forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar.gz
forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar.bz2
forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.tar.xz
forums-33f4d267ef9a3b65a1fbda82afa13ecc486b5c80.zip
Merge branch 'develop' of https://github.com/phpbb/phpbb3 into ticket/11842
Conflicts: phpBB/includes/acp/acp_groups.php
Diffstat (limited to 'tests')
-rw-r--r--tests/avatar/manager_test.php72
-rw-r--r--tests/dbal/migrator_tool_config_test.php91
-rw-r--r--tests/functional/avatar_acp_groups_test.php9
-rw-r--r--tests/functional/extension_acp_test.php171
-rw-r--r--tests/functional/extension_controller_test.php2
-rw-r--r--tests/functional/extension_global_lang_test.php3
-rw-r--r--tests/functional/extension_permission_lang_test.php3
-rw-r--r--tests/functional/fixtures/ext/foo/bar/composer.json2
-rw-r--r--tests/functional/fixtures/ext/foo/bar/config/services.yml9
-rw-r--r--tests/functional/fixtures/ext/foo/bar/event/permission.php9
-rw-r--r--tests/functional/fixtures/ext/foo/bar/event/user_setup.php9
-rw-r--r--tests/functional/notification_test.php33
-rw-r--r--tests/functions_install/ignore_new_file_on_update_test.php41
-rw-r--r--tests/notification/base.php1
-rw-r--r--tests/notification/submit_post_base.php2
-rw-r--r--tests/template/template_test.php10
-rw-r--r--tests/template/templates/define.html6
-rw-r--r--tests/template/templates/define_error.html2
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php26
19 files changed, 305 insertions, 196 deletions
diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php
index 4afa594beb..527bb223d5 100644
--- a/tests/avatar/manager_test.php
+++ b/tests/avatar/manager_test.php
@@ -112,7 +112,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
public function test_get_driver_enabled($driver_name, $expected)
{
$driver = $this->manager->get_driver($driver_name);
- $this->assertEquals($expected, $driver);
+ $this->assertEquals($expected, ($driver === null) ? null : $driver->get_name());
}
public function get_driver_data_all()
@@ -133,7 +133,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
public function test_get_driver_all($driver_name, $expected)
{
$driver = $this->manager->get_driver($driver_name, false);
- $this->assertEquals($expected, $driver);
+ $this->assertEquals($expected, ($driver === null) ? $driver : $driver->get_name());
}
public function test_get_avatar_settings()
@@ -152,12 +152,24 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
return array(
array(
array(
- 'user_avatar' => '',
- 'user_avatar_type' => '',
- 'user_avatar_width' => '',
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => '',
'user_avatar_height' => '',
+ 'group_avatar' => '',
),
array(
+ 'user_avatar' => '',
+ 'user_avatar_type' => '',
+ 'user_avatar_width' => '',
+ 'user_avatar_height' => '',
+ 'group_avatar' => '',
+ ),
+ 'foobar',
+ ),
+ array(
+ array(),
+ array(
'avatar' => '',
'avatar_type' => '',
'avatar_width' => '',
@@ -166,40 +178,41 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
),
array(
array(
- 'group_avatar' => '',
- 'group_avatar_type' => '',
- 'group_avatar_width' => '',
- 'group_avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
),
array(
- array(),
array(
- 'avatar' => '',
- 'avatar_type' => '',
- 'avatar_width' => '',
- 'avatar_height' => '',
+ 'user_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
+ ),
+ array(
+ 'avatar' => '',
+ 'id' => 5,
+ 'group_id' => 4,
),
+ 'user',
),
array(
array(
- 'foobar_avatar' => '',
- 'foobar_avatar_type' => '',
- 'foobar_avatar_width' => '',
- 'foobar_avatar_height' => '',
+ 'group_avatar' => '',
+ 'user_id' => 5,
+ 'group_id' => 4,
),
array(
- 'foobar_avatar' => '',
- 'foobar_avatar_type' => '',
- 'foobar_avatar_width' => '',
- 'foobar_avatar_height' => '',
+ 'avatar' => '',
+ 'id' => 'g4',
+ 'user_id' => 5,
),
+ 'group',
),
);
}
@@ -207,14 +220,15 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase
/**
* @dataProvider database_row_data
*/
- public function test_clean_row(array $input, array $output)
+ public function test_clean_row(array $input, array $output, $prefix = '')
{
$cleaned_row = array();
- $cleaned_row = \phpbb\avatar\manager::clean_row($input);
- foreach ($output as $key => $null)
+ $cleaned_row = \phpbb\avatar\manager::clean_row($input, $prefix);
+ foreach ($output as $key => $value)
{
$this->assertArrayHasKey($key, $cleaned_row);
+ $this->assertEquals($cleaned_row[$key], $value);
}
}
diff --git a/tests/dbal/migrator_tool_config_test.php b/tests/dbal/migrator_tool_config_test.php
index a8d8966839..807399385c 100644
--- a/tests/dbal/migrator_tool_config_test.php
+++ b/tests/dbal/migrator_tool_config_test.php
@@ -20,35 +20,24 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
public function test_add()
{
- try
- {
- $this->tool->add('foo', 'bar');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+ $this->tool->add('foo', 'bar');
+ $this->assertEquals('bar', $this->config['foo']);
+ }
+
+ public function test_add_twice()
+ {
+ $this->tool->add('foo', 'bar');
$this->assertEquals('bar', $this->config['foo']);
- try
- {
- $this->tool->add('foo', 'bar');
- $this->fail('Exception not thrown');
- }
- catch (Exception $e) {}
+ $this->tool->add('foo', 'bar2');
+ $this->assertEquals('bar', $this->config['foo']);
}
public function test_update()
{
$this->config->set('foo', 'bar');
- try
- {
- $this->tool->update('foo', 'bar2');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+
+ $this->tool->update('foo', 'bar2');
$this->assertEquals('bar2', $this->config['foo']);
}
@@ -56,24 +45,10 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
{
$this->config->set('foo', 'bar');
- try
- {
- $this->tool->update_if_equals('', 'foo', 'bar2');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+ $this->tool->update_if_equals('', 'foo', 'bar2');
$this->assertEquals('bar', $this->config['foo']);
- try
- {
- $this->tool->update_if_equals('bar', 'foo', 'bar2');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+ $this->tool->update_if_equals('bar', 'foo', 'bar2');
$this->assertEquals('bar2', $this->config['foo']);
}
@@ -81,41 +56,31 @@ class phpbb_dbal_migrator_tool_config_test extends phpbb_test_case
{
$this->config->set('foo', 'bar');
- try
- {
- $this->tool->remove('foo');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+ $this->tool->remove('foo');
$this->assertFalse(isset($this->config['foo']));
}
- public function test_reverse()
+ public function test_reverse_add()
{
$this->config->set('foo', 'bar');
- try
- {
- $this->tool->reverse('add', 'foo');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+ $this->tool->reverse('add', 'foo');
$this->assertFalse(isset($this->config['foo']));
+ }
+
+ public function test_reverse_remove()
+ {
+ $this->config->delete('foo');
+ $this->tool->reverse('remove', 'foo');
+ $this->assertEquals('', $this->config['foo']);
+ }
+
+ public function test_reverse_update_if_equals()
+ {
$this->config->set('foo', 'bar');
- try
- {
- $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
- }
- catch (Exception $e)
- {
- $this->fail($e);
- }
+ $this->tool->reverse('update_if_equals', 'test', 'foo', 'bar');
$this->assertEquals('test', $this->config['foo']);
}
}
diff --git a/tests/functional/avatar_acp_groups_test.php b/tests/functional/avatar_acp_groups_test.php
index 9fdc29cc76..5e908bc6da 100644
--- a/tests/functional/avatar_acp_groups_test.php
+++ b/tests/functional/avatar_acp_groups_test.php
@@ -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,
+ ),
+ ),
);
}
diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php
index 401b18f11c..5d391e42f7 100644
--- a/tests/functional/extension_acp_test.php
+++ b/tests/functional/extension_acp_test.php
@@ -77,59 +77,59 @@ 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(5, $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('The “test2” extension is not valid.', $crawler->filter('.ext_disabled')->eq(0)->text());
- $this->assertContains('The "test3" extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->text());
+ $this->assertContains('The “test3” extension is not valid.', $crawler->filter('.ext_disabled')->eq(1)->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('phpBB Moo Extension', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('DETAILS', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('EXTENSION_ENABLE', $crawler->filter('.ext_disabled')->eq(2)->text());
+ $this->assertContainsLang('EXTENSION_DELETE_DATA', $crawler->filter('.ext_disabled')->eq(2)->text());
- $this->assertContains('The "bar" extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->text());
+ $this->assertContains('The “bar” extension is not valid.', $crawler->filter('.ext_disabled')->eq(3)->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);
-
- $validation = array(
- 'DISPLAY_NAME' => 'phpBB Foo Extension',
- 'CLEAN_NAME' => 'foo/example',
- '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();
-
- $match = false;
-
- foreach ($validation as $language_key => $expected)
- {
- if (strpos($text, $this->lang($language_key)) === 0)
- {
- $match = true;
-
- $this->assertContains($expected, $text);
+ $crawler = self::request('GET', 'adm/index.php?i=acp_extensions&mode=main&action=details&ext_name=foo&sid=' . $this->sid);
+
+ $validation = array(
+ 'DISPLAY_NAME' => 'phpBB Foo Extension',
+ 'CLEAN_NAME' => 'foo/example',
+ '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();
+
+ $match = false;
+
+ foreach ($validation as $language_key => $expected)
+ {
+ if (strpos($text, $this->lang($language_key)) === 0)
+ {
+ $match = true;
+
+ $this->assertContains($expected, $text);
}
}
@@ -143,46 +143,73 @@ 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=foo&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());
-
- $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());
+ // 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->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());
-
- $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());
+ // 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());
+
+ // 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=foo&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());
-
- $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());
-
- $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 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());
+
+ // 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());
+
+ // 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());
}
}
diff --git a/tests/functional/extension_controller_test.php b/tests/functional/extension_controller_test.php
index 41bd48c204..37752b8fbb 100644
--- a/tests/functional/extension_controller_test.php
+++ b/tests/functional/extension_controller_test.php
@@ -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/',
);
diff --git a/tests/functional/extension_global_lang_test.php b/tests/functional/extension_global_lang_test.php
index fb8f87e6de..094eda8257 100644
--- a/tests/functional/extension_global_lang_test.php
+++ b/tests/functional/extension_global_lang_test.php
@@ -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()
diff --git a/tests/functional/extension_permission_lang_test.php b/tests/functional/extension_permission_lang_test.php
index 19adb89819..e922abdaf1 100644
--- a/tests/functional/extension_permission_lang_test.php
+++ b/tests/functional/extension_permission_lang_test.php
@@ -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()
diff --git a/tests/functional/fixtures/ext/foo/bar/composer.json b/tests/functional/fixtures/ext/foo/bar/composer.json
index cb9dbc9514..e3e5fc21cd 100644
--- a/tests/functional/fixtures/ext/foo/bar/composer.json
+++ b/tests/functional/fixtures/ext/foo/bar/composer.json
@@ -14,7 +14,7 @@
}],
"require": {
"php": ">=5.3",
- "phpbb": "3.1.*@dev"
+ "phpbb/phpbb": "3.1.*@dev"
},
"extra": {
"display-name": "phpBB 3.1 Extension Testing"
diff --git a/tests/functional/fixtures/ext/foo/bar/config/services.yml b/tests/functional/fixtures/ext/foo/bar/config/services.yml
index 3bca4c6567..64e1163408 100644
--- a/tests/functional/fixtures/ext/foo/bar/config/services.yml
+++ b/tests/functional/fixtures/ext/foo/bar/config/services.yml
@@ -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 }
+
diff --git a/tests/functional/fixtures/ext/foo/bar/event/permission.php b/tests/functional/fixtures/ext/foo/bar/event/permission.php
index 92e24074ad..9b319dd35f 100644
--- a/tests/functional/fixtures/ext/foo/bar/event/permission.php
+++ b/tests/functional/fixtures/ext/foo/bar/event/permission.php
@@ -11,15 +11,6 @@
namespace foo\bar\event;
/**
-* @ignore
-*/
-
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Event listener
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
diff --git a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php
index 1409f97470..8fa7ac97da 100644
--- a/tests/functional/fixtures/ext/foo/bar/event/user_setup.php
+++ b/tests/functional/fixtures/ext/foo/bar/event/user_setup.php
@@ -11,15 +11,6 @@
namespace foo\bar\event;
/**
-* @ignore
-*/
-
-if (!defined('IN_PHPBB'))
-{
- exit;
-}
-
-/**
* Event listener
*/
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php
index 7f33ad1859..dd1b8ec981 100644
--- a/tests/functional/notification_test.php
+++ b/tests/functional/notification_test.php
@@ -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());
+ }
}
diff --git a/tests/functions_install/ignore_new_file_on_update_test.php b/tests/functions_install/ignore_new_file_on_update_test.php
new file mode 100644
index 0000000000..703da4e435
--- /dev/null
+++ b/tests/functions_install/ignore_new_file_on_update_test.php
@@ -0,0 +1,41 @@
+<?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_install.php';
+
+class phpbb_functions_install_ignore_new_file_on_update_test extends phpbb_test_case
+{
+ static public function ignore_new_file_on_update_data()
+ {
+ return array(
+ array('willneverexist.php', false),
+ array('includes/dirwillneverexist/newfile.php', false),
+
+ array('language/en/email/short/bookmark.txt', false),
+ array('language/languagewillneverexist/email/short/bookmark.txt', true),
+
+ array('styles/prosilver/template/bbcode.html', false),
+ array('styles/stylewillneverexist/template/bbcode.html', true),
+
+ array('styles/prosilver/theme/en/icon_user_online.gif', false),
+ array('styles/prosilver/theme/languagewillneverexist/icon_user_online.gif', true),
+
+ array('styles/prosilver/theme/imageset.css', false),
+ );
+ }
+
+ /**
+ * @dataProvider ignore_new_file_on_update_data
+ */
+ public function test_ignore_new_file_on_update($file, $expected)
+ {
+ global $phpbb_root_path;
+ $this->assertEquals($expected, phpbb_ignore_new_file_on_update($phpbb_root_path, $file));
+ }
+}
diff --git a/tests/notification/base.php b/tests/notification/base.php
index 549545f01b..f6333866c3 100644
--- a/tests/notification/base.php
+++ b/tests/notification/base.php
@@ -70,6 +70,7 @@ abstract class phpbb_tests_notification_base extends phpbb_database_test_case
array(),
$this->container,
$this->user_loader,
+ $this->config,
$this->db,
$this->cache,
$this->user,
diff --git a/tests/notification/submit_post_base.php b/tests/notification/submit_post_base.php
index 8597c626a4..a9ed59686a 100644
--- a/tests/notification/submit_post_base.php
+++ b/tests/notification/submit_post_base.php
@@ -118,7 +118,7 @@ class phpbb_notification_submit_post_base extends phpbb_database_test_case
// Notification Manager
$phpbb_notifications = new \phpbb\notification\manager($notification_types_array, array(),
- $phpbb_container, $user_loader, $db, $cache, $user,
+ $phpbb_container, $user_loader, $config, $db, $cache, $user,
$phpbb_root_path, $phpEx,
NOTIFICATION_TYPES_TABLE, NOTIFICATIONS_TABLE, USER_NOTIFICATIONS_TABLE);
$phpbb_container->set('notification_manager', $phpbb_notifications);
diff --git a/tests/template/template_test.php b/tests/template/template_test.php
index 39eb08ab79..6e9b7d3ee9 100644
--- a/tests/template/template_test.php
+++ b/tests/template/template_test.php
@@ -158,7 +158,7 @@ class phpbb_template_template_test extends phpbb_template_template_test_case
array(),
array('test_loop' => array(array(), array(), array(), array(), array(), array(), array()), 'test' => array(array()), 'test.deep' => array(array()), 'test.deep.defines' => array(array())),
array(),
- "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|",
+ "xyz\nabc\n\$VALUE == 'abc'\n(\$VALUE == 'abc')\n((\$VALUE == 'abc'))\n!\$DOESNT_EXIST\n(!\$DOESNT_EXIST)\nabc\nbar\nbar\nabc\ntest!@#$%^&*()_-=+{}[]:;\",<.>/?[]|foobar|false",
),
array(
'define_advanced.html',
@@ -561,4 +561,12 @@ EOT
$expect = 'outer - 0[outer|4]outer - 1[outer|4]middle - 0[middle|1]outer - 2 - test[outer|4]middle - 0[middle|2]middle - 1[middle|2]outer - 3[outer|4]middle - 0[middle|3]middle - 1[middle|3]middle - 2[middle|3]';
$this->assertEquals($expect, str_replace(array("\n", "\r", "\t"), '', $this->display('test')), 'Ensuring S_NUM_ROWS is correct after modification');
}
+
+ /**
+ * @expectedException Twig_Error_Syntax
+ */
+ public function test_define_error()
+ {
+ $this->run_template('define_error.html', array(), array(), array(), '');
+ }
}
diff --git a/tests/template/templates/define.html b/tests/template/templates/define.html
index e7ce7f7def..276d2ebb99 100644
--- a/tests/template/templates/define.html
+++ b/tests/template/templates/define.html
@@ -29,3 +29,9 @@ $VALUE == 'abc'
<!-- DEFINE $VALUE = '' -->
[{$VALUE}]
<!-- DEFINE $TEST -->foobar<!-- ENDDEFINE -->|{$TEST}|
+<!-- DEFINE $VAR = false -->
+<!-- IF $VAR -->
+true
+<!-- ELSE -->
+false
+<!-- ENDIF -->
diff --git a/tests/template/templates/define_error.html b/tests/template/templates/define_error.html
new file mode 100644
index 0000000000..72ab1ba033
--- /dev/null
+++ b/tests/template/templates/define_error.html
@@ -0,0 +1,2 @@
+<!-- DEFINE $VAR = foo -->
+{$VAR}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index a0d186e0f2..eba5a2dfdf 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -868,9 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $subject
* @param string $message
* @param array $additional_form_data Any additional form data to be sent in the request
- * @return array post_id, topic_id
+ * @param string $expected Lang var of expected message after posting
+ * @return array|null post_id, topic_id if message is 'POST_STORED'
*/
- public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
+ public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
{
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
@@ -880,7 +881,7 @@ class phpbb_functional_test_case extends phpbb_test_case
'post' => true,
), $additional_form_data);
- return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
+ return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected);
}
/**
@@ -893,9 +894,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $subject
* @param string $message
* @param array $additional_form_data Any additional form data to be sent in the request
- * @return array post_id, topic_id
+ * @param string $expected Lang var of expected message after posting
+ * @return array|null post_id, topic_id if message is 'POST_STORED'
*/
- public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
+ public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
{
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
@@ -905,7 +907,7 @@ class phpbb_functional_test_case extends phpbb_test_case
'post' => true,
), $additional_form_data);
- return self::submit_post($posting_url, 'POST_REPLY', $form_data);
+ return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected);
}
/**
@@ -914,9 +916,10 @@ class phpbb_functional_test_case extends phpbb_test_case
* @param string $posting_url
* @param string $posting_contains
* @param array $form_data
- * @return array post_id, topic_id
+ * @param string $expected Lang var of expected message after posting
+ * @return array|null post_id, topic_id if message is 'POST_STORED'
*/
- protected function submit_post($posting_url, $posting_contains, $form_data)
+ protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED')
{
$this->add_lang('posting');
@@ -945,7 +948,12 @@ class phpbb_functional_test_case extends phpbb_test_case
// 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 = self::request('POST', $posting_url, $form_data);
- $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
+ $this->assertContainsLang($expected, $crawler->filter('html')->text());
+
+ if ($expected !== 'POST_STORED')
+ {
+ return;
+ }
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
return array(