diff options
-rw-r--r-- | src/Bridge.php | 13 | ||||
-rw-r--r-- | test/BridgeTest.php | 17 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/Bridge.php b/src/Bridge.php index 3884154..54f9880 100644 --- a/src/Bridge.php +++ b/src/Bridge.php @@ -58,6 +58,19 @@ class Bridge { return $row ? $row['forum_id'] : false; } + public function getLists($forumId) { + throw_if_null($forumId); + + $sql = 'SELECT list_name FROM forums ' . + 'WHERE forum_id = ' . $forumId; + + $result = $this->db->query($sql); + + $rows = $result->fetchAll(PDO::FETCH_COLUMN); + $result->closeCursor(); + return $rows; + } + public function registerMessage($messageId, $inReplyTo, $references) { throw_if_null($messageId); diff --git a/test/BridgeTest.php b/test/BridgeTest.php index 1c78866..d31f37d 100644 --- a/test/BridgeTest.php +++ b/test/BridgeTest.php @@ -164,6 +164,23 @@ class BridgeTest extends PHPUnit_Framework_TestCase { } /** + * @dataProvider providerGetLists + */ + public function testGetLists($forumId, $expected, $ex) { + if ($ex) $this->setExpectedException($ex); + $bridge = new Bridge($this->db); + $this->assertEquals($expected, $bridge->getLists($forumId)); + } + + public function providerGetLists() { + return array( + array(null, null, 'Exception'), + array('bogus', false, null), + array(2, array('messages@forums.vassalengine.org'), null) + ); + } + + /** * @dataProvider providerSetPostId */ public function testSetPostId($messageId, $postId, $ex) { |