1
0
mirror of https://github.com/phpbb/phpbb.git synced 2025-07-31 14:00:31 +02:00

[ticket/10941] Now actually checks for the value of errors.

Uses phpbb_mock_lang to return the key used when setting errors to
allow that key to be checked for during tests rather than just checking
if any error was set.

PHPBB3-10941
This commit is contained in:
Fyorl
2012-07-03 00:32:50 +01:00
parent 943af957e6
commit 19405a7f47
3 changed files with 29 additions and 25 deletions

View File

@@ -31,6 +31,7 @@ class phpbb_fileupload_test extends phpbb_test_case
$config['rand_seed_last_update'] = time() + 600;
$user = new phpbb_mock_user();
$user->lang = new phpbb_mock_lang();
$this->path = __DIR__ . '/fixture/';
}
@@ -56,10 +57,6 @@ class phpbb_fileupload_test extends phpbb_test_case
public function test_common_checks()
{
// Note: we cannot check for the actual value of the error messages
// since they are passed through the translator which will result in
// blank strings within this test framework.
// Test 1: Valid file
$upload = new fileupload('', array('jpg'), 1000);
$file = $this->gen_valid_filespec();
@@ -71,20 +68,20 @@ class phpbb_fileupload_test extends phpbb_test_case
$file = $this->gen_valid_filespec();
$file->filesize = 1000;
$upload->common_checks($file);
$this->assertEquals(1, sizeof($file->error));
$this->assertEquals('WRONG_FILESIZE', $file->error[0]);
// Test 3: Invalid filename
$upload = new fileupload('', array('jpg'), 100);
$file = $this->gen_valid_filespec();
$file->realname = 'invalid?';
$upload->common_checks($file);
$this->assertEquals(1, sizeof($file->error));
$this->assertEquals('INVALID_FILENAME', $file->error[0]);
// Test 4: Invalid extension
$upload = new fileupload('', array('png'), 100);
$file = $this->gen_valid_filespec();
$upload->common_checks($file);
$this->assertEquals(1, sizeof($file->error));
$this->assertEquals('DISALLOWED_EXTENSION', $file->error[0]);
}
public function test_local_upload()