diff options
author | Marc Alexander <admin@m-a-styles.de> | 2013-11-09 20:33:01 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2013-11-09 20:33:01 +0100 |
commit | 29d3b08d5097ad90a5ed2d26bfc981898732dbab (patch) | |
tree | 01748e61b5a682b13d8a3de01e4e91e5b3c46a97 /tests | |
parent | 252b5fe4f717494adde6644f257a044a661d2a7b (diff) | |
download | forums-29d3b08d5097ad90a5ed2d26bfc981898732dbab.tar forums-29d3b08d5097ad90a5ed2d26bfc981898732dbab.tar.gz forums-29d3b08d5097ad90a5ed2d26bfc981898732dbab.tar.bz2 forums-29d3b08d5097ad90a5ed2d26bfc981898732dbab.tar.xz forums-29d3b08d5097ad90a5ed2d26bfc981898732dbab.zip |
[ticket/11896] Add ability to define expected message after posting
This change will add the ability to define the expected message after a
topic or post has been submitted with the methods create_post() and
create_topic(). If the expected message is not 'POST_STORED', we will not
try to get the topic and post id.
PHPBB3-11896
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test_framework/phpbb_functional_test_case.php | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php index a0d186e0f2..64c8406adb 100644 --- a/tests/test_framework/phpbb_functional_test_case.php +++ b/tests/test_framework/phpbb_functional_test_case.php @@ -868,9 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request + * @param string $expected Lang var of expected message after posting * @return array post_id, topic_id */ - public function create_topic($forum_id, $subject, $message, $additional_form_data = array()) + public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}"; @@ -880,7 +881,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + if ($expected !== '') + { + return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected); + } + else + { + return self::submit_post($posting_url, 'POST_TOPIC', $form_data); + } } /** @@ -893,9 +901,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $subject * @param string $message * @param array $additional_form_data Any additional form data to be sent in the request + * @param string $expected Lang var of expected message after posting * @return array post_id, topic_id */ - public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array()) + public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '') { $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}"; @@ -905,7 +914,14 @@ class phpbb_functional_test_case extends phpbb_test_case 'post' => true, ), $additional_form_data); - return self::submit_post($posting_url, 'POST_REPLY', $form_data); + if ($expected !== '') + { + return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected); + } + else + { + return self::submit_post($posting_url, 'POST_REPLY', $form_data); + } } /** @@ -914,9 +930,10 @@ class phpbb_functional_test_case extends phpbb_test_case * @param string $posting_url * @param string $posting_contains * @param array $form_data - * @return array post_id, topic_id + * @param string $expected Lang var of expected message after posting + * @return array|null post_id, topic_id if message is 'POST_STORED' */ - protected function submit_post($posting_url, $posting_contains, $form_data) + protected function submit_post($posting_url, $posting_contains, $form_data, $expected = 'POST_STORED') { $this->add_lang('posting'); @@ -945,7 +962,12 @@ class phpbb_functional_test_case extends phpbb_test_case // contained in one of the actual form fields that the browser sees (i.e. it ignores "hidden" inputs) // Instead, I send it as a request with the submit button "post" set to true. $crawler = self::request('POST', $posting_url, $form_data); - $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text()); + $this->assertContains($this->lang($expected), $crawler->filter('html')->text()); + + if ($expected !== 'POST_STORED') + { + return; + } $url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri(); return array( |