From 103befc3d683a80da38fae5470315cb87a7860ae Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Sun, 20 Apr 2014 23:46:31 +0200 Subject: [ticket/12413] Tests: Adding functional tests for the feeds Some tests are disabled until PHPBB3-12418 (#2331) and PHPBB3-12421 (#2330) are fixed and merged PHPBB3-12413 --- tests/functional/feed_test.php | 1373 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 1373 insertions(+) create mode 100644 tests/functional/feed_test.php (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php new file mode 100644 index 0000000000..9aff0340f4 --- /dev/null +++ b/tests/functional/feed_test.php @@ -0,0 +1,1373 @@ +login(); + $this->admin_login(); + $this->create_user("disapprove_user"); + $this->add_user_group('NEWLY_REGISTERED', array('disapprove_user')); + + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Feeds #1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + )); + + // 'Feeds #1.1' is a sub-forum of 'Feeds #1' + $crawler = self::request('GET', "adm/index.php?i=acp_forums&sid={$this->sid}&icat=6&mode=manage&parent_id={$this->data['forums']['Feeds #1']}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Feeds #1.1', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + + // 'Feeds #news' will be used for feed.php?mode=news + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Feeds #news', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + + // 'Feeds #exclude' will not be displayed on feed.php?mode=forums + $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); + $form = $crawler->selectButton('addforum')->form(array( + 'forum_name' => 'Feeds #exclude', + )); + $crawler = self::submit($form); + $form = $crawler->selectButton('update')->form(array( + 'forum_perm_from' => 2, + )); + $crawler = self::submit($form); + } + + public function test_setup_config() + { + $this->login(); + $this->admin_login(); + + $this->load_ids(array( + 'forums' => array( + 'Feeds #news', + 'Feeds #exclude', + ), + )); + + $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=feed"); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + + // Enable all feeds + $values["config[feed_enable]"] = true; + $values["config[feed_forum]"] = true; + $values["config[feed_item_statistics]"] = true; + $values["config[feed_overall]"] = true; + $values["config[feed_overall_forums]"] = true; + $values["config[feed_topic]"] = true; + $values["config[feed_topics_active]"] = true; + $values["config[feed_topics_new]"] = true; + + $form->setValues($values); + + // News/Exclude's forums config + $form['feed_news_id']->select(array($this->data['forums']['Feeds #news'])); + $form['feed_exclude_id']->select(array($this->data['forums']['Feeds #exclude'])); + + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + + // News special config (Guest can't see attachments) + $this->add_lang('acp/permissions'); + + $crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1"); + $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); + + $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); + $form["setting[1][0][u_download]"]->select(-1); + + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + } + + public function test_feeds_empty() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + 'Feeds #1.1', + ), + )); + + // Excluded forums (and topics under them) shouldn't be displayed in feeds + $this->assert_feeds(array( + 'f' => array( + array( + 'id' => $this->data['forums']['Feeds #1'], + 'nb_entries' => 0, + ), + array( + 'id' => $this->data['forums']['Feeds #1.1'], + 'nb_entries' => 0, + ), + ), + 'forums' => array( + array( + 'nb_entries' => 4, + 'xpath' => array( + '//entry/category[@label="Feeds #exclude"]' => 0, + ), + ), + ), + 'news' => array( + array( + 'nb_entries' => 0, + ), + ), + ), 'admin'); + } + + public function test_create_exclude_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #exclude', + ), + )); + + $post = $this->create_topic($this->data['forums']['Feeds #exclude'], 'Feeds #exclude - Topic #1', 'This is a test topic posted by the testing framework.'); + $this->data['topics']['Feeds #exclude - Topic #1'] = (int) $post['topic_id']; + } + + public function test_feeds_exclude() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #exclude', + ), + 'topics' => array( + 'Feeds #exclude - Topic #1', + ), + )); + + // Assert that feeds aren't available for excluded forums + $this->assert_feeds(array( + 'f' => array( + array( + 'id' => $this->data['forums']['Feeds #exclude'], + 'contents_lang' => array('NO_FEED'), + 'invalid' => true, + ), + ), + 't' => array( + array( + 'id' => $this->data['topics']['Feeds #exclude - Topic #1'], + 'contents_lang' => array('NO_FEED'), + 'invalid' => true, + ), + ), + 'overall' => array( + array( + 'nb_entries' => 1, + 'xpath' => array( + '//entry/title[contains(., "#exclude")]' => 0, + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 1, + 'xpath' => array( + '//entry/title[contains(., "#exclude")]' => 0, + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 1, + 'xpath' => array( + '//entry/title[contains(., "#exclude")]' => 0, + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 1, + 'xpath' => array( + '//entry/title[contains(., "#exclude")]' => 0, + ), + ), + ), + ), 'admin'); + } + + public function test_create_news_topics() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #news', + ), + )); + + $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #1', 'This is a test topic posted by the testing framework.'); + $this->data['topics']['Feeds #news - Topic #1'] = (int) $post['topic_id']; + + $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); + $this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id']; + $this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + + // Test creating a reply + $post2 = $this->create_post($this->data['forums']['Feeds #news'], $post['topic_id'], 'Re: Feeds #news - Topic #2', 'This is a test post posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Re: Feeds #news - Topic #2', $crawler->filter('html')->text()); + $this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id']; + } + + public function test_feeds_news_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #news', + ), + 'topics' => array( + 'Feeds #news - Topic #1', + 'Feeds #news - Topic #2', + ), + 'posts' => array( + 'Feeds #news - Topic #2', + ), + )); + + // Assert that the first post of the two topics are displayed in news feed + $this->assert_feeds(array( + 'news' => array( + array( + 'nb_entries' => 2, + 'contents' => array( + 1 => 'This is a test topic posted by the testing framework.', + 2 => 'This is a test topic posted by the testing framework.', + ), + ), + ), + // News should also be displayed in other feeds + 'f' => array( + array( + 'nb_entries' => 3, + 'id' => $this->data['forums']['Feeds #news'], + ), + ), + 't' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['topics']['Feeds #news - Topic #1'], + ), + array( + 'nb_entries' => 2, + 'id' => $this->data['topics']['Feeds #news - Topic #2'], + ), + ), + 'overall' => array( + array( + 'nb_entries' => 4, + 'xpath' => array( + '//entry/title[contains(., "#news")]' => 3, + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 3, + 'xpath' => array( + '//entry/title[contains(., "#news")]' => 2, + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 3, + 'xpath' => array( + '//entry/title[contains(., "#news")]' => 2, + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 3, + 'xpath' => array( + '//entry/title[contains(., "#news")]' => 2, + ), + ), + ), + ), 'admin'); + } + + public function test_feeds_news_guest() + { + $this->load_ids(array( + 'posts' => array( + 'Feeds #news - Topic #2', + ), + )); + + // Assert that first post of the the two topics are displayed in news feed + $this->assert_feeds(array( + 'news' => array( + array( + 'nb_entries' => 2, + 'contents' => array( + 1 => 'This is a test topic posted by the testing framework.', + 2 => 'This is a test topic posted by the testing framework.', + ), + ), + ), + )); + } + + public function test_create_sub_forum_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + 'Feeds #1.1', + ), + )); + + $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #1', 'This is a test topic posted by the testing framework.'); + $this->data['topics']['Feeds #1 - Topic #1'] = (int) $post['topic_id']; + + $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #1', 'This is a test topic posted by the testing framework.'); + $this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id']; + } + + public function test_feeds_sub_forum() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + )); + + // The topics of the sub-forum shouldn't be displayed + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['forums']['Feeds #1'], + ), + ), + ), 'admin'); + } + + public function test_create_softdelete_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + )); + + $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #2', 'This is a test topic posted by the testing framework.'); + $this->data['topics']['Feeds #1 - Topic #2'] = (int) $post['topic_id']; + + // Test creating a reply + $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); + $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Re: Feeds #1 - Topic #2', $crawler->filter('html')->text()); + $this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id']; + } + + public function test_softdelete_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #2', + ), + 'posts' => array( + 'Re: Feeds #1 - Topic #2', + ), + )); + $this->add_lang('posting'); + + $crawler = self::request('GET', "posting.php?mode=delete&f={$this->data['forums']['Feeds #1']}&p={$this->data['posts']['Re: Feeds #1 - Topic #2']}&sid={$this->sid}"); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('POST_DELETED', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); + $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); + } + + public function test_feeds_softdeleted_post_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #2', + ), + )); + + // Assert that the soft-deleted post is marked as soft-delete for users that have the right to see it. + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 3, + 'id' => $this->data['forums']['Feeds #1'], + 'contents_lang' => array( + 1 => 'POST_DELETED', + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['topics']['Feeds #1 - Topic #2'], + 'contents_lang' => array( + 1 => 'POST_DELETED', + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 8, + 'contents_lang' => array( + 1 => 'POST_DELETED', + ), + ), + ), + ), 'admin'); + } + + public function test_feeds_softdeleted_post_guest() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #2', + ), + )); + + // Assert that the soft-deleted post is marked as soft-delete for users that have the right to see it. + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['forums']['Feeds #1'], + ), + ), + 't' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['topics']['Feeds #1 - Topic #2'], + ), + ), + 'overall' => array( + array( + 'nb_entries' => 7, + ), + ), + )); + } + + public function test_softdelete_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #2', + ), + )); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); + + $this->add_lang('posting'); + $form = $crawler->selectButton('Go')->eq(2)->form(); + $form['action']->select('delete_topic'); + $crawler = self::submit($form); + $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); + + $this->add_lang('mcp'); + $form = $crawler->selectButton('Yes')->form(); + $crawler = self::submit($form); + $this->assertContainsLang('TOPIC_DELETED_SUCCESS', $crawler->text()); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); + $this->assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); + } + + public function test_feeds_softdeleted_topic_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #2', + ), + )); + + // Assert that the soft-deleted post is marked as soft-delete for users that have the right to see it. + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 3, + 'id' => $this->data['forums']['Feeds #1'], + 'contents_lang' => array( + 1 => 'POST_DELETED', + 2 => 'POST_DELETED', + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['topics']['Feeds #1 - Topic #2'], + 'contents_lang' => array( + 1 => 'POST_DELETED', + 2 => 'POST_DELETED', + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 8, + 'contents_lang' => array( + 1 => 'POST_DELETED', + 2 => 'POST_DELETED', + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 6, + 'contents_lang' => array( + 1 => 'TOPIC_DELETED', + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 6, + 'contents_lang' => array( + 1 => 'TOPIC_DELETED', + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 6, + 'contents_lang' => array( + 1 => 'TOPIC_DELETED', + ), + ), + ), + ), 'admin'); + } + + public function test_feeds_softdeleted_topic_guest() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #2', + ), + )); + + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['forums']['Feeds #1'], + ), + ), + 't' => array( + array( + 'id' => $this->data['topics']['Feeds #1 - Topic #2'], + 'contents_lang' => array('SORRY_AUTH_READ'), + 'invalid' => true, + ), + ), + 'overall' => array( + array( + 'nb_entries' => 6, + ), + ), + 'topics' => array( + array( + 'nb_entries' => 5, + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 5, + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 5, + ), + ), + )); + } + + public function test_create_unapproved_post() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1.1', + ), + )); + + $this->login('admin'); + $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #2', 'This is a test topic posted by the testing framework.'); + $this->data['topics']['Feeds #1.1 - Topic #2'] = (int) $post['topic_id']; + $this->logout(); + + // Test creating a reply + $this->login("disapprove_user"); + $post2 = $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); + + $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1.1 - Topic #2']}&sid={$this->sid}"); + $this->assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); + } + + public function test_feeds_unapproved_post_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1.1', + ), + 'topics' => array( + 'Feeds #1.1 - Topic #2', + ), + )); + + // Assert that the unapproved post is marked as unapproved for users that have the right to see it. + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 3, + 'id' => $this->data['forums']['Feeds #1.1'], + 'contents_lang' => array( + 1 => 'POST_UNAPPROVED', + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['topics']['Feeds #1.1 - Topic #2'], + 'contents_lang' => array( + 1 => 'POST_UNAPPROVED', + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 10, + 'contents_lang' => array( + 1 => 'POST_UNAPPROVED', + ), + ), + ), + ), 'admin'); + } + + public function test_feeds_unapproved_post_disapprove_user() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1.1', + ), + 'topics' => array( + 'Feeds #1.1 - Topic #2', + ), + )); + + // Assert that the unapproved isn't displayed for regular users + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['forums']['Feeds #1.1'], + ), + ), + 't' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['topics']['Feeds #1.1 - Topic #2'], + ), + ), + 'overall' => array( + array( + 'nb_entries' => 7, + ), + ), + ), 'disapprove_user'); + } + + public function test_create_unapproved_topic() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1.1', + ), + )); + + // We have to wait because of the flood interval. + sleep(15); + + $this->login("disapprove_user"); + $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); + $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; + $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); + + $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); + } + + public function test_feeds_unapproved_topic_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1.1', + ), + 'topics' => array( + 'Feeds #1.1 - Topic #3', + ), + )); + + // Assert that the unapproved topic is marked as unapproved for users that have the right to see it. + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 4, + 'id' => $this->data['forums']['Feeds #1.1'], + 'contents_lang' => array( + 1 => 'POST_UNAPPROVED', + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['topics']['Feeds #1.1 - Topic #3'], + 'contents_lang' => array( + 1 => 'POST_UNAPPROVED', + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 11, + 'contents_lang' => array( + 1 => 'POST_UNAPPROVED', + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 8, + 'contents_lang' => array( + 1 => 'TOPIC_UNAPPROVED', + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 8, + 'contents_lang' => array( + 1 => 'TOPIC_UNAPPROVED', + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 8, + 'contents_lang' => array( + 1 => 'TOPIC_UNAPPROVED', + ), + ), + ), + ), 'admin'); + } + + public function test_feeds_unapproved_topic_disapprove_user() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1.1', + ), + 'topics' => array( + 'Feeds #1.1 - Topic #3', + ), + )); + + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['forums']['Feeds #1.1'], + ), + ), + 't' => array( + array( + 'id' => $this->data['topics']['Feeds #1.1 - Topic #3'], + 'contents_lang' => array('SORRY_AUTH_READ'), + 'invalid' => true, + ), + ), + 'overall' => array( + array( + 'nb_entries' => 7, + ), + ), + 'topics' => array( + array( + 'nb_entries' => 6, + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 6, + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 6, + ), + ), + ), 'disapprove_user'); + } + + public function test_create_attachment_topic() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + )); + + // Test creating a topic with 1 attachment + $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #3', 'This is a test topic posted by the testing framework. [attachment=0]Attachment #0[/attachment]', array('upload_files' => 1)); + $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Feeds #1 - Topic #3', $crawler->filter('html')->text()); + $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; + } + + public function test_feeds_attachment_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #3', + ), + 'posts' => array( + 'Feeds #1 - Topic #3', + ), + 'attachments' => true, + )); + + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 4, + 'id' => $this->data['forums']['Feeds #1'], + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => true, + ), + ), + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['topics']['Feeds #1 - Topic #3'], + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => true, + ), + ), + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 12, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => true, + ), + ), + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 9, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => true, + ), + ), + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 9, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => true, + ), + ), + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 9, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => true, + ), + ), + ), + ), + ), + ), 'admin'); + } + + public function test_feeds_attachment_guest() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #3', + ), + 'posts' => array( + 'Feeds #1 - Topic #3', + ), + 'attachments' => true, + )); + + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['forums']['Feeds #1'], + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 1, + 'id' => $this->data['topics']['Feeds #1 - Topic #3'], + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 8, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 7, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 7, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 7, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + )); + } + + // Disabled until PHPBB3-12418 is fixed and merged + /*public function test_create_missing_attachment_post() + { + $this->login(); + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #3', + ), + )); + + // Test creating a reply with 1 missing attachment + $post2 = $this->create_post($this->data['forums']['Feeds #1'], $this->data['topics']['Feeds #1 - Topic #3'], 'Re: Feeds #1 - Topic #3-1', 'This is a test post posted by the testing framework. [attachment=0]Attachment #0[/attachment]'); + $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); + + $this->assertContains('Re: Feeds #1 - Topic #3-1', $crawler->filter('html')->text()); + $this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id']; + } + + public function test_feeds_missing_attachment_admin() + { + $this->load_ids(array( + 'forums' => array( + 'Feeds #1', + ), + 'topics' => array( + 'Feeds #1 - Topic #3', + ), + 'posts' => array( + 'Feeds #1 - Topic #3', + ), + )); + + $this->add_lang('viewtopic'); + + $this->assert_feeds(array( + 'f' => array( + array( + 'nb_entries' => 5, + 'id' => $this->data['forums']['Feeds #1'], + 'contents' => array( + 1 => 'Attachment #0', + ), + ), + ), + 't' => array( + array( + 'nb_entries' => 2, + 'id' => $this->data['topics']['Feeds #1 - Topic #3'], + 'contents' => array( + 1 => 'Attachment #0', + ), + ), + ), + 'overall' => array( + array( + 'nb_entries' => 13, + 'contents' => array( + 1 => 'Attachment #0', + ), + ), + ), + 'topics' => array( + array( + 'nb_entries' => 9, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 'topics_new' => array( + array( + 'nb_entries' => 9, + 'attachments' => array( + 1 => array( // First entry + array( // First attachment to fetch + 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], + 'displayed' => false, + ), + ), + ), + ), + ), + 'topics_active' => array( + array( + 'nb_entries' => 9, + 'contents' => array( + 1 => 'Attachment #0', + ), + ), + ), + ), 'admin'); + }*/ + + protected function assert_feeds($data, $username = false) + { + if ($username) + { + $this->login($username); + } + + foreach ($data as $mode => $feeds) + { + foreach ($feeds as $feed_data) + { + if ($mode === 'f' || $mode === 't') + { + $params = "?{$mode}={$feed_data['id']}"; + $this->assert_feed($params, $feed_data); + } + else + { + $params = "?mode={$mode}"; + $this->assert_feed($params, $feed_data); + } + } + } + } + + protected function assert_feed($params, $data) + { + $crawler = self::request('GET', 'feed.php' . $params, array(), false); + + if (!(isset($data['invalid']) && $data['invalid'])) + { + self::assert_response_xml(); + $this->assertEquals($data['nb_entries'], $crawler->filter('entry')->count(), "Tested feed : 'feed.php{$params}'"); + + if (sizeof($data['xpath'])) { + foreach($data['xpath'] as $xpath => $count_expected) + { + $this->assertCount($count_expected, $crawler->filterXPath($xpath), "Tested feed : 'feed.php{$params}', Search for {$xpath}"); + } + } + + if (sizeof($data['contents'])) { + foreach($data['contents'] as $entry_id => $string) + { + $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); + $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); + } + } + + if (sizeof($data['contents_lang'])) { + foreach($data['contents_lang'] as $entry_id => $string) + { + $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); + $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'"); + } + } + + if (sizeof($data['attachments'])) { + foreach($data['attachments'] as $entry_id => $attachments) + { + foreach ($attachments as $i => $attachment) + { + $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); + $url = "./download/file.php?id={$attachment['id']}"; + $string = "Attachment #{$i}"; + + if ($attachment['displayed']) + { + $this->assertContains($url, $content, "Tested feed : 'feed.php{$params}'"); + // $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'"); + } + else + { + // Disabled until PHPBB3-12421 is fixed and merged + // $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); + // $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'"); + } + } + } + } + } + else + { + self::assert_response_html(); + + if (sizeof($data['contents_lang'])) { + foreach($data['contents_lang'] as $string) + { + $content = $crawler->filter("html")->text(); + $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'"); + } + } + } + } + + protected function load_ids($data) + { + $this->db = $this->get_db(); + + if (!empty($data['forums'])) + { + $sql = 'SELECT * + FROM phpbb_forums + WHERE ' . $this->db->sql_in_set('forum_name', $data['forums']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['forum_name'], $data['forums'])) + { + $this->data['forums'][$row['forum_name']] = (int) $row['forum_id']; + } + } + $this->db->sql_freeresult($result); + } + + if (!empty($data['topics'])) + { + $sql = 'SELECT * + FROM phpbb_topics + WHERE ' . $this->db->sql_in_set('topic_title', $data['topics']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['topic_title'], $data['topics'])) + { + $this->data['topics'][$row['topic_title']] = (int) $row['topic_id']; + } + } + $this->db->sql_freeresult($result); + } + + $post_ids = array(); + if (!empty($data['posts'])) + { + $sql = 'SELECT * + FROM phpbb_posts + WHERE ' . $this->db->sql_in_set('post_subject', $data['posts']); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + if (in_array($row['post_subject'], $data['posts'])) + { + $this->data['posts'][$row['post_subject']] = (int) $row['post_id']; + $post_ids[] = (int) $row['post_id']; + } + } + $this->db->sql_freeresult($result); + + if (isset($data['attachments'])) + { + $sql = 'SELECT * + FROM phpbb_attachments + WHERE in_message = 0 AND ' . $this->db->sql_in_set('post_msg_id', $post_ids); + $result = $this->db->sql_query($sql); + while ($row = $this->db->sql_fetchrow($result)) + { + $this->data['attachments'][(int) $row['post_msg_id']][] = (int) $row['attach_id']; + } + $this->db->sql_freeresult($result); + } + } + } +} -- cgit v1.2.1 From 13d939b7e104425dc6710c6b3e71e8c3acb95321 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 21 Apr 2014 01:39:12 +0200 Subject: [ticket/12413] Useing @depends to transmit the state of the board the state of the board is calculate in the first test and transmit to the others thanks to the @depends annotation. PHPBB3-12413 --- tests/functional/feed_test.php | 418 ++++++++++++++++++++++++++++++++--------- 1 file changed, 328 insertions(+), 90 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 9aff0340f4..c6d4fee8fd 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -14,8 +14,110 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { protected $data = array(); - public function test_setup_forums() + private $init_values = array(); + + public function test_setup_config_before_state() + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=feed"); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + + $this->init_values['post_base_items'] = (int)$values['config[feed_limit_post]']; + $this->init_values['topic_base_items'] = (int)$values['config[feed_limit_topic]']; + + // Enable all feeds + $values["config[feed_enable]"] = true; + $values["config[feed_forum]"] = true; + $values["config[feed_item_statistics]"] = true; + $values["config[feed_overall]"] = true; + $values["config[feed_overall_forums]"] = true; + $values["config[feed_topic]"] = true; + $values["config[feed_topics_active]"] = true; + $values["config[feed_topics_new]"] = true; + + $form->setValues($values); + + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + + // Special config (Guest can't see attachments) + $this->add_lang('acp/permissions'); + + $crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1"); + $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); + + $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); + $form["setting[1][0][u_download]"]->select(-1); + + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + + return $this->init_values; + } + + /** + * @depends test_setup_config_before_state + */ + public function test_dump_board_state($init_values) + { + $this->init_values = $init_values; + + $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); + self::assert_response_xml(); + $this->init_values['disapprove_user']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); + self::assert_response_xml(); + $this->init_values['disapprove_user']['overall_value'] = $crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); + self::assert_response_xml(); + $this->init_values['disapprove_user']['topics_value'] = $crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); + self::assert_response_xml(); + $this->init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); + self::assert_response_xml(); + $this->init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + + $this->login(); + + $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); + self::assert_response_xml(); + $this->init_values['admin']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); + self::assert_response_xml(); + $this->init_values['admin']['overall_value'] = $crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); + self::assert_response_xml(); + $this->init_values['admin']['topics_value'] = $crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); + self::assert_response_xml(); + $this->init_values['admin']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); + + $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); + self::assert_response_xml(); + $this->init_values['admin']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + + return $this->init_values; + } + + /** + * @depends test_dump_board_state + */ + public function test_setup_forums($init_values) { + $this->init_values = $init_values; + $this->login(); $this->admin_login(); $this->create_user("disapprove_user"); @@ -71,8 +173,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::submit($form); } - public function test_setup_config() + /** + * @depends test_dump_board_state + */ + public function test_setup_config_after_forums($init_values) { + $this->init_values = $init_values; + $this->login(); $this->admin_login(); @@ -86,19 +193,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::request('GET', "adm/index.php?sid={$this->sid}&i=acp_board&mode=feed"); $form = $crawler->selectButton('Submit')->form(); - $values = $form->getValues(); - - // Enable all feeds - $values["config[feed_enable]"] = true; - $values["config[feed_forum]"] = true; - $values["config[feed_item_statistics]"] = true; - $values["config[feed_overall]"] = true; - $values["config[feed_overall_forums]"] = true; - $values["config[feed_topic]"] = true; - $values["config[feed_topics_active]"] = true; - $values["config[feed_topics_new]"] = true; - - $form->setValues($values); // News/Exclude's forums config $form['feed_news_id']->select(array($this->data['forums']['Feeds #news'])); @@ -106,22 +200,14 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); - - // News special config (Guest can't see attachments) - $this->add_lang('acp/permissions'); - - $crawler = self::request('GET', "adm/index.php?i=acp_permissions&sid={$this->sid}&icat=16&mode=setting_group_global&group_id[0]=1"); - $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); - - $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); - $form["setting[1][0][u_download]"]->select(-1); - - $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); } - public function test_feeds_empty() + /** + * @depends test_dump_board_state + */ + public function test_feeds_empty($init_values) { + $this->init_values = $init_values; $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -143,7 +229,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'forums' => array( array( - 'nb_entries' => 4, + 'nb_entries' => 3, 'xpath' => array( '//entry/category[@label="Feeds #exclude"]' => 0, ), @@ -157,8 +243,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_create_exclude_topic() + /** + * @depends test_dump_board_state + */ + public function test_create_exclude_topic($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -170,8 +261,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #exclude - Topic #1'] = (int) $post['topic_id']; } - public function test_feeds_exclude() + /** + * @depends test_dump_board_state + */ + public function test_feeds_exclude($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #exclude', @@ -199,7 +295,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 1, + 'nb_entries' => 0, 'xpath' => array( '//entry/title[contains(., "#exclude")]' => 0, ), @@ -207,7 +303,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 1, + 'nb_entries' => 0, 'xpath' => array( '//entry/title[contains(., "#exclude")]' => 0, ), @@ -215,7 +311,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 1, + 'nb_entries' => 0, 'xpath' => array( '//entry/title[contains(., "#exclude")]' => 0, ), @@ -223,7 +319,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 1, + 'nb_entries' => 0, 'xpath' => array( '//entry/title[contains(., "#exclude")]' => 0, ), @@ -232,8 +328,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_create_news_topics() + /** + * @depends test_dump_board_state + */ + public function test_create_news_topics($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -259,8 +360,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id']; } - public function test_feeds_news_admin() + /** + * @depends test_dump_board_state + */ + public function test_feeds_news_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #news', @@ -304,7 +410,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 4, + 'nb_entries' => 3, 'xpath' => array( '//entry/title[contains(., "#news")]' => 3, ), @@ -312,7 +418,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 3, + 'nb_entries' => 2, 'xpath' => array( '//entry/title[contains(., "#news")]' => 2, ), @@ -320,7 +426,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 3, + 'nb_entries' => 2, 'xpath' => array( '//entry/title[contains(., "#news")]' => 2, ), @@ -328,7 +434,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 3, + 'nb_entries' => 2, 'xpath' => array( '//entry/title[contains(., "#news")]' => 2, ), @@ -337,8 +443,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_feeds_news_guest() + /** + * @depends test_dump_board_state + */ + public function test_feeds_news_guest($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'posts' => array( 'Feeds #news - Topic #2', @@ -359,8 +470,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case )); } - public function test_create_sub_forum_topic() + /** + * @depends test_dump_board_state + */ + public function test_create_sub_forum_topic($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -376,8 +492,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id']; } - public function test_feeds_sub_forum() + /** + * @depends test_dump_board_state + */ + public function test_feeds_sub_forum($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -395,8 +516,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_create_softdelete_post() + /** + * @depends test_dump_board_state + */ + public function test_create_softdelete_post($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -415,8 +541,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id']; } - public function test_softdelete_post() + /** + * @depends test_dump_board_state + */ + public function test_softdelete_post($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -442,8 +573,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } - public function test_feeds_softdeleted_post_admin() + /** + * @depends test_dump_board_state + */ + public function test_feeds_softdeleted_post_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -475,7 +611,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 7, 'contents_lang' => array( 1 => 'POST_DELETED', ), @@ -484,8 +620,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_feeds_softdeleted_post_guest() + /** + * @depends test_dump_board_state + */ + public function test_feeds_softdeleted_post_guest($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -511,14 +652,19 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, ), ), )); } - public function test_softdelete_topic() + /** + * @depends test_dump_board_state + */ + public function test_softdelete_topic($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -546,8 +692,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); } - public function test_feeds_softdeleted_topic_admin() + /** + * @depends test_dump_board_state + */ + public function test_feeds_softdeleted_topic_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -581,7 +732,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 7, 'contents_lang' => array( 1 => 'POST_DELETED', 2 => 'POST_DELETED', @@ -590,7 +741,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, 'contents_lang' => array( 1 => 'TOPIC_DELETED', ), @@ -598,7 +749,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, 'contents_lang' => array( 1 => 'TOPIC_DELETED', ), @@ -606,7 +757,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, 'contents_lang' => array( 1 => 'TOPIC_DELETED', ), @@ -615,8 +766,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_feeds_softdeleted_topic_guest() + /** + * @depends test_dump_board_state + */ + public function test_feeds_softdeleted_topic_guest($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -642,29 +798,34 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, ), ), 'topics' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 4, ), ), 'topics_new' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 4, ), ), 'topics_active' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 4, ), ), )); } - public function test_create_unapproved_post() + /** + * @depends test_dump_board_state + */ + public function test_create_unapproved_post($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -684,8 +845,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); } - public function test_feeds_unapproved_post_admin() + /** + * @depends test_dump_board_state + */ + public function test_feeds_unapproved_post_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -717,7 +883,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 10, + 'nb_entries' => 9, 'contents_lang' => array( 1 => 'POST_UNAPPROVED', ), @@ -726,8 +892,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_feeds_unapproved_post_disapprove_user() + /** + * @depends test_dump_board_state + */ + public function test_feeds_unapproved_post_disapprove_user($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -753,14 +924,19 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, ), ), ), 'disapprove_user'); } - public function test_create_unapproved_topic() + /** + * @depends test_dump_board_state + */ + public function test_create_unapproved_topic($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -778,8 +954,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); } - public function test_feeds_unapproved_topic_admin() + /** + * @depends test_dump_board_state + */ + public function test_feeds_unapproved_topic_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -811,7 +992,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 11, + 'nb_entries' => 10, 'contents_lang' => array( 1 => 'POST_UNAPPROVED', ), @@ -819,7 +1000,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 7, 'contents_lang' => array( 1 => 'TOPIC_UNAPPROVED', ), @@ -827,7 +1008,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 7, 'contents_lang' => array( 1 => 'TOPIC_UNAPPROVED', ), @@ -835,7 +1016,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 7, 'contents_lang' => array( 1 => 'TOPIC_UNAPPROVED', ), @@ -844,8 +1025,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_feeds_unapproved_topic_disapprove_user() + /** + * @depends test_dump_board_state + */ + public function test_feeds_unapproved_topic_disapprove_user($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -871,29 +1057,34 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, ), ), 'topics' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, ), ), 'topics_new' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, ), ), 'topics_active' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, ), ), ), 'disapprove_user'); } - public function test_create_attachment_topic() + /** + * @depends test_dump_board_state + */ + public function test_create_attachment_topic($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -909,8 +1100,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; } - public function test_feeds_attachment_admin() + /** + * @depends test_dump_board_state + */ + public function test_feeds_attachment_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -955,7 +1151,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 12, + 'nb_entries' => 11, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -968,7 +1164,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -981,7 +1177,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -994,7 +1190,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1008,8 +1204,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - public function test_feeds_attachment_guest() + /** + * @depends test_dump_board_state + */ + public function test_feeds_attachment_guest($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1054,7 +1255,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 7, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1067,7 +1268,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1080,7 +1281,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1093,7 +1294,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1108,8 +1309,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case } // Disabled until PHPBB3-12418 is fixed and merged - /*public function test_create_missing_attachment_post() + /** + * @depends test_dump_board_state + */ + /*public function test_create_missing_attachment_post($init_values) { + $this->init_values = $init_values; + $this->login(); $this->load_ids(array( 'forums' => array( @@ -1128,8 +1334,13 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id']; } - public function test_feeds_missing_attachment_admin() + /** + * @depends test_dump_board_state + * / + public function test_feeds_missing_attachment_admin($init_values) { + $this->init_values = $init_values; + $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1213,6 +1424,11 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case if ($username) { $this->login($username); + $init_values = $this->init_values[$username]; + } + else + { + $init_values = $this->init_values['disapprove_user']; } foreach ($data as $mode => $feeds) @@ -1226,6 +1442,28 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case } else { + switch ($mode) { + case 'forums': + $feed_data['nb_entries'] = ((int)$feed_data['nb_entries'] + $init_values['forums_value']); + break; + case 'overall': + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['overall_value'], $this->init_values['post_base_items']); + break; + case 'topics': + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_value'], $this->init_values['topic_base_items']); + break; + case 'topics_new': + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_new_value'], $this->init_values['topic_base_items']); + break; + case 'topics_active': + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_active_value'], $this->init_values['topic_base_items']); + break; + case 'news': + break; + default: + $this->fail('Unsupported feed.'); + } + $params = "?mode={$mode}"; $this->assert_feed($params, $feed_data); } -- cgit v1.2.1 From 6c58f8cdeef5793c8ad5f2762ad81ad6e02bf9e7 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Mon, 21 Apr 2014 13:15:15 +0200 Subject: [ticket/12413] Using static attribute instead of @depends Using a static attribute to store the initial state of the feeds instead of transmit it with the @depends annotation. This attribute is also added to backupStaticAttributesBlackList PHPBB3-12413 --- tests/functional/feed_test.php | 253 ++++++++++------------------------------- 1 file changed, 59 insertions(+), 194 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index c6d4fee8fd..2612d5a138 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -14,7 +14,16 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { protected $data = array(); - private $init_values = array(); + static public $init_values = array(); + + public function __construct($name = NULL, array $data = array(), $dataName = '') + { + parent::__construct($name, $data, $dataName); + + $this->backupStaticAttributesBlacklist += array( + 'phpbb_functional_feed_test' => array('init_values'), + ); + } public function test_setup_config_before_state() { @@ -26,8 +35,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(); $values = $form->getValues(); - $this->init_values['post_base_items'] = (int)$values['config[feed_limit_post]']; - $this->init_values['topic_base_items'] = (int)$values['config[feed_limit_topic]']; + self::$init_values['post_base_items'] = (int)$values['config[feed_limit_post]']; + self::$init_values['topic_base_items'] = (int)$values['config[feed_limit_topic]']; // Enable all feeds $values["config[feed_enable]"] = true; @@ -56,68 +65,58 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::submit($form); $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); - return $this->init_values; + } - /** - * @depends test_setup_config_before_state - */ - public function test_dump_board_state($init_values) + public function test_dump_board_state() { - $this->init_values = $init_values; - $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); self::assert_response_xml(); - $this->init_values['disapprove_user']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); self::assert_response_xml(); - $this->init_values['disapprove_user']['overall_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['overall_value'] = $crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); self::assert_response_xml(); - $this->init_values['disapprove_user']['topics_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['topics_value'] = $crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); self::assert_response_xml(); - $this->init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); self::assert_response_xml(); - $this->init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); $this->login(); $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); self::assert_response_xml(); - $this->init_values['admin']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); self::assert_response_xml(); - $this->init_values['admin']['overall_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['overall_value'] = $crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); self::assert_response_xml(); - $this->init_values['admin']['topics_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['topics_value'] = $crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); self::assert_response_xml(); - $this->init_values['admin']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); self::assert_response_xml(); - $this->init_values['admin']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + - return $this->init_values; } - /** - * @depends test_dump_board_state - */ - public function test_setup_forums($init_values) + public function test_setup_forums() { - $this->init_values = $init_values; - $this->login(); $this->admin_login(); $this->create_user("disapprove_user"); @@ -173,13 +172,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::submit($form); } - /** - * @depends test_dump_board_state - */ - public function test_setup_config_after_forums($init_values) + public function test_setup_config_after_forums() { - $this->init_values = $init_values; - $this->login(); $this->admin_login(); @@ -202,12 +196,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_empty($init_values) + public function test_feeds_empty() { - $this->init_values = $init_values; $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -243,13 +233,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_create_exclude_topic($init_values) + public function test_create_exclude_topic() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -261,13 +246,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #exclude - Topic #1'] = (int) $post['topic_id']; } - /** - * @depends test_dump_board_state - */ - public function test_feeds_exclude($init_values) + public function test_feeds_exclude() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #exclude', @@ -328,13 +308,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_create_news_topics($init_values) + public function test_create_news_topics() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -360,13 +335,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['posts']['Re: Feeds #news - Topic #2'] = (int) $post2['post_id']; } - /** - * @depends test_dump_board_state - */ - public function test_feeds_news_admin($init_values) + public function test_feeds_news_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #news', @@ -443,13 +413,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_news_guest($init_values) + public function test_feeds_news_guest() { - $this->init_values = $init_values; - $this->load_ids(array( 'posts' => array( 'Feeds #news - Topic #2', @@ -470,13 +435,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case )); } - /** - * @depends test_dump_board_state - */ - public function test_create_sub_forum_topic($init_values) + public function test_create_sub_forum_topic() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -492,13 +452,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id']; } - /** - * @depends test_dump_board_state - */ - public function test_feeds_sub_forum($init_values) + public function test_feeds_sub_forum() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -516,13 +471,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_create_softdelete_post($init_values) + public function test_create_softdelete_post() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -541,13 +491,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['posts']['Re: Feeds #1 - Topic #2'] = (int) $post2['post_id']; } - /** - * @depends test_dump_board_state - */ - public function test_softdelete_post($init_values) + public function test_softdelete_post() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -573,13 +518,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertContains($this->lang('POST_DISPLAY', '', ''), $crawler->text()); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_softdeleted_post_admin($init_values) + public function test_feeds_softdeleted_post_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -620,13 +560,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_softdeleted_post_guest($init_values) + public function test_feeds_softdeleted_post_guest() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -658,13 +593,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case )); } - /** - * @depends test_dump_board_state - */ - public function test_softdelete_topic($init_values) + public function test_softdelete_topic() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -692,13 +622,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertContains('Feeds #1 - Topic #2', $crawler->filter('h2')->text()); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_softdeleted_topic_admin($init_values) + public function test_feeds_softdeleted_topic_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -766,13 +691,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_softdeleted_topic_guest($init_values) + public function test_feeds_softdeleted_topic_guest() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -819,13 +739,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case )); } - /** - * @depends test_dump_board_state - */ - public function test_create_unapproved_post($init_values) + public function test_create_unapproved_post() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -845,13 +760,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertNotContains('Re: Feeds #1.1 - Topic #2', $crawler->filter('html')->text()); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_unapproved_post_admin($init_values) + public function test_feeds_unapproved_post_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -892,13 +802,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_unapproved_post_disapprove_user($init_values) + public function test_feeds_unapproved_post_disapprove_user() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -930,13 +835,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'disapprove_user'); } - /** - * @depends test_dump_board_state - */ - public function test_create_unapproved_topic($init_values) + public function test_create_unapproved_topic() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -954,13 +854,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_unapproved_topic_admin($init_values) + public function test_feeds_unapproved_topic_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -1025,13 +920,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_unapproved_topic_disapprove_user($init_values) + public function test_feeds_unapproved_topic_disapprove_user() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -1078,13 +968,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'disapprove_user'); } - /** - * @depends test_dump_board_state - */ - public function test_create_attachment_topic($init_values) + public function test_create_attachment_topic() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -1100,13 +985,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; } - /** - * @depends test_dump_board_state - */ - public function test_feeds_attachment_admin($init_values) + public function test_feeds_attachment_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1204,13 +1084,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'admin'); } - /** - * @depends test_dump_board_state - */ - public function test_feeds_attachment_guest($init_values) + public function test_feeds_attachment_guest() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1309,13 +1184,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case } // Disabled until PHPBB3-12418 is fixed and merged - /** - * @depends test_dump_board_state - */ - /*public function test_create_missing_attachment_post($init_values) + /*public function test_create_missing_attachment_post() { - $this->init_values = $init_values; - $this->login(); $this->load_ids(array( 'forums' => array( @@ -1334,13 +1204,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->data['posts']['Re: Feeds #1 - Topic #3-1'] = (int) $post2['post_id']; } - /** - * @depends test_dump_board_state - * / - public function test_feeds_missing_attachment_admin($init_values) + public function test_feeds_missing_attachment_admin() { - $this->init_values = $init_values; - $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1424,11 +1289,11 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case if ($username) { $this->login($username); - $init_values = $this->init_values[$username]; + $init_values = self::$init_values[$username]; } else { - $init_values = $this->init_values['disapprove_user']; + $init_values = self::$init_values['disapprove_user']; } foreach ($data as $mode => $feeds) @@ -1447,16 +1312,16 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $feed_data['nb_entries'] = ((int)$feed_data['nb_entries'] + $init_values['forums_value']); break; case 'overall': - $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['overall_value'], $this->init_values['post_base_items']); + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['overall_value'], self::$init_values['post_base_items']); break; case 'topics': - $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_value'], $this->init_values['topic_base_items']); + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_value'], self::$init_values['topic_base_items']); break; case 'topics_new': - $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_new_value'], $this->init_values['topic_base_items']); + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_new_value'], self::$init_values['topic_base_items']); break; case 'topics_active': - $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_active_value'], $this->init_values['topic_base_items']); + $feed_data['nb_entries'] = min($feed_data['nb_entries'] + $init_values['topics_active_value'], self::$init_values['topic_base_items']); break; case 'news': break; -- cgit v1.2.1 From ac59b6a19914a86bc434fd8ac6aae4f901c72f98 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Thu, 24 Apr 2014 00:52:04 +0200 Subject: [ticket/12413] Fixing the failed test The test was failing because travis is too fast: 2 posts had the same timestamp. PHPBB3-12413 --- tests/functional/feed_test.php | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 2612d5a138..98a3bf2aa4 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -1,15 +1,15 @@ create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #news - Topic #1'] = (int) $post['topic_id']; + // Travis is too fast, so we have to wait + sleep(1); + $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); + // Travis is too fast, so we have to wait + sleep(1); + $this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id']; $this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -448,6 +454,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1 - Topic #1'] = (int) $post['topic_id']; + // Travis is too fast, so we have to wait + sleep(1); + $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id']; } @@ -483,6 +492,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #2', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1 - Topic #2'] = (int) $post['topic_id']; + // Travis is too fast, so we have to wait + sleep(1); + // Test creating a reply $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); -- cgit v1.2.1 From 7d8d8394fc36b1564ea083447329ab9f54a3db01 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 25 Apr 2014 17:00:24 +0200 Subject: [ticket/12413] Fix: coding style PHPBB3-12413 --- tests/functional/feed_test.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 98a3bf2aa4..17847422b3 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -1,15 +1,15 @@ Date: Tue, 29 Apr 2014 23:27:43 +0200 Subject: [ticket/12413] Fix coding style PHPBB3-12413 --- tests/functional/feed_test.php | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 17847422b3..64f8f237d7 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -1195,9 +1195,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case )); } - // Disabled until PHPBB3-12418 is fixed and merged - /*public function test_create_missing_attachment_post() + public function test_create_missing_attachment_post() { + $this->markIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -1218,6 +1218,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_missing_attachment_admin() { + $this->markIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1294,7 +1295,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), ), ), 'admin'); - }*/ + } protected function assert_feeds($data, $username = false) { @@ -1338,7 +1339,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case case 'news': break; default: - $this->fail('Unsupported feed.'); + $this->fail('Unsupported feed mode: ' . $mode); } $params = "?mode={$mode}"; @@ -1352,19 +1353,22 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { $crawler = self::request('GET', 'feed.php' . $params, array(), false); - if (!(isset($data['invalid']) && $data['invalid'])) + if (empty($data['invalid'])) { self::assert_response_xml(); $this->assertEquals($data['nb_entries'], $crawler->filter('entry')->count(), "Tested feed : 'feed.php{$params}'"); - if (sizeof($data['xpath'])) { + if (!empty($data['xpath'])) + { + foreach($data['xpath'] as $xpath => $count_expected) { $this->assertCount($count_expected, $crawler->filterXPath($xpath), "Tested feed : 'feed.php{$params}', Search for {$xpath}"); } } - if (sizeof($data['contents'])) { + if (!empty($data['contents'])) + { foreach($data['contents'] as $entry_id => $string) { $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); @@ -1372,7 +1376,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case } } - if (sizeof($data['contents_lang'])) { + if (!empty($data['contents_lang'])) + { foreach($data['contents_lang'] as $entry_id => $string) { $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); @@ -1380,7 +1385,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case } } - if (sizeof($data['attachments'])) { + if (!empty($data['attachments'])) + { foreach($data['attachments'] as $entry_id => $attachments) { foreach ($attachments as $i => $attachment) @@ -1408,10 +1414,11 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { self::assert_response_html(); - if (sizeof($data['contents_lang'])) { + if (!empty($data['contents_lang'])) + { foreach($data['contents_lang'] as $string) { - $content = $crawler->filter("html")->text(); + $content = $crawler->filter('html')->text(); $this->assertContainsLang($string, $content, "Tested feed : 'feed.php{$params}'"); } } -- cgit v1.2.1 From ff2d26e7e8e9aa47fdbc40aada5bef3d5f07d034 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Tue, 29 Apr 2014 23:48:08 +0200 Subject: [ticket/12413] Coding style again PHPBB3-12413 --- tests/functional/feed_test.php | 54 +++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 64f8f237d7..b50196fb18 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -16,7 +16,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case static public $init_values = array(); - public function __construct($name = NULL, array $data = array(), $dataName = '') + public function __construct($name = null, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); @@ -35,18 +35,18 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form = $crawler->selectButton('Submit')->form(); $values = $form->getValues(); - self::$init_values['post_base_items'] = (int)$values['config[feed_limit_post]']; - self::$init_values['topic_base_items'] = (int)$values['config[feed_limit_topic]']; + self::$init_values['post_base_items'] = (int) $values['config[feed_limit_post]']; + self::$init_values['topic_base_items'] = (int) $values['config[feed_limit_topic]']; // Enable all feeds - $values["config[feed_enable]"] = true; - $values["config[feed_forum]"] = true; - $values["config[feed_item_statistics]"] = true; - $values["config[feed_overall]"] = true; - $values["config[feed_overall_forums]"] = true; - $values["config[feed_topic]"] = true; - $values["config[feed_topics_active]"] = true; - $values["config[feed_topics_new]"] = true; + $values['config[feed_enable]'] = true; + $values['config[feed_forum]'] = true; + $values['config[feed_item_statistics]'] = true; + $values['config[feed_overall]'] = true; + $values['config[feed_overall_forums]'] = true; + $values['config[feed_topic]'] = true; + $values['config[feed_topics_active]'] = true; + $values['config[feed_topics_new]'] = true; $form->setValues($values); @@ -60,7 +60,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assertContains($this->lang('ACL_SET'), $crawler->filter('h1')->eq(1)->text()); $form = $crawler->selectButton($this->lang('APPLY_PERMISSIONS'))->form(); - $form["setting[1][0][u_download]"]->select(-1); + $form['setting[1][0][u_download]']->select(-1); $crawler = self::submit($form); $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); @@ -72,45 +72,45 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); self::assert_response_xml(); - self::$init_values['disapprove_user']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['forums_value'] = (int)$crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); self::assert_response_xml(); - self::$init_values['disapprove_user']['overall_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['overall_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); self::assert_response_xml(); - self::$init_values['disapprove_user']['topics_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['topics_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); self::assert_response_xml(); - self::$init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['topics_new_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); self::assert_response_xml(); - self::$init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['disapprove_user']['topics_active_value'] = $crawler->filterXPath('//entry')->count(); $this->login(); $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); self::assert_response_xml(); - self::$init_values['admin']['forums_value'] = (int)$crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['forums_value'] = (int)$crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); self::assert_response_xml(); - self::$init_values['admin']['overall_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['overall_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=topics', array(), false); self::assert_response_xml(); - self::$init_values['admin']['topics_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['topics_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=topics_new', array(), false); self::assert_response_xml(); - self::$init_values['admin']['topics_new_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['topics_new_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=topics_active', array(), false); self::assert_response_xml(); - self::$init_values['admin']['topics_active_value'] = $crawler->filterXPath("//entry")->count(); + self::$init_values['admin']['topics_active_value'] = $crawler->filterXPath('//entry')->count(); } @@ -119,7 +119,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { $this->login(); $this->admin_login(); - $this->create_user("disapprove_user"); + $this->create_user('disapprove_user'); $this->add_user_group('NEWLY_REGISTERED', array('disapprove_user')); $crawler = self::request('GET', "adm/index.php?i=acp_forums&mode=manage&sid={$this->sid}"); @@ -765,7 +765,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->logout(); // Test creating a reply - $this->login("disapprove_user"); + $this->login('disapprove_user'); $post2 = $this->create_post($this->data['forums']['Feeds #1.1'], $post['topic_id'], 'Re: Feeds #1.1 - Topic #2', 'This is a test post posted by the testing framework.', array(), 'POST_STORED_MOD'); $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1.1 - Topic #2']}&sid={$this->sid}"); @@ -858,7 +858,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case // We have to wait because of the flood interval. sleep(15); - $this->login("disapprove_user"); + $this->login('disapprove_user'); $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); $this->data['topics']['Feeds #1 - Topic #3'] = (int) $post['topic_id']; $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); @@ -1197,7 +1197,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_missing_attachment_post() { - $this->markIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); + $this->markTestIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -1218,7 +1218,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_missing_attachment_admin() { - $this->markIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); + $this->markTestIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->load_ids(array( 'forums' => array( 'Feeds #1', -- cgit v1.2.1 From dcadc04b182cb820cfa9bdddee3bc8661c817c4b Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Wed, 30 Apr 2014 00:14:28 +0200 Subject: [ticket/12413] Disabled unapproved and solftdeleted tests PHPBB3-12413 --- tests/functional/feed_test.php | 31 ++++++++++++++++++++++--------- 1 file changed, 22 insertions(+), 9 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index b50196fb18..32a25fd390 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -482,6 +482,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_softdelete_post() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -505,6 +506,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_softdelete_post() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -532,6 +534,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_post_admin() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -574,6 +577,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_post_guest() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -607,6 +611,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_softdelete_topic() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -636,6 +641,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_topic_admin() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -705,6 +711,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_topic_guest() { + $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -753,6 +760,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_unapproved_post() { + $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -774,6 +782,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_post_admin() { + $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -816,6 +825,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_post_disapprove_user() { + $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -849,6 +859,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_unapproved_topic() { + $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -868,6 +879,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_topic_admin() { + $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -934,6 +946,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_topic_disapprove_user() { + $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -1015,7 +1028,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assert_feeds(array( 'f' => array( array( - 'nb_entries' => 4, + 'nb_entries' => 2, 'id' => $this->data['forums']['Feeds #1'], 'attachments' => array( 1 => array( // First entry @@ -1043,7 +1056,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 11, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1056,7 +1069,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 5, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1069,7 +1082,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 5, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1082,7 +1095,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 8, + 'nb_entries' => 5, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1142,7 +1155,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 7, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1155,7 +1168,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1168,7 +1181,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1181,7 +1194,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 5, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch -- cgit v1.2.1 From 87fe1e613639e7bcb0549024f31565acc3426143 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Wed, 30 Apr 2014 00:50:11 +0200 Subject: [ticket/12413] Remove unnecessary casts PHPBB3-12413 --- tests/functional/feed_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 32a25fd390..97ba848b4f 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -72,7 +72,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case { $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); self::assert_response_xml(); - self::$init_values['disapprove_user']['forums_value'] = (int)$crawler->filterXPath('//entry')->count(); + self::$init_values['disapprove_user']['forums_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); self::assert_response_xml(); @@ -94,7 +94,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::request('GET', 'feed.php?mode=forums', array(), false); self::assert_response_xml(); - self::$init_values['admin']['forums_value'] = (int)$crawler->filterXPath('//entry')->count(); + self::$init_values['admin']['forums_value'] = $crawler->filterXPath('//entry')->count(); $crawler = self::request('GET', 'feed.php?mode=overall', array(), false); self::assert_response_xml(); -- cgit v1.2.1 From 2bc4c0e39fcf48bb6e52588a62d9c2e883353880 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Wed, 30 Apr 2014 01:02:11 +0200 Subject: [ticket/12413] Update init PHPBB3-12413 --- tests/functional/feed_test.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 97ba848b4f..bc494d6f05 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -63,9 +63,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form['setting[1][0][u_download]']->select(-1); $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); - - + $this->assertContainsLang('AUTH_UPDATED', $crawler->filter('.successbox')->text()); } public function test_dump_board_state() -- cgit v1.2.1 From 8812cfcfbf4ae82eb0270c268d227ba729b42107 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Fri, 2 May 2014 13:24:38 +0200 Subject: [ticket/12413] Update configuration's asserts PHPBB3-12413 --- tests/functional/feed_test.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index bc494d6f05..fbcbfa3943 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -51,7 +51,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form->setValues($values); $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); // Special config (Guest can't see attachments) $this->add_lang('acp/permissions'); @@ -191,7 +191,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $form['feed_exclude_id']->select(array($this->data['forums']['Feeds #exclude'])); $crawler = self::submit($form); - $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + $this->assertContainsLang('CONFIG_UPDATED', $crawler->filter('.successbox')->text()); } public function test_feeds_empty() -- cgit v1.2.1 From f90e6649f77a95c32274d52f5518c9ef319565d5 Mon Sep 17 00:00:00 2001 From: Nicofuma Date: Wed, 30 Apr 2014 00:47:37 +0200 Subject: [ticket/12459] Enable related tests PHPBB3-12459 --- tests/functional/feed_test.php | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index fbcbfa3943..b6287bf10f 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -480,7 +480,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_softdelete_post() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -504,7 +503,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_softdelete_post() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -532,7 +530,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_post_admin() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -575,7 +572,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_post_guest() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -609,7 +605,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_softdelete_topic() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -639,7 +634,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_topic_admin() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -709,7 +703,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_softdeleted_topic_guest() { - $this->markTestIncomplete('Softdeleted posts/topics are not marked in feeds yet, see PHPBB3-12460'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -758,7 +751,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_unapproved_post() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -780,7 +772,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_post_admin() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -823,7 +814,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_post_disapprove_user() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -857,7 +847,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_unapproved_topic() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -877,7 +866,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_topic_admin() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -944,7 +932,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_unapproved_topic_disapprove_user() { - $this->markTestIncomplete('Unapproved posts/topics are not marked in feeds yet, see PHPBB3-12459'); $this->load_ids(array( 'forums' => array( 'Feeds #1.1', @@ -1026,7 +1013,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $this->assert_feeds(array( 'f' => array( array( - 'nb_entries' => 2, + 'nb_entries' => 4, 'id' => $this->data['forums']['Feeds #1'], 'attachments' => array( 1 => array( // First entry @@ -1054,7 +1041,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 11, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1067,7 +1054,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1080,7 +1067,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1093,7 +1080,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1153,7 +1140,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 6, + 'nb_entries' => 7, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1166,7 +1153,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1179,7 +1166,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch @@ -1192,7 +1179,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 5, + 'nb_entries' => 6, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch -- cgit v1.2.1 From 62b4e7b9d25a8e947d2bec67888ad006f0f1b4b0 Mon Sep 17 00:00:00 2001 From: Tristan Darricau Date: Tue, 6 May 2014 14:54:22 +0200 Subject: [ticket/12421] Rebase and enable tests PHPBB3-12421 --- tests/functional/feed_test.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index b6287bf10f..86d3930a7b 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -1195,7 +1195,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_create_missing_attachment_post() { - $this->markTestIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->login(); $this->load_ids(array( 'forums' => array( @@ -1216,7 +1215,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case public function test_feeds_missing_attachment_admin() { - $this->markTestIncomplete('Missing attachments in posts/topics are not marked in feeds yet, see PHPBB3-12418'); $this->load_ids(array( 'forums' => array( 'Feeds #1', @@ -1252,7 +1250,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'overall' => array( array( - 'nb_entries' => 13, + 'nb_entries' => 12, 'contents' => array( 1 => 'Attachment #0', ), @@ -1260,12 +1258,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], - 'displayed' => false, + 'displayed' => true, ), ), ), @@ -1273,12 +1271,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_new' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'attachments' => array( 1 => array( // First entry array( // First attachment to fetch 'id' => $this->data['attachments'][$this->data['posts']['Feeds #1 - Topic #3']][0], - 'displayed' => false, + 'displayed' => true, ), ), ), @@ -1286,7 +1284,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), 'topics_active' => array( array( - 'nb_entries' => 9, + 'nb_entries' => 8, 'contents' => array( 1 => 'Attachment #0', ), @@ -1396,13 +1394,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case if ($attachment['displayed']) { $this->assertContains($url, $content, "Tested feed : 'feed.php{$params}'"); - // $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'"); + $this->assertNotContains($string, $content, "Tested feed : 'feed.php{$params}'"); } else { - // Disabled until PHPBB3-12421 is fixed and merged - // $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); - // $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'"); + $this->assertContains($string, $content, "Tested feed : 'feed.php{$params}'"); + $this->assertNotContains($url, $content, "Tested feed : 'feed.php{$params}'"); } } } -- cgit v1.2.1 From a759704b39fc1c1353f865a633759b1369589b67 Mon Sep 17 00:00:00 2001 From: Yuriy Rusko Date: Tue, 27 May 2014 20:18:06 +0200 Subject: [ticket/12594] Remove @package tags and update file headers PHPBB3-12594 --- tests/functional/feed_test.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 86d3930a7b..a474ecf27f 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -1,9 +1,13 @@ +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ -- cgit v1.2.1 From d95c97c3b4bd3f6efbdf3b457e6f9377fed640d3 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 14 Jun 2014 15:36:36 -0700 Subject: [ticket/12013] Fix functional tests and sniffer issue. PHPBB3-12013 --- tests/functional/feed_test.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index a474ecf27f..7aa2d0da7d 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -619,12 +619,8 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case ), )); - $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Feeds #1 - Topic #2']}&sid={$this->sid}"); - $this->add_lang('posting'); - $form = $crawler->selectButton('Go')->eq(2)->form(); - $form['action']->select('delete_topic'); - $crawler = self::submit($form); + $crawler = $this->get_quickmod_page($this->data['topics']['Feeds #1 - Topic #2'], 'DELETE_TOPIC'); $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); $this->add_lang('mcp'); -- cgit v1.2.1 From b868886b25ccf6228b31dd1e4950eba1b3a67243 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 29 Oct 2014 13:15:11 +0100 Subject: [ticket/13241] Remove sleep() since the method takes care of this now PHPBB3-13241 --- tests/functional/feed_test.php | 12 ------------ 1 file changed, 12 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 7aa2d0da7d..ddf17d4749 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -322,15 +322,9 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #news - Topic #1'] = (int) $post['topic_id']; - // Travis is too fast, so we have to wait - sleep(1); - $post = $this->create_topic($this->data['forums']['Feeds #news'], 'Feeds #news - Topic #2', 'This is a test topic posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post['topic_id']}&sid={$this->sid}"); - // Travis is too fast, so we have to wait - sleep(1); - $this->assertContains('Feeds #news - Topic #2', $crawler->filter('html')->text()); $this->data['topics']['Feeds #news - Topic #2'] = (int) $post['topic_id']; $this->data['posts']['Feeds #news - Topic #2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); @@ -456,9 +450,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1 - Topic #1'] = (int) $post['topic_id']; - // Travis is too fast, so we have to wait - sleep(1); - $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #1', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1.1 - Topic #1'] = (int) $post['topic_id']; } @@ -494,9 +485,6 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $post = $this->create_topic($this->data['forums']['Feeds #1'], 'Feeds #1 - Topic #2', 'This is a test topic posted by the testing framework.'); $this->data['topics']['Feeds #1 - Topic #2'] = (int) $post['topic_id']; - // Travis is too fast, so we have to wait - sleep(1); - // Test creating a reply $post2 = $this->create_post($this->data['forums']['Feeds #1'], $post['topic_id'], 'Re: Feeds #1 - Topic #2', 'This is a test post posted by the testing framework.'); $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); -- cgit v1.2.1 From 1787ccb5852e09566ba13040ad3f8ca53052e6dd Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 29 Oct 2014 13:24:59 +0100 Subject: [ticket/13241] Remove sleep() and change flood interval instead PHPBB3-13241 --- tests/functional/feed_test.php | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index ddf17d4749..9041c8dc69 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -840,9 +840,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case 'Feeds #1.1', ), )); - - // We have to wait because of the flood interval. - sleep(15); + $this->set_flood_interval(0); $this->login('disapprove_user'); $post = $this->create_topic($this->data['forums']['Feeds #1.1'], 'Feeds #1.1 - Topic #3', 'This is a test topic posted by the testing framework.', array(), 'POST_STORED_MOD'); @@ -850,6 +848,27 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewforum.php?f={$this->data['forums']['Feeds #1.1']}&sid={$this->sid}"); $this->assertNotContains('Feeds #1.1 - Topic #3', $crawler->filter('html')->text()); + + $this->logout(); + $this->set_flood_interval(15); + } + + protected function set_flood_interval($flood_interval) + { + $this->login(); + $this->admin_login(); + + $crawler = self::request('GET', 'adm/index.php?sid=' . $this->sid . '&i=acp_board&mode=post'); + + $form = $crawler->selectButton('Submit')->form(); + $values = $form->getValues(); + + $values["config[flood_interval]"] = $flood_interval; + $form->setValues($values); + $crawler = self::submit($form); + $this->assertGreaterThan(0, $crawler->filter('.successbox')->count()); + + $this->logout(); } public function test_feeds_unapproved_topic_admin() -- cgit v1.2.1 From 7e1b0330a3ddd269c85047912c956daf930018cc Mon Sep 17 00:00:00 2001 From: Zoddo Date: Wed, 15 Jul 2015 21:55:12 +0200 Subject: [ticket/13988] Update tests PHPBB3-13988 --- tests/functional/feed_test.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index 9041c8dc69..ad5c4a5cab 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -1395,7 +1395,7 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case foreach ($attachments as $i => $attachment) { $content = $crawler->filterXPath("//entry[{$entry_id}]/content")->text(); - $url = "./download/file.php?id={$attachment['id']}"; + $url = self::$root_url . "download/file.php?id={$attachment['id']}"; $string = "Attachment #{$i}"; if ($attachment['displayed']) -- cgit v1.2.1 From cf1fc202975aa055d0bb926a5dce1c3896bbd1e1 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Thu, 7 Jan 2016 10:31:21 +0100 Subject: [ticket/14394] Only purge cache in functional tests if necessary PHPBB3-14394 --- tests/functional/feed_test.php | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests/functional/feed_test.php') diff --git a/tests/functional/feed_test.php b/tests/functional/feed_test.php index ad5c4a5cab..e48dfc043a 100644 --- a/tests/functional/feed_test.php +++ b/tests/functional/feed_test.php @@ -20,6 +20,12 @@ class phpbb_functional_feed_test extends phpbb_functional_test_case static public $init_values = array(); + public function setUp() + { + parent::setUp(); + $this->purge_cache(); + } + public function __construct($name = null, array $data = array(), $dataName = '') { parent::__construct($name, $data, $dataName); -- cgit v1.2.1