mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08:52 +00:00
[ticket/11896] Minor code improvements in phpbb_functional_test_case
Use assertContainsLang() and get rid of unnecessary logic in create_post() and create_topic(). The docblocks were also slightly improved. PHPBB3-11896
This commit is contained in:
parent
95c2b12bf7
commit
308329b547
1 changed files with 7 additions and 21 deletions
|
@ -868,10 +868,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
* @param string $subject
|
* @param string $subject
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
* @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
|
* @param string $expected Lang var of expected message after posting or null
|
||||||
* @return array post_id, topic_id
|
* @return array post_id, topic_id
|
||||||
*/
|
*/
|
||||||
public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = '')
|
public function create_topic($forum_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
|
||||||
{
|
{
|
||||||
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
|
$posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
|
||||||
|
|
||||||
|
@ -881,15 +881,8 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
'post' => true,
|
'post' => true,
|
||||||
), $additional_form_data);
|
), $additional_form_data);
|
||||||
|
|
||||||
if ($expected !== '')
|
|
||||||
{
|
|
||||||
return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected);
|
return self::submit_post($posting_url, 'POST_TOPIC', $form_data, $expected);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a post
|
* Creates a post
|
||||||
|
@ -901,10 +894,10 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
* @param string $subject
|
* @param string $subject
|
||||||
* @param string $message
|
* @param string $message
|
||||||
* @param array $additional_form_data Any additional form data to be sent in the request
|
* @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
|
* @param string $expected Lang var of expected message after posting or null
|
||||||
* @return array post_id, topic_id
|
* @return array post_id, topic_id
|
||||||
*/
|
*/
|
||||||
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = '')
|
public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array(), $expected = 'POST_STORED')
|
||||||
{
|
{
|
||||||
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
|
$posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
|
||||||
|
|
||||||
|
@ -914,15 +907,8 @@ class phpbb_functional_test_case extends phpbb_test_case
|
||||||
'post' => true,
|
'post' => true,
|
||||||
), $additional_form_data);
|
), $additional_form_data);
|
||||||
|
|
||||||
if ($expected !== '')
|
|
||||||
{
|
|
||||||
return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected);
|
return self::submit_post($posting_url, 'POST_REPLY', $form_data, $expected);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
return self::submit_post($posting_url, 'POST_REPLY', $form_data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for submitting posts
|
* Helper for submitting posts
|
||||||
|
@ -962,7 +948,7 @@ 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)
|
// 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.
|
// Instead, I send it as a request with the submit button "post" set to true.
|
||||||
$crawler = self::request('POST', $posting_url, $form_data);
|
$crawler = self::request('POST', $posting_url, $form_data);
|
||||||
$this->assertContains($this->lang($expected), $crawler->filter('html')->text());
|
$this->assertContainsLang($expected, $crawler->filter('html')->text());
|
||||||
|
|
||||||
if ($expected !== 'POST_STORED')
|
if ($expected !== 'POST_STORED')
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue