diff options
-rw-r--r-- | src/Bridge.php | 11 | ||||
-rw-r--r-- | test/BridgeTest.php | 17 |
2 files changed, 28 insertions, 0 deletions
diff --git a/src/Bridge.php b/src/Bridge.php index 6b83230..e46013d 100644 --- a/src/Bridge.php +++ b/src/Bridge.php @@ -72,6 +72,17 @@ class Bridge { return $count == 1; } + public function unregisterMessage($messageId) { + throw_if_null($messageId); + + $sql = 'DELETE FROM posts WHERE message_id = ' . + $this->db->quote($messageId); + + $coult = $this->db->exec($sql); + + return $count == 1; + } + protected function get_exactly_one_row($sql) { $result = $this->db->query($sql); diff --git a/test/BridgeTest.php b/test/BridgeTest.php index 7912327..cc094e6 100644 --- a/test/BridgeTest.php +++ b/test/BridgeTest.php @@ -129,6 +129,23 @@ class BridgeTest extends PHPUnit_Framework_TestCase { } /** + * @dataProvider providerUnregisterMessage + */ + public function testUnregisterMessage($messageId, $expected, $ex) { + if ($ex) $this->setExpectedException($ex); + $bridge = new Bridge($this->db); + $this->assertEquals($expected, $bridge->unregisterMessage($messageId)); + } + + public function providerUnregisterMessage() { + return array( + array(null, null, 'Exception'), + array('<20100302094228.33F0310091@charybdis.ellipsis.cx>', true, null), + array('<10100302094228.33F0310091@charybdis.ellipsis.cx>', false, null) + ); + } + + /** * @dataProvider providerGetDefaultForumId */ public function testGetDefaultForumId($list, $expected, $ex) { |