aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_framework/phpbb_functional_test_case.php
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-07-12 15:41:52 -0400
committerJoas Schilling <nickvergessen@gmx.de>2013-07-12 15:41:52 -0400
commit0297b88aafd3ef12217965f2879af9f9fd12d91f (patch)
treef7b7dcc32eddef4b61215c7a81061a3ffe0a219c /tests/test_framework/phpbb_functional_test_case.php
parente1bf87844b09e1359088ee55e4d500af97179926 (diff)
downloadforums-0297b88aafd3ef12217965f2879af9f9fd12d91f.tar
forums-0297b88aafd3ef12217965f2879af9f9fd12d91f.tar.gz
forums-0297b88aafd3ef12217965f2879af9f9fd12d91f.tar.bz2
forums-0297b88aafd3ef12217965f2879af9f9fd12d91f.tar.xz
forums-0297b88aafd3ef12217965f2879af9f9fd12d91f.zip
[ticket/9657] Add unit tests for softdeleting and moving posts/topics
PHPBB3-9657
Diffstat (limited to 'tests/test_framework/phpbb_functional_test_case.php')
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php48
1 files changed, 39 insertions, 9 deletions
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index 7e2e750e30..d2d16a4bda 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -767,6 +767,7 @@ class phpbb_functional_test_case extends phpbb_test_case
* Be sure to login before creating
*
* @param int $forum_id
+ * @param int $topic_id
* @param string $subject
* @param string $message
* @param array $additional_form_data Any additional form data to be sent in the request
@@ -823,18 +824,47 @@ 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);
$this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
-
$url = $crawler->selectLink($this->lang('VIEW_MESSAGE', '', ''))->link()->getUri();
- $matches = $topic_id = $post_id = false;
- preg_match_all('#&t=([0-9]+)(&p=([0-9]+))?#', $url, $matches);
-
- $topic_id = (int) (isset($matches[1][0])) ? $matches[1][0] : 0;
- $post_id = (int) (isset($matches[3][0])) ? $matches[3][0] : 0;
-
return array(
- 'topic_id' => $topic_id,
- 'post_id' => $post_id,
+ 'topic_id' => $this->get_parameter_from_link($url, 't'),
+ 'post_id' => $this->get_parameter_from_link($url, 'p'),
);
}
+
+ /*
+ * Returns the requested parameter from a URL
+ *
+ * @param string $url
+ * @param string $parameter
+ * @return string Value of the parameter in the URL, null if not set
+ */
+ public function get_parameter_from_link($url, $parameter)
+ {
+ if (strpos($url, '?') === false)
+ {
+ return null;
+ }
+
+ $url_parts = explode('?', $url);
+ if (isset($url_parts[1]))
+ {
+ $url_parameters = $url_parts[1];
+ if (strpos($url_parameters, '#') !== false)
+ {
+ $url_parameters = explode('#', $url_parameters);
+ $url_parameters = $url_parameters[0];
+ }
+
+ foreach (explode('&', $url_parameters) as $url_param)
+ {
+ list($param, $value) = explode('=', $url_param);
+ if ($param == $parameter)
+ {
+ return $value;
+ }
+ }
+ }
+ return null;
+ }
}