aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-10-09 14:33:12 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-10-09 14:33:12 +0200
commit52dccd3dba0808e4e19aa8407da1d4c75fe241cd (patch)
tree809117ade566c3cbc16a87d38056f486fac104f7
parentb90783a296bc15427e9f29a5ed4d0912afcfa6b4 (diff)
downloadforums-52dccd3dba0808e4e19aa8407da1d4c75fe241cd.tar
forums-52dccd3dba0808e4e19aa8407da1d4c75fe241cd.tar.gz
forums-52dccd3dba0808e4e19aa8407da1d4c75fe241cd.tar.bz2
forums-52dccd3dba0808e4e19aa8407da1d4c75fe241cd.tar.xz
forums-52dccd3dba0808e4e19aa8407da1d4c75fe241cd.zip
[ticket/14168] Add more test cases for attachment manager
PHPBB3-14168
-rw-r--r--tests/attachment/manager_test.php81
1 files changed, 50 insertions, 31 deletions
diff --git a/tests/attachment/manager_test.php b/tests/attachment/manager_test.php
index 85a6465ab9..01a6049602 100644
--- a/tests/attachment/manager_test.php
+++ b/tests/attachment/manager_test.php
@@ -38,35 +38,6 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
return new \phpbb\attachment\manager($this->delete, $this->resync, $this->upload);
}
- public function data_delete()
- {
- return array(
- [
- ['foo', [1, 2, 3], false],
- ['foo', [1, 2, 3], false],
- true,
- ],
- [
- ['foo', [1, 2, 3], true],
- ['foo', [1, 2, 3]],
- true,
- ],
- );
- }
-
- /**
- * @dataProvider data_delete
- */
- public function test_delete($input, $input_manager, $output)
- {
- $mock = $this->delete->expects($this->atLeastOnce())
- ->method('delete');
- $mock = call_user_func_array([$mock, 'with'], $input);
- $mock->willReturn($output);
- $manager = $this->get_manager();
- $this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager));
- }
-
public function data_manager()
{
return array(
@@ -77,6 +48,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
['foo'],
['foo', 'file', false],
true,
+ true,
),
array(
'delete',
@@ -85,6 +57,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
['foo', 'bar'],
['foo', 'bar', false],
true,
+ true,
),
array(
'delete',
@@ -93,6 +66,52 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
['foo', 'bar', true],
['foo', 'bar', true],
true,
+ true,
+ ),
+ array(
+ 'delete',
+ 'delete',
+ 'delete',
+ ['foo', [1, 2, 3]],
+ ['foo', [1, 2, 3], true],
+ true,
+ true,
+ ),
+ array(
+ 'delete',
+ 'delete',
+ 'delete',
+ ['foo', [1, 2, 3], false],
+ ['foo', [1, 2, 3], false],
+ true,
+ true,
+ ),
+ array(
+ 'resync',
+ 'resync',
+ 'resync',
+ ['foo', [1, 2, 3]],
+ ['foo', [1, 2, 3]],
+ true,
+ null,
+ ),
+ array(
+ 'upload',
+ 'upload',
+ 'upload',
+ ['foo', 1],
+ ['foo', 1, false, '', false, []],
+ true,
+ true,
+ ),
+ array(
+ 'upload',
+ 'upload',
+ 'upload',
+ ['foo', 1, true, 'bar', true, ['filename' => 'foobar']],
+ ['foo', 1, true, 'bar', true, ['filename' => 'foobar']],
+ true,
+ true,
),
);
}
@@ -100,12 +119,12 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
/**
* @dataProvider data_manager
*/
- public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $output)
+ public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $return, $output)
{
$mock = call_user_func_array([$this->{$class}, 'expects'], [$this->atLeastOnce()]);
$mock = $mock->method($method_class);
$mock = call_user_func_array([$mock, 'with'], $input_method);
- $mock->willReturn($output);
+ $mock->willReturn($return);
$manager = $this->get_manager();
$this->assertSame($output, call_user_func_array([$manager, $method_manager], $input_manager));
}