diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/RUNNING_TESTS.md | 14 | ||||
-rw-r--r-- | tests/acp_board/select_auth_method_test.php | 4 | ||||
-rw-r--r-- | tests/avatar/manager_test.php | 20 | ||||
-rw-r--r-- | tests/bbcode/parser_test.php | 2 | ||||
-rw-r--r-- | tests/cache/null_driver_test.php | 6 | ||||
-rw-r--r-- | tests/class_loader/class_loader_test.php | 2 | ||||
-rw-r--r-- | tests/controller/controller_test.php | 5 | ||||
-rw-r--r-- | tests/controller/helper_route_test.php | 28 | ||||
-rw-r--r-- | tests/cron/manager_test.php | 2 | ||||
-rw-r--r-- | tests/functional/extension_acp_test.php | 4 | ||||
-rw-r--r-- | tests/functional/feed_test.php | 52 | ||||
-rw-r--r-- | tests/functional/ucp_allow_pm_test.php | 70 | ||||
-rw-r--r-- | tests/functional/visibility_softdelete_test.php | 2 | ||||
-rw-r--r-- | tests/functions/build_url_test.php | 5 | ||||
-rw-r--r-- | tests/mock/controller_helper.php | 22 | ||||
-rw-r--r-- | tests/pagination/pagination_test.php | 8 | ||||
-rw-r--r-- | tests/passwords/drivers_test.php | 2 | ||||
-rw-r--r-- | tests/passwords/manager_test.php | 6 |
18 files changed, 172 insertions, 82 deletions
diff --git a/tests/RUNNING_TESTS.md b/tests/RUNNING_TESTS.md index 0778046141..d638c86859 100644 --- a/tests/RUNNING_TESTS.md +++ b/tests/RUNNING_TESTS.md @@ -128,12 +128,16 @@ Slow tests -------------- Certain tests, such as the UTF-8 normalizer or the DNS tests tend to be slow. -Thus these tests are in the `slow` group, which is excluded by default. You can -enable slow tests by copying the phpunit.xml.all file to phpunit.xml. If you +Thus these tests are in the `slow` group, which is excluded by default. If you only want the slow tests, run: $ phpBB/vendor/bin/phpunit --group slow +If you want all tests, run: + + $ phpBB/vendor/bin/phpunit --group __nogroup__,functional,slow + + Functional tests ----------------- @@ -154,10 +158,10 @@ on which to run tests. $phpbb_functional_url = 'http://localhost/phpBB3/'; -To then run the tests, you run PHPUnit, but use the phpunit.xml.functional -config file instead of the default one. Specify this through the "-c" option: +Functional tests are automatically run, if '$phpbb_functional_url' is configured. +If you only want the functional tests, run: - $ phpBB/vendor/bin/phpunit -c phpunit.xml.functional + $ phpBB/vendor/bin/phpunit --group functional This will change your board's config.php file, but it makes a backup at config_dev.php, so you can restore it after the test run is complete. diff --git a/tests/acp_board/select_auth_method_test.php b/tests/acp_board/select_auth_method_test.php index b943554564..1eb442bb3d 100644 --- a/tests/acp_board/select_auth_method_test.php +++ b/tests/acp_board/select_auth_method_test.php @@ -18,8 +18,8 @@ class phpbb_acp_board_select_auth_method_test extends phpbb_test_case public static function select_auth_method_data() { return array( - array('acp_board_valid', '<option value="acp_board_valid" selected="selected">Acp_board_valid</option>'), - array('acp_board_invalid', '<option value="acp_board_valid">Acp_board_valid</option>'), + array('acp_board_valid', '<option value="acp_board_valid" selected="selected" data-toggle-setting="#auth_acp_board_valid_settings">Acp_board_valid</option>'), + array('acp_board_invalid', '<option value="acp_board_valid" data-toggle-setting="#auth_acp_board_valid_settings">Acp_board_valid</option>'), ); } diff --git a/tests/avatar/manager_test.php b/tests/avatar/manager_test.php index 527bb223d5..69d4280b9a 100644 --- a/tests/avatar/manager_test.php +++ b/tests/avatar/manager_test.php @@ -9,29 +9,33 @@ require_once dirname(__FILE__) . '/driver/foobar.php'; -class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase +class phpbb_avatar_manager_test extends \phpbb_test_case { + /** @var \phpbb\avatar\manager */ + protected $manager; + protected $avatar_foobar; + protected $avatar_barfoo; + public function setUp() { global $phpbb_root_path, $phpEx; // Mock phpbb_container - $this->phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); - $this->phpbb_container->expects($this->any()) + $phpbb_container = $this->getMock('Symfony\Component\DependencyInjection\ContainerInterface'); + $phpbb_container->expects($this->any()) ->method('get') ->will($this->returnArgument(0)); // Prepare dependencies for avatar manager and driver $config = new \phpbb\config\config(array()); - $request = $this->getMock('\phpbb\request\request'); $cache = $this->getMock('\phpbb\cache\driver\driver_interface'); $path_helper = new \phpbb\path_helper( new \phpbb\symfony_request( new phpbb_mock_request() ), new \phpbb\filesystem(), - $this->phpbb_root_path, - $this->phpEx + $phpbb_root_path, + $phpEx ); // $this->avatar_foobar will be needed later on @@ -60,7 +64,7 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase $config['allow_avatar_' . get_class($this->avatar_barfoo)] = false; // Set up avatar manager - $this->manager = new \phpbb\avatar\manager($config, $avatar_drivers, $this->phpbb_container); + $this->manager = new \phpbb\avatar\manager($config, $avatar_drivers, $phpbb_container); } protected function avatar_drivers() @@ -222,8 +226,6 @@ class phpbb_avatar_manager_test extends PHPUnit_Framework_TestCase */ public function test_clean_row(array $input, array $output, $prefix = '') { - $cleaned_row = array(); - $cleaned_row = \phpbb\avatar\manager::clean_row($input, $prefix); foreach ($output as $key => $value) { diff --git a/tests/bbcode/parser_test.php b/tests/bbcode/parser_test.php index d0dcce5bbf..4bf5037f45 100644 --- a/tests/bbcode/parser_test.php +++ b/tests/bbcode/parser_test.php @@ -12,7 +12,7 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/functions_content.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/bbcode.php'; require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php'; -class phpbb_bbcode_parser_test extends PHPUnit_Framework_TestCase +class phpbb_bbcode_parser_test extends \phpbb_test_case { public function bbcode_firstpass_data() { diff --git a/tests/cache/null_driver_test.php b/tests/cache/null_driver_test.php index 58e57f2b3a..049d0412b6 100644 --- a/tests/cache/null_driver_test.php +++ b/tests/cache/null_driver_test.php @@ -35,14 +35,12 @@ class phpbb_cache_null_driver_test extends phpbb_database_test_case public function test_purge() { - // does nothing - $this->driver->purge(); + $this->assertNull($this->driver->purge()); } public function test_destroy() { - // does nothing - $this->driver->destroy('foo'); + $this->assertNull($this->driver->destroy('foo')); } public function test_cache_sql() diff --git a/tests/class_loader/class_loader_test.php b/tests/class_loader/class_loader_test.php index 6e551f658a..d3c7bb0579 100644 --- a/tests/class_loader/class_loader_test.php +++ b/tests/class_loader/class_loader_test.php @@ -7,7 +7,7 @@ * */ -class phpbb_class_loader_test extends PHPUnit_Framework_TestCase +class phpbb_class_loader_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/controller/controller_test.php b/tests/controller/controller_test.php index 7d9fe652eb..e0564f0a11 100644 --- a/tests/controller/controller_test.php +++ b/tests/controller/controller_test.php @@ -29,7 +29,8 @@ class phpbb_controller_controller_test extends phpbb_test_case public function test_provider() { - $provider = new \phpbb\controller\provider($this->extension_manager->get_finder()); + $provider = new \phpbb\controller\provider(); + $provider->find_routing_files($this->extension_manager->get_finder()); $routes = $provider->find(__DIR__)->get_routes(); // This will need to be updated if any new routes are defined @@ -67,7 +68,7 @@ class phpbb_controller_controller_test extends phpbb_test_case include(__DIR__.'/phpbb/controller/foo.php'); } - $resolver = new \phpbb\controller\resolver(new \phpbb\user, $container); + $resolver = new \phpbb\controller\resolver(new \phpbb\user, $container, dirname(__FILE__) . '/'); $symfony_request = new Request(); $symfony_request->attributes->set('_controller', 'foo.controller:handle'); diff --git a/tests/controller/helper_route_test.php b/tests/controller/helper_route_test.php index 5264c788c7..ae6f924a62 100644 --- a/tests/controller/helper_route_test.php +++ b/tests/controller/helper_route_test.php @@ -27,23 +27,25 @@ class phpbb_controller_helper_route_test extends phpbb_test_case ); $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()); + $this->extension_manager = new phpbb_mock_extension_manager( + dirname(__FILE__) . '/', + array( + 'vendor2/foo' => array( + 'ext_name' => 'vendor2/foo', + 'ext_active' => '1', + 'ext_path' => 'ext/vendor2/foo/', + ), + ) + ); $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/', - ), - ) - ), + $this->extension_manager, new \phpbb\filesystem(), dirname(__FILE__) . '/', new phpbb_mock_cache() ); - $this->provider = new \phpbb\controller\provider($finder); + $this->provider = new \phpbb\controller\provider(); + $this->provider->find_routing_files($finder); $this->provider->find(dirname(__FILE__) . '/'); } @@ -82,7 +84,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case */ 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, '', 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); } @@ -122,7 +124,7 @@ class phpbb_controller_helper_route_test extends phpbb_test_case 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->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $this->provider, $this->extension_manager, '', 'php', dirname(__FILE__) . '/'); $this->assertEquals($expected, $this->helper->route($route, $params, $is_amp, $session_id)); } } diff --git a/tests/cron/manager_test.php b/tests/cron/manager_test.php index 713f44c1e2..937add252f 100644 --- a/tests/cron/manager_test.php +++ b/tests/cron/manager_test.php @@ -14,7 +14,7 @@ require_once dirname(__FILE__) . '/tasks/simple_ready.php'; require_once dirname(__FILE__) . '/tasks/simple_not_runnable.php'; require_once dirname(__FILE__) . '/tasks/simple_should_not_run.php'; -class phpbb_cron_manager_test extends PHPUnit_Framework_TestCase +class phpbb_cron_manager_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/functional/extension_acp_test.php b/tests/functional/extension_acp_test.php index 5f02158e20..8a724f2133 100644 --- a/tests/functional/extension_acp_test.php +++ b/tests/functional/extension_acp_test.php @@ -157,7 +157,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $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->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('.errorbox')->text()); + $this->assertContains($this->lang('EXTENSION_ENABLE_CONFIRM', 'phpBB Moo Extension'), $crawler->filter('#main')->text()); } public function test_disable_pre() @@ -169,7 +169,7 @@ class phpbb_functional_extension_acp_test extends phpbb_functional_test_case $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=vendor2%2Ffoo&sid=' . $this->sid); - $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('.errorbox')->text()); + $this->assertContains($this->lang('EXTENSION_DISABLE_CONFIRM', 'phpBB Foo Extension'), $crawler->filter('#main')->text()); } public function test_delete_data_pre() diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index fbcbfa3943..86d3930a7b 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -480,7 +480,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_softdelete_post() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -504,7 +503,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_softdelete_post() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -532,7 +530,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_post_admin() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -575,7 +572,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_post_guest() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -609,7 +605,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_softdelete_topic() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -639,7 +634,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_topic_admin() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -709,7 +703,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_topic_guest() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -758,7 +751,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_unapproved_post() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -780,7 +772,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_post_admin() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -823,7 +814,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_post_disapprove_user() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -857,7 +847,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_unapproved_topic() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -877,7 +866,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_topic_admin() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -944,7 +932,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_topic_disapprove_user() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -1026,7 +1013,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assert_feeds(array( 'f' => array( array( - 'nb_entries' => 2, + 'nb_entries' => 4, 'id' => $this->data['forums']['Feeds #1'], 'attachments' => array( 1 => array( // First entry @@ -1054,7 +1041,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 11, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1067,7 +1054,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1080,7 +1067,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1093,7 +1080,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1153,7 +1140,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 7, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1166,7 +1153,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1179,7 +1166,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1192,7 +1179,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1208,7 +1195,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_missing_attachment_post() { - $this->markTestIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -1229,7 +1215,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_missing_attachment_admin() { - $this->markTestIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1265,7 +1250,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 13, + 'nb_entries' => 12, 'contents' => array( 1 => 'Attachment #0', ), @@ -1273,12 +1258,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], - 'displayed' => false, + 'displayed' => true, ), ), ), @@ -1286,12 +1271,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], - 'displayed' => false, + 'displayed' => true, ), ), ), @@ -1299,7 +1284,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'contents' => array( 1 => 'Attachment #0', ), @@ -1409,13 +1394,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case if ($attachment['displayed']) { $this->assertContains($url, $content, "Tested feed : 'feed.php{$params}'"); - // $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'"); + $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'"); } else { - // Disabled until PHPBB3-12421 is fixed and merged - // $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); - // $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'"); + $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); + $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'"); } } } diff --git a/tests/functional/ucp_allow_pm_test.php b/tests/functional/ucp_allow_pm_test.php new file mode 100644 index 0000000000..b433ec8e75 --- /dev/null +++ b/tests/functional/ucp_allow_pm_test.php @@ -0,0 +1,70 @@ +<?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_ucp_allow_pm_test extends phpbb_functional_test_case +{ + static protected $data = array(); + + public function __construct() + { + parent::__construct(); + + $this->backupStaticAttributesBlacklist += array( + 'phpbb_functional_ucp_allow_pm_test' => array('data'), + ); + } + + // user A sends a PM to user B where B accepts PM + public function test_enabled_pm_user_to_user() + { + // setup + $this->create_user('test_ucp_allow_pm_sender'); + $this->login('test_ucp_allow_pm_sender'); + self::$data['recipient_id'] = $this->create_user('test_ucp_allow_pm_recipient'); + self::$data['pm_url'] = "ucp.php?i=pm&mode=compose&u=" . (int) self::$data['recipient_id'] . "&sid={$this->sid}"; + + // the actual test + $this->set_user_allow_pm(self::$data['recipient_id'], 1); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); + } + + // user A sends a PM to user B where B does not accept PM + public function test_disabled_pm_user_to_user() + { + $this->login('test_ucp_allow_pm_sender'); + $this->set_user_allow_pm(self::$data['recipient_id'], 0); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('.error')->text()); + } + + + // An admin sends a PM to user B where B does not accept PM, but cannot + // ignore a PM from an admin + public function test_disabled_pm_admin_to_user() + { + $this->login(); + $crawler = self::request('GET', self::$data['pm_url']); + $this->assertNotContainsLang('PM_USERS_REMOVED_NO_PM', $crawler->filter('html')->text()); + } + + // enable or disable PM for a user, like from ucp + protected function set_user_allow_pm($user_id, $allow) + { + $db = $this->get_db(); + $sql = 'UPDATE ' . USERS_TABLE . " + SET user_allow_pm = " . $allow . " + WHERE user_id = " . $user_id; + $result = $db->sql_query($sql); + $db->sql_freeresult($result); + } +} diff --git a/tests/functional/visibility_softdelete_test.php b/tests/functional/visibility_softdelete_test.php index f8ada9687c..3d44476ff0 100644 --- a/tests/functional/visibility_softdelete_test.php +++ b/tests/functional/visibility_softdelete_test.php @@ -608,7 +608,7 @@ class phpbb_functional_visibility_softdelete_test extends phpbb_functional_test_ $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Soft Delete Topic #1']}&sid={$this->sid}"); $this->assertContains('Soft Delete Topic #1', $crawler->filter('h2')->text()); - $this->assertContainsLang('POST_DELETED', $crawler->filter('body')->text()); + $this->assertContainsLang('POST_DELETED_ACTION', $crawler->filter('body')->text()); $this->assert_forum_details($this->data['forums']['Soft Delete #1'], array( 'forum_posts_approved' => 1, diff --git a/tests/functions/build_url_test.php b/tests/functions/build_url_test.php index 795427ffe8..ad36f29b8c 100644 --- a/tests/functions/build_url_test.php +++ b/tests/functions/build_url_test.php @@ -45,6 +45,11 @@ class phpbb_build_url_test extends phpbb_test_case 'phpBB/index.php?', ), array( + 'viewtopic.php?t=5&f=4', + false, + 'phpBB/viewtopic.php?t=5&f=4', + ), + array( 'viewtopic.php?f=2&style=1&t=6', 'f', 'phpBB/viewtopic.php?style=1&t=6', diff --git a/tests/mock/controller_helper.php b/tests/mock/controller_helper.php new file mode 100644 index 0000000000..01ac6494d0 --- /dev/null +++ b/tests/mock/controller_helper.php @@ -0,0 +1,22 @@ +<?php +/** +* +* @package testing +* @copyright (c) 2014 phpBB Group +* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* +*/ + +class phpbb_mock_controller_helper extends \phpbb\controller\helper +{ + public function __construct(\phpbb\template\template $template, \phpbb\user $user, \phpbb\config\config $config, \phpbb\controller\provider $provider, \phpbb\extension\manager $manager, $phpbb_root_path, $php_ext, $phpbb_root_path_ext) + { + $this->template = $template; + $this->user = $user; + $this->config = $config; + $this->phpbb_root_path = $phpbb_root_path; + $this->php_ext = $php_ext; + $provider->find_routing_files($manager->get_finder()); + $this->route_collection = $provider->find($phpbb_root_path_ext)->get_routes(); + } +} diff --git a/tests/pagination/pagination_test.php b/tests/pagination/pagination_test.php index 71206dff58..f7a02dc419 100644 --- a/tests/pagination/pagination_test.php +++ b/tests/pagination/pagination_test.php @@ -30,17 +30,19 @@ class phpbb_pagination_pagination_test extends phpbb_template_template_test_case ->method('lang') ->will($this->returnCallback(array($this, 'return_callback_implode'))); + $manager = new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()); $this->finder = new \phpbb\extension\finder( - new phpbb_mock_extension_manager(dirname(__FILE__) . '/', array()), + $manager, 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 = new \phpbb\controller\provider(); + $provider->find_routing_files($this->finder); $provider->find(dirname(__FILE__) . '/'); - $this->helper = new \phpbb\controller\helper($this->template, $this->user, $this->config, $provider, '', 'php'); + $this->helper = new phpbb_mock_controller_helper($this->template, $this->user, $this->config, $provider, $manager, '', 'php', dirname(__FILE__) . '/'); $this->pagination = new \phpbb\pagination($this->template, $this->user, $this->helper); } diff --git a/tests/passwords/drivers_test.php b/tests/passwords/drivers_test.php index 40bb110185..df1474419b 100644 --- a/tests/passwords/drivers_test.php +++ b/tests/passwords/drivers_test.php @@ -7,7 +7,7 @@ * */ -class phpbb_passwords_helper_test extends PHPUnit_Framework_TestCase +class phpbb_passwords_helper_test extends \phpbb_test_case { public function setUp() { diff --git a/tests/passwords/manager_test.php b/tests/passwords/manager_test.php index 008f222696..561c4d1189 100644 --- a/tests/passwords/manager_test.php +++ b/tests/passwords/manager_test.php @@ -7,7 +7,7 @@ * */ -class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase +class phpbb_passwords_manager_test extends \phpbb_test_case { protected $passwords_drivers; @@ -176,7 +176,7 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase } } - public function test_combined_hash_data() + public function combined_hash_data() { if (version_compare(PHP_VERSION, '5.3.7', '<')) { @@ -242,7 +242,7 @@ class phpbb_passwords_manager_test extends PHPUnit_Framework_TestCase } /** - * @dataProvider test_combined_hash_data + * @dataProvider combined_hash_data */ public function test_combined_hash_password($first_type, $second_type, $expected = true) { |