aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2013-06-29 15:49:23 +0200
committerJoas Schilling <nickvergessen@gmx.de>2013-06-29 15:49:23 +0200
commit8233c3e340a3608a6952ef444143a10e668d6561 (patch)
treea08e14baf9b7bb0304bdba5ca2eea10a0e453d1d /tests
parentc0c4ce8b8b523b90314502ded4c7c0b85e150a63 (diff)
parent91e773a79538a8fa26bea1d56384379b8730ac70 (diff)
downloadforums-8233c3e340a3608a6952ef444143a10e668d6561.tar
forums-8233c3e340a3608a6952ef444143a10e668d6561.tar.gz
forums-8233c3e340a3608a6952ef444143a10e668d6561.tar.bz2
forums-8233c3e340a3608a6952ef444143a10e668d6561.tar.xz
forums-8233c3e340a3608a6952ef444143a10e668d6561.zip
Merge remote-tracking branch 'dhruvgoel92/ticket/9341' into develop
* dhruvgoel92/ticket/9341: [ticket/9341] Assert that page doesnt contain next or prev page posts [ticket/9341] Follow the Next/Prev link in tests follow the next/prev link and then assert if the page contains its last post or not [ticket/9341] remove PREV_PAGE tpl var used for backward compatability [ticket/9341] Add tests for checking Next and Previous template vars [ticket/9341] Move create_topic and post into functional test case [ticket/9341] Use U_PREVIOUS and U_NEXT in template files [ticket/9341] Correctly named template vars
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/paging_test.php39
-rw-r--r--tests/functional/posting_test.php101
-rw-r--r--tests/test_framework/phpbb_functional_test_case.php101
3 files changed, 140 insertions, 101 deletions
diff --git a/tests/functional/paging_test.php b/tests/functional/paging_test.php
new file mode 100644
index 0000000000..d5adc6ad0a
--- /dev/null
+++ b/tests/functional/paging_test.php
@@ -0,0 +1,39 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+/**
+* @group functional
+*/
+class phpbb_functional_paging_test extends phpbb_functional_test_case
+{
+
+ public function test_pagination()
+ {
+ $this->login();
+
+ $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
+ for ($post_id = 1; $post_id < 20; $post_id++)
+ {
+ $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post no' . $post_id . ' posted by the testing framework.');
+ }
+ $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains('post no9', $crawler->text());
+ $this->assertNotContains('post no19', $crawler->text());
+
+ $next_link = $crawler->filter('#viewtopic > fieldset > a.arrow-right')->attr('href');
+ $crawler = self::request('GET', $next_link);
+ $this->assertContains('post no19', $crawler->text());
+ $this->assertNotContains('post no9', $crawler->text());
+
+ $prev_link = $crawler->filter('#viewtopic > fieldset > a.arrow-left')->attr('href');
+ $crawler = self::request('GET', $prev_link);
+ $this->assertContains('post no9', $crawler->text());
+ $this->assertNotContains('post no19', $crawler->text());
+ }
+}
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index 9bcfcc2fda..7fd1e4fdcf 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -32,105 +32,4 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
$crawler = self::request('GET', "posting.php?mode=quote&f=2&t={$post2['topic_id']}&p={$post2['post_id']}&sid={$this->sid}");
$this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
}
-
- /**
- * Creates a topic
- *
- * Be sure to login before creating
- *
- * @param int $forum_id
- * @param string $subject
- * @param string $message
- * @param array $additional_form_data Any additional form data to be sent in the request
- * @return array post_id, topic_id
- */
- public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
- {
- $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
-
- $form_data = array_merge(array(
- 'subject' => $subject,
- 'message' => $message,
- 'post' => true,
- ), $additional_form_data);
-
- return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
- }
-
- /**
- * Creates a post
- *
- * Be sure to login before creating
- *
- * @param int $forum_id
- * @param string $subject
- * @param string $message
- * @param array $additional_form_data Any additional form data to be sent in the request
- * @return array post_id, topic_id
- */
- public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
- {
- $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
-
- $form_data = array_merge(array(
- 'subject' => $subject,
- 'message' => $message,
- 'post' => true,
- ), $additional_form_data);
-
- return self::submit_post($posting_url, 'POST_REPLY', $form_data);
- }
-
- /**
- * Helper for submitting posts
- *
- * @param string $posting_url
- * @param string $posting_contains
- * @param array $form_data
- * @return array post_id, topic_id
- */
- protected function submit_post($posting_url, $posting_contains, $form_data)
- {
- $this->add_lang('posting');
-
- $crawler = self::request('GET', $posting_url);
- $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
-
- $hidden_fields = array(
- $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
- return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('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;
-
- // I use a request because the form submission method does not allow you to send data that is not
- // 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());
-
- $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,
- );
- }
}
diff --git a/tests/test_framework/phpbb_functional_test_case.php b/tests/test_framework/phpbb_functional_test_case.php
index e5da8de4ae..7e2e750e30 100644
--- a/tests/test_framework/phpbb_functional_test_case.php
+++ b/tests/test_framework/phpbb_functional_test_case.php
@@ -736,4 +736,105 @@ class phpbb_functional_test_case extends phpbb_test_case
return $result;
}
+
+ /**
+ * Creates a topic
+ *
+ * Be sure to login before creating
+ *
+ * @param int $forum_id
+ * @param string $subject
+ * @param string $message
+ * @param array $additional_form_data Any additional form data to be sent in the request
+ * @return array post_id, topic_id
+ */
+ public function create_topic($forum_id, $subject, $message, $additional_form_data = array())
+ {
+ $posting_url = "posting.php?mode=post&f={$forum_id}&sid={$this->sid}";
+
+ $form_data = array_merge(array(
+ 'subject' => $subject,
+ 'message' => $message,
+ 'post' => true,
+ ), $additional_form_data);
+
+ return self::submit_post($posting_url, 'POST_TOPIC', $form_data);
+ }
+
+ /**
+ * Creates a post
+ *
+ * Be sure to login before creating
+ *
+ * @param int $forum_id
+ * @param string $subject
+ * @param string $message
+ * @param array $additional_form_data Any additional form data to be sent in the request
+ * @return array post_id, topic_id
+ */
+ public function create_post($forum_id, $topic_id, $subject, $message, $additional_form_data = array())
+ {
+ $posting_url = "posting.php?mode=reply&f={$forum_id}&t={$topic_id}&sid={$this->sid}";
+
+ $form_data = array_merge(array(
+ 'subject' => $subject,
+ 'message' => $message,
+ 'post' => true,
+ ), $additional_form_data);
+
+ return self::submit_post($posting_url, 'POST_REPLY', $form_data);
+ }
+
+ /**
+ * Helper for submitting posts
+ *
+ * @param string $posting_url
+ * @param string $posting_contains
+ * @param array $form_data
+ * @return array post_id, topic_id
+ */
+ protected function submit_post($posting_url, $posting_contains, $form_data)
+ {
+ $this->add_lang('posting');
+
+ $crawler = self::request('GET', $posting_url);
+ $this->assertContains($this->lang($posting_contains), $crawler->filter('html')->text());
+
+ $hidden_fields = array(
+ $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
+ return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('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;
+
+ // I use a request because the form submission method does not allow you to send data that is not
+ // 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());
+
+ $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,
+ );
+ }
}