summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Bridge.php12
-rw-r--r--test/BridgeTest.php18
2 files changed, 30 insertions, 0 deletions
diff --git a/src/Bridge.php b/src/Bridge.php
index 8b04f03..ba6ccc8 100644
--- a/src/Bridge.php
+++ b/src/Bridge.php
@@ -99,6 +99,18 @@ class Bridge {
}
}
+ public function unregisterPost($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 message id: ' . $messageId);
+ }
+ }
+
protected function get_exactly_one_row($sql) {
$result = $this->db->query($sql);
diff --git a/test/BridgeTest.php b/test/BridgeTest.php
index 6925847..f3d3b48 100644
--- a/test/BridgeTest.php
+++ b/test/BridgeTest.php
@@ -165,6 +165,24 @@ class BridgeTest extends PHPUnit_Framework_TestCase {
}
/**
+ * @dataProvider providerUnregisterPost
+ */
+ public function testUnregisterPost($postId, $ex) {
+ if ($ex) $this->setExpectedException($ex);
+ $bridge = new Bridge($this->db);
+ $bridge->unregisterPost($postId);
+ $this->assertEquals(false, $bridge->getMessageId($postId));
+ }
+
+ public function providerUnregisterMessage() {
+ return array(
+ array(null, 'Exception'),
+ array(1, 'Exception'),
+ array(2, null),
+ );
+ }
+
+ /**
* @dataProvider providerGetDefaultForumId
*/
public function testGetDefaultForumId($list, $expected, $ex) {