diff options
Diffstat (limited to 'tests/functional/download_test.php')
-rw-r--r-- | tests/functional/download_test.php | 97 |
1 files changed, 24 insertions, 73 deletions
diff --git a/tests/functional/download_test.php b/tests/functional/download_test.php index 24366992d5..1e863210e6 100644 --- a/tests/functional/download_test.php +++ b/tests/functional/download_test.php @@ -1,9 +1,13 @@ <?php /** * -* @package testing -* @copyright (c) 2014 phpBB Group -* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2 +* This file is part of the phpBB Forum Software package. +* +* @copyright (c) phpBB Limited <https://www.phpbb.com> +* @license GNU General Public License, version 2 (GPL-2.0) +* +* For full copyright and license information, please see +* the docs/CREDITS.txt file. * */ @@ -57,11 +61,16 @@ class phpbb_functional_download_test extends phpbb_functional_test_case $crawler = self::request('GET', "viewtopic.php?t={$post2['topic_id']}&sid={$this->sid}"); $this->assertContains('Re: Download Topic #1-#2', $crawler->filter('html')->text()); - $this->data['posts']['Re: Download Topic #1-#2'] = (int) $this->get_parameter_from_link($crawler->filter('.post')->eq(1)->selectLink($this->lang('POST', '', ''))->link()->getUri(), 'p'); + $this->data['posts']['Re: Download Topic #1-#2'] = (int) $post2['post_id']; } public function test_download_accessible() { + if (!class_exists('finfo')) + { + $this->markTestSkipped('Unable to run test with fileinfo disabled'); + } + $this->load_ids(array( 'forums' => array( 'Download #1', @@ -76,20 +85,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case 'attachments' => true, )); - // Download topic archive as guest - $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - - // Download post archive as guest - $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - // Download attachment as guest $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false); self::assert_response_status_code(200); @@ -128,6 +123,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case public function test_download_softdeleted_post() { + if (!class_exists('finfo')) + { + $this->markTestSkipped('Unable to run test with fileinfo disabled'); + } + $this->load_ids(array( 'forums' => array( 'Download #1', @@ -143,18 +143,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case )); $this->add_lang('viewtopic'); - // Download topic archive as guest: still works - $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - - // No download post archive as guest - $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false); - self::assert_response_html(404); - $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text()); - // No download attachment as guest $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false); self::assert_response_html(404); @@ -163,20 +151,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case // Login as admin and try again, should work now. $this->login(); - // Download topic archive as admin - $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - - // Download post archive as admin - $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - // Download attachment as admin $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false); self::assert_response_status_code(200); @@ -201,12 +175,8 @@ class phpbb_functional_download_test extends phpbb_functional_test_case ), )); - $crawler = self::request('GET', "viewtopic.php?t={$this->data['topics']['Download Topic #1']}&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']['Download Topic #1'], 'DELETE_TOPIC'); $this->assertContainsLang('DELETE_PERMANENTLY', $crawler->text()); $this->add_lang('mcp'); @@ -220,6 +190,11 @@ class phpbb_functional_download_test extends phpbb_functional_test_case public function test_download_softdeleted_topic() { + if (!class_exists('finfo')) + { + $this->markTestSkipped('Unable to run test with fileinfo disabled'); + } + $this->load_ids(array( 'forums' => array( 'Download #1', @@ -235,16 +210,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case )); $this->add_lang('viewtopic'); - // Download topic archive as guest: still works - $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false); - self::assert_response_html(404); - $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text()); - - // No download post archive as guest - $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false); - self::assert_response_html(404); - $this->assertContainsLang('ERROR_NO_ATTACHMENT', $crawler->filter('#message')->text()); - // No download attachment as guest $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false); self::assert_response_html(404); @@ -253,20 +218,6 @@ class phpbb_functional_download_test extends phpbb_functional_test_case // Login as admin and try again, should work now. $this->login(); - // Download topic archive as admin - $crawler = self::request('GET', "download/file.php?archive=.zip&topic_id={$this->data['topics']['Download Topic #1']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - - // Download post archive as admin - $crawler = self::request('GET', "download/file.php?archive=.zip&post_id={$this->data['posts']['Re: Download Topic #1-#2']}", array(), false); - self::assert_response_status_code(200); - $content = self::$client->getResponse()->getContent(); - $finfo = new finfo(FILEINFO_MIME_TYPE); - self::assertEquals('application/zip', $finfo->buffer($content)); - // Download attachment as admin $crawler = self::request('GET', "download/file.php?id={$this->data['attachments'][$this->data['posts']['Re: Download Topic #1-#2']]}", array(), false); self::assert_response_status_code(200); |