diff options
Diffstat (limited to 'tests/functional')
| -rw-r--r-- | tests/functional/browse_test.php | 12 | ||||
| -rw-r--r-- | tests/functional/controllers_compatibility_test.php | 43 | ||||
| -rw-r--r-- | tests/functional/extension_module_test.php | 11 | ||||
| -rw-r--r-- | tests/functional/fileupload_remote_test.php | 11 | ||||
| -rw-r--r-- | tests/functional/fixtures/ext/foo/bar/acp/main_info.php | 1 | ||||
| -rw-r--r-- | tests/functional/fixtures/ext/foo/bar/ucp/main_info.php | 1 | ||||
| -rw-r--r-- | tests/functional/notification_test.php | 10 | ||||
| -rw-r--r-- | tests/functional/posting_test.php | 91 | ||||
| -rw-r--r-- | tests/functional/private_messages_test.php | 41 | ||||
| -rw-r--r-- | tests/functional/report_post_captcha_test.php | 7 | 
10 files changed, 197 insertions, 31 deletions
diff --git a/tests/functional/browse_test.php b/tests/functional/browse_test.php index b9e74a280f..4f28879687 100644 --- a/tests/functional/browse_test.php +++ b/tests/functional/browse_test.php @@ -34,6 +34,18 @@ class phpbb_functional_browse_test extends phpbb_functional_test_case  		$this->assertGreaterThan(0, $crawler->filter('.postbody')->count());  	} +	public function test_help_faq() +	{ +		$crawler = self::request('GET', 'app.php/help/faq'); +		$this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count()); +	} + +	public function test_help_bbcode() +	{ +		$crawler = self::request('GET', 'app.php/help/bbcode'); +		$this->assertGreaterThan(0, $crawler->filter('h2.faq-title')->count()); +	} +  	public function test_feed()  	{  		$crawler = self::request('GET', 'feed.php', array(), false); diff --git a/tests/functional/controllers_compatibility_test.php b/tests/functional/controllers_compatibility_test.php new file mode 100644 index 0000000000..7ba0b0d991 --- /dev/null +++ b/tests/functional/controllers_compatibility_test.php @@ -0,0 +1,43 @@ +<?php +/** +* +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. +* +*/ + +/** +* @group functional +*/ + +class phpbb_functional_controllers_compatibility_test extends phpbb_functional_test_case +{ +	public function test_report_compatibility() +	{ +		$this->assert301('report.php?f=1&p=1', 'app.php/post/1/report'); +		$this->assert301('report.php?p=1', 'app.php/post/1/report'); +		$this->assert301('report.php?pm=1', 'app.php/pm/1/report'); +	} + +	protected function assert301($from, $to) +	{ +		self::$client->followRedirects(false); +		self::request('GET', $from, array(), false); + +		// Fix sid issues +		$location = self::$client->getResponse()->getHeader('Location'); +		$location = preg_replace('#sid=[^&]+(&(amp;)?)?#', '', $location); +		if (substr($location, -1) === '?') +		{ +			$location = substr($location, 0, -1); +		} + +		$this->assertEquals(301, self::$client->getResponse()->getStatus()); +		$this->assertStringEndsWith($to, $location); +	} +} diff --git a/tests/functional/extension_module_test.php b/tests/functional/extension_module_test.php index ee084720e4..95107665cd 100644 --- a/tests/functional/extension_module_test.php +++ b/tests/functional/extension_module_test.php @@ -49,8 +49,9 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case  		$this->phpbb_extension_manager = $this->get_extension_manager();  		$this->phpbb_extension_manager->enable('foo/bar'); -		$modules = new acp_modules();  		$db = $this->get_db(); +		$cache = $this->get_cache_driver(); +		$modules = new \phpbb\module\module_manager($cache, $db, $this->phpbb_extension_manager, MODULES_TABLE, dirname(__FILE__) . '/../../phpBB/', 'php');  		$sql = 'SELECT module_id  			FROM ' . MODULES_TABLE . " @@ -70,7 +71,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case  			'module_mode'		=> '',  			'module_auth'		=> '',  		); -		$modules->update_module_data($parent_data, true); +		$modules->update_module_data($parent_data);  		$module_data = array(  			'module_basename'	=> 'foo\\bar\\acp\\main_module', @@ -82,7 +83,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case  			'module_mode'		=> 'mode',  			'module_auth'		=> '',  		); -		$modules->update_module_data($module_data, true); +		$modules->update_module_data($module_data);  		$parent_data = array(  			'module_basename'	=> '', @@ -94,7 +95,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case  			'module_mode'		=> '',  			'module_auth'		=> '',  		); -		$modules->update_module_data($parent_data, true); +		$modules->update_module_data($parent_data);  		$module_data = array(  			'module_basename'	=> 'foo\\bar\\ucp\\main_module', @@ -106,7 +107,7 @@ class phpbb_functional_extension_module_test extends phpbb_functional_test_case  			'module_mode'		=> 'mode',  			'module_auth'		=> '',  		); -		$modules->update_module_data($module_data, true); +		$modules->update_module_data($module_data);  		$this->purge_cache();  	} diff --git a/tests/functional/fileupload_remote_test.php b/tests/functional/fileupload_remote_test.php index 6ece150b23..4aa1a83b30 100644 --- a/tests/functional/fileupload_remote_test.php +++ b/tests/functional/fileupload_remote_test.php @@ -18,6 +18,8 @@ require_once __DIR__ . '/../../phpBB/includes/functions_upload.php';   */  class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case  { +	protected $filesystem; +  	public function setUp()  	{  		parent::setUp(); @@ -38,6 +40,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case  		$user = new phpbb_mock_user();  		$user->lang = new phpbb_mock_lang(); +		$this->filesystem = new \phpbb\filesystem\filesystem();  	}  	public function tearDown() @@ -49,21 +52,21 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case  	public function test_invalid_extension()  	{ -		$upload = new fileupload('', array('jpg'), 100); +		$upload = new fileupload($this->filesystem, '', array('jpg'), 100);  		$file = $upload->remote_upload(self::$root_url . 'develop/blank.gif');  		$this->assertEquals('URL_INVALID', $file->error[0]);  	}  	public function test_empty_file()  	{ -		$upload = new fileupload('', array('jpg'), 100); +		$upload = new fileupload($this->filesystem, '', array('jpg'), 100);  		$file = $upload->remote_upload(self::$root_url . 'develop/blank.jpg');  		$this->assertEquals('EMPTY_REMOTE_DATA', $file->error[0]);  	}  	public function test_successful_upload()  	{ -		$upload = new fileupload('', array('gif'), 1000); +		$upload = new fileupload($this->filesystem, '', array('gif'), 1000);  		$file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');  		$this->assertEquals(0, sizeof($file->error));  		$this->assertTrue(file_exists($file->filename)); @@ -71,7 +74,7 @@ class phpbb_functional_fileupload_remote_test extends phpbb_functional_test_case  	public function test_too_large()  	{ -		$upload = new fileupload('', array('gif'), 100); +		$upload = new fileupload($this->filesystem, '', array('gif'), 100);  		$file = $upload->remote_upload(self::$root_url . 'styles/prosilver/theme/images/forum_read.gif');  		$this->assertEquals(1, sizeof($file->error));  		$this->assertEquals('WRONG_FILESIZE', $file->error[0]); diff --git a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php index ec378e0e75..371ab7c967 100644 --- a/tests/functional/fixtures/ext/foo/bar/acp/main_info.php +++ b/tests/functional/fixtures/ext/foo/bar/acp/main_info.php @@ -28,7 +28,6 @@ class main_info  		return array(  			'filename'	=> 'foo\bar\acp\main_module',  			'title'		=> 'ACP_FOOBAR_TITLE', -			'version'	=> '1.0.0',  			'modes'		=> array(  				'mode'		=> array('title' => 'ACP_FOOBAR_MODE', 'auth' => '', 'cat' => array('ACP_FOOBAR_TITLE')),  			), diff --git a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php index d34244f800..4c74442639 100644 --- a/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php +++ b/tests/functional/fixtures/ext/foo/bar/ucp/main_info.php @@ -20,7 +20,6 @@ class main_info  		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')),  			), diff --git a/tests/functional/notification_test.php b/tests/functional/notification_test.php index ec03f7a6a4..87c36dd4d1 100644 --- a/tests/functional/notification_test.php +++ b/tests/functional/notification_test.php @@ -11,6 +11,8 @@  *  */ +require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php'; +  /**  * @group functional  */ @@ -21,15 +23,15 @@ class phpbb_functional_notification_test extends phpbb_functional_test_case  		return array(  			// Rows inserted by phpBB/install/schemas/schema_data.sql  			// Also see PHPBB3-11460 -			array('notification.type.post_notification', true), -			array('notification.type.topic_notification', true), +			array('notification.type.post_notification.method.board', true), +			array('notification.type.topic_notification.method.board', true),  			array('notification.type.post_notification.method.email', true),  			array('notification.type.topic_notification.method.email', true),  			// Default behaviour for in-board notifications:  			// If user did not opt-out, in-board notifications are on. -			array('notification.type.bookmark_notification', true), -			array('notification.type.quote_notification', true), +			array('notification.type.bookmark_notification.method.board', true), +			array('notification.type.quote_notification.method.board', true),  			// Default behaviour for email notifications:  			// If user did not opt-in, email notifications are off. diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 33632a01e1..724c42b289 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -45,14 +45,6 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case  		self::create_post(2,  			1, -			'Unsupported characters', -			"This is a test with these weird characters: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6", -			array(), -			'Your message contains the following unsupported characters' -		); - -		self::create_post(2, -			1,  			"Unsupported: \xF0\x9F\x88\xB3 \xF0\x9F\x9A\xB6",  			'This is a test with emoji characters in the topic title.',  			array(), @@ -60,6 +52,40 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case  		);  	} +	public function test_supported_unicode_characters() +	{ +		$this->login(); + +		$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); +		$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', "This is a test with these weird characters: \xF0\x9F\x84\x90 \xF0\x9F\x84\x91"); +		$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); +		$this->assertContains("\xF0\x9F\x84\x90 \xF0\x9F\x84\x91", $crawler->text()); +	} + +	public function test_html_entities() +	{ +		$this->login(); + +		$post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.'); +		$this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', '😀'); +		$crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); +		$this->assertContains('😀', $crawler->text()); +	} + +	public function test_quote() +	{ +		$text     = 'Test post </textarea>"\' &&amp;'; +		$expected = "(\\[quote=admin[^\\]]*\\]\n" . preg_quote($text) . "\n\\[/quote\\])"; + +		$this->login(); +		$topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); +		$post  = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + +		$crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post['topic_id']}&p={$post['post_id']}&sid={$this->sid}"); + +		$this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); +	} +  	/**  	* @testdox max_quote_depth is applied to the text populating the posting form  	*/ @@ -67,10 +93,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case  	{  		$text = '0[quote]1[quote]2[/quote]1[/quote]0';  		$expected = array( -			0 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', -			1 => '[quote="admin"]00[/quote]', -			2 => '[quote="admin"]0[quote]11[/quote]0[/quote]', -			3 => '[quote="admin"]0[quote]1[quote]2[/quote]1[/quote]0[/quote]', +			0 => '0[quote]1[quote]2[/quote]1[/quote]0', +			1 => '00', +			2 => '0[quote]11[/quote]0', +			3 => '0[quote]1[quote]2[/quote]1[/quote]0',  		);  		$this->login(); @@ -83,7 +109,10 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case  		{  			$this->set_quote_depth($quote_depth);  			$crawler = self::request('GET', $quote_url); -			$this->assertContains($expected_text, $crawler->filter('textarea#message')->text()); +			$this->assertRegexp( +				"(\\[quote=admin[^\\]]*\\]\n?" . preg_quote($expected_text) . "\n?\\[/quote\\])", +				$crawler->filter('textarea#message')->text() +			);  		}  	} @@ -140,4 +169,40 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case  		$crawler = self::submit($form);  		$this->assertEquals(1, $crawler->filter('.successbox')->count());  	} + +	public function test_ticket_8420() +	{ +		$text = '[b][url=http://example.org] :arrow: here[/url][/b]'; + +		$this->login(); +		$crawler = self::request('GET', 'posting.php?mode=post&f=2'); +		$form = $crawler->selectButton('Preview')->form(array( +			'subject' => 'Test subject', +			'message' => $text +		)); +		$crawler = self::submit($form); +		$this->assertEquals($text, $crawler->filter('#message')->text()); +	} + +	public function test_old_signature_in_preview() +	{ +		$sql = 'UPDATE ' . USERS_TABLE . " +			SET user_sig = '[b:2u8sdcwb]My signature[/b:2u8sdcwb]', +				user_sig_bbcode_uid = '2u8sdcwb', +				user_sig_bbcode_bitfield = 'QA==' +			WHERE user_id = 2"; +		$this->get_db()->sql_query($sql); + +		$this->login(); +		$crawler = self::request('GET', 'posting.php?mode=post&f=2'); +		$form = $crawler->selectButton('Preview')->form(array( +			'subject' => 'Test subject', +			'message' => 'My post', +		)); +		$crawler = self::submit($form); +		$this->assertContains( +			'<span style="font-weight: bold">My signature</span>', +			$crawler->filter('#preview .signature')->html() +		); +	}  } diff --git a/tests/functional/private_messages_test.php b/tests/functional/private_messages_test.php index 1f6dc3a979..7fda26fb49 100644 --- a/tests/functional/private_messages_test.php +++ b/tests/functional/private_messages_test.php @@ -66,4 +66,45 @@ class phpbb_functional_private_messages_test extends phpbb_functional_test_case  		$crawler = self::submit($form);  		$this->assertContains($this->lang('CONFIG_UPDATED'), $crawler->filter('.successbox')->text());  	} + +	public function test_quote_post() +	{ +		$text = 'Test post'; + +		$this->login(); +		$topic = $this->create_topic(2, 'Test Topic 1', 'Test topic'); +		$post  = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text); + +		$expected = '(\\[quote=admin post_id=' . $post['post_id'] . ' time=\\d+ user_id=2\\]' . $text . '\\[/quote\\])'; + +		$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid); + +		$this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); +	} + +	public function test_quote_pm() +	{ +		$text     = 'This is a test private message sent by the testing framework.'; +		$expected = "(\\[quote=admin time=\\d+ user_id=2\\]\n" . $text . "\n\\[/quote\\])"; + +		$this->login(); +		$message_id = $this->create_private_message('Test', $text, array(2)); + +		$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=quote&p=' . $message_id . '&sid=' . $this->sid); + +		$this->assertRegexp($expected, $crawler->filter('textarea#message')->text()); +	} + +	public function test_quote_forward() +	{ +		$text     = 'This is a test private message sent by the testing framework.'; +		$expected = "[quote=admin]\n" . $text . "\n[/quote]"; + +		$this->login(); +		$message_id = $this->create_private_message('Test', $text, array(2)); + +		$crawler = self::request('GET', 'ucp.php?i=pm&mode=compose&action=forward&f=0&p=' . $message_id . '&sid=' . $this->sid); + +		$this->assertContains($expected, $crawler->filter('textarea#message')->text()); +	}  } diff --git a/tests/functional/report_post_captcha_test.php b/tests/functional/report_post_captcha_test.php index 93a03bd931..36a1a9ee4d 100644 --- a/tests/functional/report_post_captcha_test.php +++ b/tests/functional/report_post_captcha_test.php @@ -18,12 +18,13 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca  {  	public function test_guest_report_post()  	{ -		$crawler = self::request('GET', 'report.php?f=2&p=1'); +		$crawler = self::request('GET', 'app.php/post/1/report', array(), false); +		$this->assert_response_html(403);  		$this->add_lang('mcp');  		$this->assertContains($this->lang('USER_CANNOT_REPORT'), $crawler->filter('html')->text());  		$this->set_reporting_guest(1); -		$crawler = self::request('GET', 'report.php?f=2&p=1'); +		$crawler = self::request('GET', 'app.php/post/1/report');  		$this->assertContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());  		$this->set_reporting_guest(-1);  	} @@ -31,7 +32,7 @@ class phpbb_functional_report_post_captcha_test extends phpbb_functional_test_ca  	public function test_user_report_post()  	{  		$this->login(); -		$crawler = self::request('GET', 'report.php?f=2&p=1'); +		$crawler = self::request('GET', 'app.php/post/1/report');  		$this->assertNotContains($this->lang('CONFIRM_CODE'), $crawler->filter('html')->text());  		$this->add_lang('mcp');  | 
