mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/14168] Add tests for attachment delete class
PHPBB3-14168
This commit is contained in:
parent
583f42a2aa
commit
b00c7511f0
2 changed files with 71 additions and 1 deletions
|
@ -85,7 +85,7 @@ class delete
|
||||||
* @return int|bool Number of deleted attachments or false if something
|
* @return int|bool Number of deleted attachments or false if something
|
||||||
* went wrong during attachment deletion
|
* went wrong during attachment deletion
|
||||||
*/
|
*/
|
||||||
function delete($mode, $ids, $resync = true)
|
public function delete($mode, $ids, $resync = true)
|
||||||
{
|
{
|
||||||
if (!$this->set_attachment_ids($ids))
|
if (!$this->set_attachment_ids($ids))
|
||||||
{
|
{
|
||||||
|
|
70
tests/attachment/delete_test.php
Normal file
70
tests/attachment/delete_test.php
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* This file is part of the phpBB Forum Software package.
|
||||||
|
*
|
||||||
|
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||||
|
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||||
|
*
|
||||||
|
* For full copyright and license information, please see
|
||||||
|
* the docs/CREDITS.txt file.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once(dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php');
|
||||||
|
|
||||||
|
class phpbb_attachment_delete_test extends \phpbb_database_test_case
|
||||||
|
{
|
||||||
|
/** @var \phpbb\config\config */
|
||||||
|
protected $config;
|
||||||
|
|
||||||
|
/** @var \phpbb\db\driver\driver_interface */
|
||||||
|
protected $db;
|
||||||
|
|
||||||
|
/** @var \phpbb\attachment\resync */
|
||||||
|
protected $resync;
|
||||||
|
|
||||||
|
/** @var \phpbb\attachment\delete */
|
||||||
|
protected $attachment_delete;
|
||||||
|
|
||||||
|
public function getDataSet()
|
||||||
|
{
|
||||||
|
return $this->createXMLDataSet(dirname(__FILE__) . '/fixtures/resync.xml');
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setUp()
|
||||||
|
{
|
||||||
|
global $db;
|
||||||
|
|
||||||
|
parent::setUp();
|
||||||
|
|
||||||
|
$this->config = new \phpbb\config\config(array());
|
||||||
|
$this->db = $this->new_dbal();
|
||||||
|
$db = $this->db;
|
||||||
|
$this->resync = new \phpbb\attachment\resync($this->db);
|
||||||
|
$this->attachment_delete = new \phpbb\attachment\delete($this->config, $this->db, $this->resync);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function data_attachment_delete()
|
||||||
|
{
|
||||||
|
return array(
|
||||||
|
array('attach', '', false, false),
|
||||||
|
array('meh', 5, false, 0),
|
||||||
|
array('attach', array(5), false, 0),
|
||||||
|
array('attach', array(1,2), false, 2),
|
||||||
|
array('attach', array(1,2), true, 2),
|
||||||
|
array('post', 5, false, 0),
|
||||||
|
array('topic', 5, false, 0),
|
||||||
|
array('topic', 1, true, 2),
|
||||||
|
array('user', 1, false, 0),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider data_attachment_delete
|
||||||
|
*/
|
||||||
|
public function test_attachment_delete($mode, $ids, $resync, $expected)
|
||||||
|
{
|
||||||
|
$this->assertSame($expected, $this->attachment_delete->delete($mode, $ids, $resync));
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue