mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/14168] Add new test method and more tests
One test method to rule them all. PHPBB3-14168
This commit is contained in:
parent
53008c8782
commit
b90783a296
1 changed files with 44 additions and 1 deletions
|
@ -21,7 +21,7 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
|
||||||
{
|
{
|
||||||
$this->delete = $this->getMockBuilder('\phpbb\attachment\delete')
|
$this->delete = $this->getMockBuilder('\phpbb\attachment\delete')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
->setMethods(['delete', 'unlink'])
|
->setMethods(['delete', 'unlink_attachment'])
|
||||||
->getMock();
|
->getMock();
|
||||||
$this->resync = $this->getMockBuilder('\phpbb\attachment\resync')
|
$this->resync = $this->getMockBuilder('\phpbb\attachment\resync')
|
||||||
->disableOriginalConstructor()
|
->disableOriginalConstructor()
|
||||||
|
@ -66,4 +66,47 @@ class phpbb_attachment_manager_test extends \phpbb_test_case
|
||||||
$manager = $this->get_manager();
|
$manager = $this->get_manager();
|
||||||
$this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager));
|
$this->assertSame($output, call_user_func_array([$manager, 'delete'], $input_manager));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function data_manager()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array(
|
||||||
|
'delete',
|
||||||
|
'unlink_attachment',
|
||||||
|
'unlink',
|
||||||
|
['foo'],
|
||||||
|
['foo', 'file', false],
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'delete',
|
||||||
|
'unlink_attachment',
|
||||||
|
'unlink',
|
||||||
|
['foo', 'bar'],
|
||||||
|
['foo', 'bar', false],
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
array(
|
||||||
|
'delete',
|
||||||
|
'unlink_attachment',
|
||||||
|
'unlink',
|
||||||
|
['foo', 'bar', true],
|
||||||
|
['foo', 'bar', true],
|
||||||
|
true,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider data_manager
|
||||||
|
*/
|
||||||
|
public function test_manager($class, $method_class, $method_manager, $input_manager, $input_method, $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);
|
||||||
|
$manager = $this->get_manager();
|
||||||
|
$this->assertSame($output, call_user_func_array([$manager, $method_manager], $input_manager));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue