From ff57ecf0bc541123c987ff0a84e80e1d01eb31de Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Feb 2014 23:45:41 +0100 Subject: [PATCH 1/3] [ticket/12175] Fix upload test for empty file PHPBB3-12175 --- tests/functional/fileupload_form_test.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index ad01d7b2df..596aae03a2 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -63,9 +63,8 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case public function test_empty_file() { - $this->markTestIncomplete('Test fails intermittently.'); $crawler = $this->upload_file('empty.png', 'image/png'); - $this->assertEquals($this->lang('ATTACHED_IMAGE_NOT_IMAGE'), $this->assert_filter($crawler, 'div#message p')->text()); + $this->assertEquals($this->lang('EMPTY_FILEUPLOAD'), $crawler->filter('p.error')->text()); } public function test_invalid_extension() From 07f19647f43f44c3b82d6100f384dff5800eb550 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Feb 2014 23:47:20 +0100 Subject: [PATCH 2/3] [ticket/12175] Fix test for uploading a valid file PHPBB3-12175 --- tests/functional/fileupload_form_test.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index 596aae03a2..db615dc2a6 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -82,10 +82,12 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case public function test_valid_file() { - $this->markTestIncomplete('Test fails intermittently.'); $crawler = $this->upload_file('valid.jpg', 'image/jpeg'); - // ensure there was no error message rendered + + // Ensure there was no error message rendered $this->assertNotContains('

' . $this->lang('INFORMATION') . '

', $this->get_content()); - $this->assertContains($this->lang('POSTED_ATTACHMENTS'), $crawler->filter('#postform h3')->eq(1)->text()); + + // Also the file name should be in the first row of the files table + $this->assertEquals('valid.jpg', $crawler->filter('span.file-name')->eq(1)->text()); } } From 1fdd01275e9fc65a28fb0c95efc3dde0f36ea976 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sun, 9 Feb 2014 23:48:34 +0100 Subject: [PATCH 3/3] [ticket/12175] Do not use admin account for file size limit test PHPBB3-12175 --- tests/functional/fileupload_form_test.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/functional/fileupload_form_test.php b/tests/functional/fileupload_form_test.php index db615dc2a6..c291712c71 100644 --- a/tests/functional/fileupload_form_test.php +++ b/tests/functional/fileupload_form_test.php @@ -19,7 +19,6 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case parent::setUp(); $this->path = __DIR__ . '/fixtures/files/'; $this->add_lang('posting'); - $this->login(); } public function tearDown() @@ -63,25 +62,33 @@ class phpbb_functional_fileupload_form_test extends phpbb_functional_test_case public function test_empty_file() { + $this->login(); + $crawler = $this->upload_file('empty.png', 'image/png'); $this->assertEquals($this->lang('EMPTY_FILEUPLOAD'), $crawler->filter('p.error')->text()); } public function test_invalid_extension() { + $this->login(); + $crawler = $this->upload_file('illegal-extension.bif', 'application/octet-stream'); $this->assertEquals($this->lang('DISALLOWED_EXTENSION', 'bif'), $crawler->filter('p.error')->text()); } public function test_too_large() { - $this->markTestIncomplete('Functional tests use an admin account which ignores maximum upload size.'); + $this->create_user('fileupload'); + $this->login('fileupload'); + $crawler = $this->upload_file('too-large.png', 'image/png'); $this->assertEquals($this->lang('WRONG_FILESIZE', '256', 'KiB'), $crawler->filter('p.error')->text()); } public function test_valid_file() { + $this->login(); + $crawler = $this->upload_file('valid.jpg', 'image/jpeg'); // Ensure there was no error message rendered