Skip to content

Commit 52dccd3

Browse files
committed
[ticket/14168] Add more test cases for attachment manager
PHPBB3-14168
1 parent b90783a commit 52dccd3

1 file changed

Lines changed: 50 additions & 31 deletions

File tree

tests/attachment/manager_test.php

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -38,35 +38,6 @@ protected function get_manager()
3838
return new \phpbb\attachment\manager($this->delete, $this->resync, $this->upload);
3939
}
4040

41-
public function data_delete()
42-
{
43-
return array(
44-
[
45-
['foo', [1, 2, 3], false],
46-
['foo', [1, 2, 3], false],
47-
true,
48-
],
49-
[
50-
['foo', [1, 2, 3], true],
51-
['foo', [1, 2, 3]],
52-
true,
53-
],
54-
);
55-
}
56-
57-
/**
58-
* @dataProvider data_delete
59-
*/
60-
public function test_delete($input, $input_manager, $output)
61-
{
62-
$mock = $this->delete->expects($this->atLeastOnce())
63-
->method('delete');
64-
$mock = call_user_func_array([$mock, 'with'], $input);
65-
$mock->willReturn($output);
66-
$manager = $this->get_manager();
67-
$this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager));
68-
}
69-
7041
public function data_manager()
7142
{
7243
return array(
@@ -77,6 +48,7 @@ public function data_manager()
7748
['foo'],
7849
['foo', 'file', false],
7950
true,
51+
true,
8052
),
8153
array(
8254
'delete',
@@ -85,6 +57,7 @@ public function data_manager()
8557
['foo', 'bar'],
8658
['foo', 'bar', false],
8759
true,
60+
true,
8861
),
8962
array(
9063
'delete',
@@ -93,19 +66,65 @@ public function data_manager()
9366
['foo', 'bar', true],
9467
['foo', 'bar', true],
9568
true,
69+
true,
70+
),
71+
array(
72+
'delete',
73+
'delete',
74+
'delete',
75+
['foo', [1, 2, 3]],
76+
['foo', [1, 2, 3], true],
77+
true,
78+
true,
79+
),
80+
array(
81+
'delete',
82+
'delete',
83+
'delete',
84+
['foo', [1, 2, 3], false],
85+
['foo', [1, 2, 3], false],
86+
true,
87+
true,
88+
),
89+
array(
90+
'resync',
91+
'resync',
92+
'resync',
93+
['foo', [1, 2, 3]],
94+
['foo', [1, 2, 3]],
95+
true,
96+
null,
97+
),
98+
array(
99+
'upload',
100+
'upload',
101+
'upload',
102+
['foo', 1],
103+
['foo', 1, false, '', false, []],
104+
true,
105+
true,
106+
),
107+
array(
108+
'upload',
109+
'upload',
110+
'upload',
111+
['foo', 1, true, 'bar', true, ['filename' => 'foobar']],
112+
['foo', 1, true, 'bar', true, ['filename' => 'foobar']],
113+
true,
114+
true,
96115
),
97116
);
98117
}
99118

100119
/**
101120
* @dataProvider data_manager
102121
*/
103-
public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $output)
122+
public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $return, $output)
104123
{
105124
$mock = call_user_func_array([$this->{$class}, 'expects'], [$this->atLeastOnce()]);
106125
$mock = $mock->method($method_class);
107126
$mock = call_user_func_array([$mock, 'with'], $input_method);
108-
$mock->willReturn($output);
127+
$mock->willReturn($return);
109128
$manager = $this->get_manager();
110129
$this->assertSame($output, call_user_func_array([$manager, $method_manager], $input_manager));
111130
}

0 commit comments

Comments
 (0)