aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional/posting_test.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/functional/posting_test.php')
-rw-r--r--tests/functional/posting_test.php188
1 files changed, 166 insertions, 22 deletions
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 914233240e..49447e1133 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -29,7 +29,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
// Test creating a reply with bbcode
$post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test [b]post[/b] posted by the testing framework.');
- $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $crawler = self::request('GET', "viewtopic.php?p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
// Test quoting a message
@@ -41,23 +41,62 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$this->login();
- $this->add_lang('posting');
+ $post = $this->create_topic(2, "Test Topic \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji character in the topic title.');
+ $this->create_post(2, $post['topic_id'], "Re: Test Topic 1 \xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", 'This is a test with emoji characters in the topic title.');
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains("\xF0\x9F\xA4\x94 3\xF0\x9D\x94\xBB\xF0\x9D\x95\x9A", $crawler->text());
+ }
- 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'
- );
+ public function test_supported_unicode_characters()
+ {
+ $this->login();
- 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(),
- 'Your subject contains the following unsupported characters'
- );
+ $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;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());
+ }
+
+ /**
+ * @see https://tracker.phpbb.com/browse/PHPBB3-14962
+ */
+ public function test_edit()
+ {
+ $this->login();
+ $this->create_topic(2, 'Test Topic post', 'Test topic post');
+
+ $url = self::$client->getCrawler()->selectLink('Edit')->link()->getUri();
+ $post_id = $this->get_parameter_from_link($url, 'p');
+ $crawler = self::request('GET', "posting.php?mode=edit&f=2&p={$post_id}&sid={$this->sid}");
+ $form = $crawler->selectButton('Submit')->form();
+ $form->setValues(array('message' => 'Edited post'));
+ $crawler = self::submit($form);
+
+ $this->assertContains('Edited post', $crawler->filter("#post_content{$post_id} .content")->text());
}
/**
@@ -67,10 +106,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 +122,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()
+ );
}
}
@@ -114,7 +156,7 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
{
$this->set_quote_depth($quote_depth);
- $post = $this->create_post(2, $topic['topic_id'], 'Re: Test Topic 1', $text);
+ $post = $this->create_post(2, $topic['topic_id'], "Re: Test Topic 1#$quote_depth", $text);
$url = "viewtopic.php?p={$post['post_id']}&sid={$this->sid}";
$crawler = self::request('GET', $url);
@@ -156,4 +198,106 @@ 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(
+ '<strong class="text-strong">My signature</strong>',
+ $crawler->filter('#preview .signature')->html()
+ );
+ }
+
+ /**
+ * @ticket PHPBB3-10628
+ */
+ public function test_www_links_preview()
+ {
+ $text = 'www.example.org';
+ $url = 'http://' . $text;
+
+ $this->add_lang('posting');
+ $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);
+
+ // Test that the textarea remains unchanged
+ $this->assertEquals($text, $crawler->filter('#message')->text());
+
+ // Test that the preview contains the correct link
+ $this->assertEquals($url, $crawler->filter('#preview a')->attr('href'));
+ }
+
+ public function test_allowed_schemes_links()
+ {
+ $text = 'http://example.org/ tcp://localhost:22/ServiceName';
+
+ $this->login();
+ $this->admin_login();
+
+ // Post with default settings
+ $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->assertContains(
+ '<a href="http://example.org/" class="postlink">http://example.org/</a> tcp://localhost:22/ServiceName',
+ $crawler->filter('#preview .content')->html()
+ );
+
+ // Update allowed schemes
+ $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post');
+ $form = $crawler->selectButton('Submit')->form();
+ $values = $form->getValues();
+ $values['config[allowed_schemes_links]'] = 'https,tcp';
+ $form->setValues($values);
+ $crawler = self::submit($form);
+ $this->assertEquals(1, $crawler->filter('.successbox')->count());
+
+ // Post with new settings
+ $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->assertContains(
+ 'http://example.org/ <a href="tcp://localhost:22/ServiceName" class="postlink">tcp://localhost:22/ServiceName</a>',
+ $crawler->filter('#preview .content')->html()
+ );
+ }
}