aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Alexander <admin@m-a-styles.de>2015-09-21 22:16:23 +0200
committerMarc Alexander <admin@m-a-styles.de>2015-10-09 10:15:40 +0200
commitb00c7511f022dfafb32f570db1f5fe762a62ef21 (patch)
treec4cd5be1f68b4a713e12fafe2bdd9f25719b4ff6
parent583f42a2aa5ba8132e9e516b363ba0180fe46289 (diff)
downloadforums-b00c7511f022dfafb32f570db1f5fe762a62ef21.tar
forums-b00c7511f022dfafb32f570db1f5fe762a62ef21.tar.gz
forums-b00c7511f022dfafb32f570db1f5fe762a62ef21.tar.bz2
forums-b00c7511f022dfafb32f570db1f5fe762a62ef21.tar.xz
forums-b00c7511f022dfafb32f570db1f5fe762a62ef21.zip
[ticket/14168] Add tests for attachment delete class
PHPBB3-14168
-rw-r--r--phpBB/phpbb/attachment/delete.php2
-rw-r--r--tests/attachment/delete_test.php70
2 files changed, 71 insertions, 1 deletions
diff --git a/phpBB/phpbb/attachment/delete.php b/phpBB/phpbb/attachment/delete.php
index 4c863a2205..372495aef0 100644
--- a/phpBB/phpbb/attachment/delete.php
+++ b/phpBB/phpbb/attachment/delete.php
@@ -85,7 +85,7 @@ class delete
* @return int|bool Number of deleted attachments or false if something
* went wrong during attachment deletion
*/
- function delete($mode, $ids, $resync = true)
+ public function delete($mode, $ids, $resync = true)
{
if (!$this->set_attachment_ids($ids))
{
diff --git a/tests/attachment/delete_test.php b/tests/attachment/delete_test.php
new file mode 100644
index 0000000000..19a5e0bcca
--- /dev/null
+++ b/tests/attachment/delete_test.php
@@ -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));
+ }
+}