From 65884bf2bd754343410a5b3d8b4eea2343dc42e9 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Mon, 9 Jun 2014 18:57:05 +0200 Subject: [PATCH] [ticket/11711] Reduce size of tests and also test topic titles PHPBB3-11711 --- tests/functional/posting_test.php | 41 ++++++------------- .../phpbb_functional_test_case.php | 7 +++- 2 files changed, 18 insertions(+), 30 deletions(-) diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php index 430a6496a0..b0a2f069e1 100644 --- a/tests/functional/posting_test.php +++ b/tests/functional/posting_test.php @@ -43,35 +43,18 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case $this->add_lang('posting'); - $crawler = self::request('GET', "posting.php?mode=reply&f=2&t=1&sid={$this->sid}"); + 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'); - $form = $crawler->selectButton('Submit')->form(); - - $hidden_fields = array( - $crawler->filter('[type="hidden"]')->each(function ($node, $i) { - return array('name' => $node->attr('name'), 'value' => $node->attr('value')); - }), - ); - - foreach ($hidden_fields as $fields) - { - foreach($fields as $field) - { - $form_data[$field['name']] = $field['value']; - } - } - - // Bypass time restriction that said that if the lastclick time (i.e. time when the form was opened) - // is not at least 2 seconds before submission, cancel the form - $form_data['lastclick'] = 0; - - $form_data += array( - 'subject' => 'Unsupported characters', - 'message' => 'This is a test with these weird characters: 👅👅👅', - 'post' => true, - ); - $crawler = self::request('POST', "posting.php?mode=reply&f=2&t=1&sid={$this->sid}", $form_data); - - $this->assertContains('Your message contains the following unsupported characters', $crawler->text()); + 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'); } } diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index 182ffaaaf7..c0127c50c9 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -996,11 +996,16 @@ class phpbb_functional_test_case extends phpbb_test_case // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); - if ($expected !== '') + if ($expected !== '' && isset($this->lang[$expected])) { $this->assertContainsLang($expected, $crawler->filter('html')->text()); return null; } + else if ($expected !== '') + { + $this->assertContains($expected, $crawler->filter('html')->text()); + return null; + } $url = $crawler->selectLink($form_data['subject'])->link()->getUri(); return array(