summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Bridge.php12
-rw-r--r--src/F2M.php2
-rw-r--r--test/BridgeTest.php17
3 files changed, 30 insertions, 1 deletions
diff --git a/src/Bridge.php b/src/Bridge.php
index d9f0dec..b137b51 100644
--- a/src/Bridge.php
+++ b/src/Bridge.php
@@ -126,6 +126,18 @@ class Bridge {
}
}
+ public function removePost($postId) {
+ throw_if_null($postId);
+
+ $sql = 'DELETE FROM posts WHERE post_id = ' . $postId;
+
+ $count = $this->db->exec($sql);
+
+ if ($count < 1) {
+ throw new Exception('Failed to delete post id: ' . $postId);
+ }
+ }
+
protected function get_exactly_one_row($sql) {
$result = $this->db->query($sql);
diff --git a/src/F2M.php b/src/F2M.php
index 68d2a12..079c999 100644
--- a/src/F2M.php
+++ b/src/F2M.php
@@ -202,7 +202,7 @@ function remove_post($postId) {
require_once(__DIR__ . '/Bridge.php');
$bridge = new Bridge();
- $bridge->unregisterPost($postId);
+ $bridge->removePost($postId);
}
function build_text_part($mime, $text) {
diff --git a/test/BridgeTest.php b/test/BridgeTest.php
index c078aaa..8688af3 100644
--- a/test/BridgeTest.php
+++ b/test/BridgeTest.php
@@ -206,6 +206,23 @@ class BridgeTest extends PHPUnit_Framework_TestCase {
}
/**
+ * @dataProvider providerRemovePost
+ */
+ public function testRemovePost($postId, $ex) {
+ if ($ex) $this->setExpectedException($ex);
+ $bridge = new Bridge($this->db);
+ $bridge->removePost($postId);
+ }
+
+ public function providerRemovePost() {
+ return array(
+ array(null, 'Exception'),
+ array(1, null),
+ array(2, 'Exception')
+ );
+ }
+
+ /**
* @dataProvider providerGetDefaultForumId
*/
public function testGetDefaultForumId($list, $expected, $ex) {