aboutsummaryrefslogtreecommitdiffstats
path: root/tests/functional
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2012-12-13 22:38:17 -0600
committerNathan Guse <nathaniel.guse@gmail.com>2012-12-13 22:38:17 -0600
commit9eb9fa2b9d117b919dfcc1e37d6c1186841b4fe7 (patch)
tree159614bad55edc1387603003bbd4295511883355 /tests/functional
parent2469225a721cfa49528a00dd8cae075de726277f (diff)
downloadforums-9eb9fa2b9d117b919dfcc1e37d6c1186841b4fe7.tar
forums-9eb9fa2b9d117b919dfcc1e37d6c1186841b4fe7.tar.gz
forums-9eb9fa2b9d117b919dfcc1e37d6c1186841b4fe7.tar.bz2
forums-9eb9fa2b9d117b919dfcc1e37d6c1186841b4fe7.tar.xz
forums-9eb9fa2b9d117b919dfcc1e37d6c1186841b4fe7.zip
[ticket/8610] Create helper functions to create topic/post in functional tests
This will be used to test splitting/copying/merging/etc in functional tests Also convert functional posting_test.php to use these functions PHPBB3-8610
Diffstat (limited to 'tests/functional')
-rw-r--r--tests/functional/posting_test.php89
1 files changed, 11 insertions, 78 deletions
diff --git a/tests/functional/posting_test.php b/tests/functional/posting_test.php
index f54a3591b2..6aa7a46974 100644
--- a/tests/functional/posting_test.php
+++ b/tests/functional/posting_test.php
@@ -15,88 +15,21 @@ class phpbb_functional_posting_test extends phpbb_functional_test_case
public function test_post_new_topic()
{
$this->login();
- $this->add_lang('posting');
- $crawler = $this->request('GET', 'posting.php?mode=post&f=2&sid=' . $this->sid);
- $this->assertContains($this->lang('POST_TOPIC'), $crawler->filter('html')->text());
+ // Test creating topic
+ $post = $this->create_topic(2, 'Test Topic 1', 'This is a test topic posted by the testing framework.');
- $hidden_fields = array();
- $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
- return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
- });
+ $crawler = $this->request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}");
+ $this->assertContains('This is a test topic posted by the testing framework.', $crawler->filter('html')->text());
- $test_message = 'This is a test topic posted by the testing framework.';
- $form_data = array(
- 'subject' => 'Test Topic 1',
- 'message' => $test_message,
- 'post' => true,
- 'f' => 2,
- 'mode' => 'post',
- 'sid' => $this->sid,
- );
+ // Test creating a reply
+ $post2 = $this->create_post(2, $post['topic_id'], 'Re: Test Topic 1', 'This is a test post posted by the testing framework.');
- foreach ($hidden_fields as $fields)
- {
- foreach($fields as $field)
- {
- $form_data[$field['name']] = $field['value'];
- }
- }
+ $crawler = $this->request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}");
+ $this->assertContains('This is a test post posted by the testing framework.', $crawler->filter('html')->text());
- // 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 = $this->client->request('POST', 'posting.php', $form_data);
- $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
-
- $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
- $this->assertContains($test_message, $crawler->filter('html')->text());
- }
-
- public function test_post_reply()
- {
- $this->login();
- $this->add_lang('posting');
-
- $crawler = $this->request('GET', 'posting.php?mode=reply&t=2&f=2&sid=' . $this->sid);
- $this->assertContains($this->lang('POST_REPLY'), $crawler->filter('html')->text());
-
- $hidden_fields = array();
- $hidden_fields[] = $crawler->filter('[type="hidden"]')->each(function ($node, $i) {
- return array('name' => $node->getAttribute('name'), 'value' => $node->getAttribute('value'));
- });
-
- $test_message = 'This is a test post posted by the testing framework.';
- $form_data = array(
- 'subject' => 'Re: Test Topic 1',
- 'message' => $test_message,
- 'post' => true,
- 't' => 2,
- 'f' => 2,
- 'mode' => 'reply',
- 'sid' => $this->sid,
- );
-
- foreach ($hidden_fields as $fields)
- {
- foreach($fields as $field)
- {
- $form_data[$field['name']] = $field['value'];
- }
- }
-
- // For reasoning behind the following command, see the test_post_new_topic() test
- $form_data['lastclick'] = 0;
-
- // Submit the post
- $crawler = $this->client->request('POST', 'posting.php', $form_data);
- $this->assertContains($this->lang('POST_STORED'), $crawler->filter('html')->text());
-
- $crawler = $this->request('GET', 'viewtopic.php?t=2&sid=' . $this->sid);
- $this->assertContains($test_message, $crawler->filter('html')->text());
+ // Test quoting a message
+ $crawler = $this->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());
}
}