summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Bridge.php12
-rw-r--r--test/BridgeTest.php28
2 files changed, 29 insertions, 11 deletions
diff --git a/src/Bridge.php b/src/Bridge.php
index 98667ed..ad3b6c3 100644
--- a/src/Bridge.php
+++ b/src/Bridge.php
@@ -28,19 +28,19 @@ class Bridge {
return $row['message_id'];
}
- public function registerMessage($msg, $parentId) {
+ public function registerMessage($postId, $messageId, $inReplyTo, $refs) {
$sql = 'INSERT INTO posts ' .
'(post_id, message_id, in_reply_to, refs) ' .
- 'VALUES (' . $msg->getPostId() . ', '
- . $this->db->quote($msg->getMessageId()) . ', '
- . $this->db->quote() . ', '
- . $this->db->quote($msg->getReferences()) . ')';
+ 'VALUES (' . $postId . ', '
+ . $this->db->quote($messageId) . ', '
+ . $this->db->quote($inReplyTo) . ', '
+ . $this->db->quote($refs) . ')';
$count = $this->db->exec($sql);
if ($count != 1) {
trigger_error(
- 'Failed to register message: ' . $msg->getMessageId(), E_USER_ERROR
+ 'Failed to register message: ' . $messageId, E_USER_ERROR
);
}
}
diff --git a/test/BridgeTest.php b/test/BridgeTest.php
index c7f6f47..b90ae02 100644
--- a/test/BridgeTest.php
+++ b/test/BridgeTest.php
@@ -96,15 +96,33 @@ class BridgeTest extends PHPUnit_Framework_TestCase {
/**
* @dataProvider providerRegisterMessage
*/
- public function testRegisterMessage($msg, $expected, $ex) {
- $this->markTestIncomplete();
-# $bridge = new Bridge($this->db);
-# if ($ex) $this->setExpectedException($ex);
-# $this->assertEquals($expected, $bridge->registerMessage($msg));
+ public function testRegisterMessage($postId, $messageId, $inReplyTo, $refs,
+ $expected, $ex) {
+ if ($ex) $this->setExpectedException($ex);
+ $bridge = new Bridge($this->db);
+ $bridge->registerMessage($postId, $messageId, $inReplyTo, $refs);
}
public function providerRegisterMessage() {
return array(
+ array('bogus', null, null, null, null, 'PDOException'),
+ array(1, '', '', '', null, 'PDOException'),
+ array(
+ 2,
+ '<20100302094228.33F0310091@charybdis.ellipsis.cx>',
+ null,
+ null,
+ null,
+ 'PDOException'
+ ),
+ array(
+ 2,
+ '<10100302094228.33F0310091@charybdis.ellipsis.cx>',
+ null,
+ null,
+ null,
+ null,
+ )
);
}