mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-06 16:56:44 +02:00
Merge pull request #3616 from s9e/ticket/13847
[ticket/13847] Move quote generation to text_formatter.utils
This commit is contained in:
@@ -72,6 +72,20 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
|
||||
$this->assertContains('😀', $crawler->text());
|
||||
}
|
||||
|
||||
public function test_quote()
|
||||
{
|
||||
$text = 'Test post </textarea>"\' &&amp;';
|
||||
$expected = '[quote="admin"]' . $text . '[/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->assertContains($expected, $crawler->filter('textarea#message')->text());
|
||||
}
|
||||
|
||||
/**
|
||||
* @testdox max_quote_depth is applied to the text populating the posting form
|
||||
*/
|
||||
|
@@ -66,4 +66,31 @@ 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';
|
||||
$expected = '[quote="admin"]' . $text . '[/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', 'ucp.php?i=pm&mode=compose&action=quotepost&p=' . $post['post_id'] . '&sid=' . $this->sid);
|
||||
|
||||
$this->assertContains($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"]' . $text . '[/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());
|
||||
}
|
||||
}
|
||||
|
@@ -108,6 +108,72 @@ class phpbb_textformatter_s9e_utils_test extends phpbb_test_case
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_generate_quote_tests
|
||||
*/
|
||||
public function test_generate_quote($text, $params, $expected)
|
||||
{
|
||||
$container = $this->get_test_case_helpers()->set_s9e_services();
|
||||
$utils = $container->get('text_formatter.utils');
|
||||
|
||||
$this->assertSame($expected, $utils->generate_quote($text, $params));
|
||||
}
|
||||
|
||||
public function get_generate_quote_tests()
|
||||
{
|
||||
return array(
|
||||
array(
|
||||
'...',
|
||||
array(),
|
||||
'[quote]...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => 'Brian Kibler'),
|
||||
'[quote="Brian Kibler"]...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => 'Brian "Brian Kibler" Kibler of Brian Kibler Gaming'),
|
||||
'[quote=\'Brian "Brian Kibler" Kibler of Brian Kibler Gaming\']...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => "Brian Kibler Gaming's Brian Kibler"),
|
||||
'[quote="Brian Kibler Gaming\'s Brian Kibler"]...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => "\\\"'"),
|
||||
'[quote="\\\\\\"\'"]...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => 'Lots of doubles """ one single \' one backslash \\'),
|
||||
'[quote=\'Lots of doubles """ one single \\\' one backslash \\\\\']...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => "Lots of singles ''' one double \" one backslash \\"),
|
||||
'[quote="Lots of singles \'\'\' one double \\" one backslash \\\\"]...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array('author' => 'Defaults to doublequotes """\'\'\''),
|
||||
'[quote="Defaults to doublequotes \\"\\"\\"\'\'\'"]...[/quote]',
|
||||
),
|
||||
array(
|
||||
'...',
|
||||
array(
|
||||
'author' => 'user',
|
||||
'post_id' => 123,
|
||||
'url' => 'http://example.org'
|
||||
),
|
||||
'[quote="user" post_id="123" url="http://example.org"]...[/quote]',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider get_remove_bbcode_tests
|
||||
*/
|
||||
|
Reference in New Issue
Block a user