summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruckelman <uckelman@nomic.net>2010-04-13 20:29:30 +0000
committeruckelman <uckelman@nomic.net>2010-04-13 20:29:30 +0000
commit227c44ce079de309cf054899c15ec06b075d7940 (patch)
tree81caff29a92822efc66d142e71b4f90ad8ffabfe
parent1118926f9e87bfe9ec4f78cb560877fc8081cf28 (diff)
PHP apparently doesn't support function overloading. Bah!
git-svn-id: https://vassalengine.svn.sourceforge.net/svnroot/vassalengine/site-src/trunk@6701 67b53d14-2c14-4ace-a08f-0dab2b34000c
-rw-r--r--src/Bridge.php16
-rw-r--r--test/BridgeTest.php45
2 files changed, 15 insertions, 46 deletions
diff --git a/src/Bridge.php b/src/Bridge.php
index 9d59564..8ea229a 100644
--- a/src/Bridge.php
+++ b/src/Bridge.php
@@ -71,27 +71,13 @@ class Bridge {
return $rows;
}
- public function registerMessage($messageId, $inReplyTo, $references) {
- throw_if_null($messageId);
-
- $sql = 'INSERT IGNORE INTO posts ' .
- '(message_id, in_reply_to, refs) ' .
- 'VALUES (' . $this->db->quote($messageId) . ', '
- . $this->quote($inReplyTo) . ', '
- . $this->quote($references) . ')';
-
- $count = $this->db->exec($sql);
- return $count == 1;
- }
-
public function registerMessage($postId, $messageId,
$inReplyTo, $references) {
- throw_if_null($postId);
throw_if_null($messageId);
$sql = 'INSERT IGNORE INTO posts ' .
'(post_id, message_id, in_reply_to, refs) ' .
- 'VALUES (' . $postId . ', '
+ 'VALUES (' . ($postId === null ? 'NULL' : $postId) . ', '
. $this->db->quote($messageId) . ', '
. $this->quote($inReplyTo) . ', '
. $this->quote($references) . ')';
diff --git a/test/BridgeTest.php b/test/BridgeTest.php
index 28ef8d5..e2b98a7 100644
--- a/test/BridgeTest.php
+++ b/test/BridgeTest.php
@@ -94,24 +94,25 @@ class BridgeTest extends PHPUnit_Framework_TestCase {
array(1, '<20100302094228.33F0310091@charybdis.ellipsis.cx>', null),
);
}
-
+
/**
- * @dataProvider providerRegisterMessage3
+ * @dataProvider providerRegisterMessage
*/
- public function testRegisterMessage3($messageId, $inReplyTo, $refs,
+ public function testRegisterMessage($postId, $messageId, $inReplyTo, $refs,
$expected, $ex) {
if ($ex) $this->setExpectedException($ex);
$bridge = new Bridge($this->db);
$this->assertEquals(
$expected,
- $bridge->registerMessage($messageId, $inReplyTo, $refs)
+ $bridge->registerMessage($postId, $messageId, $inReplyTo, $refs)
);
}
- public function providerRegisterMessage3() {
+ public function providerRegisterMessage() {
return array(
array(null, null, null, null, 'Exception'),
array(
+ null,
'<20100302094228.33F0310091@charybdis.ellipsis.cx>',
null,
null,
@@ -119,47 +120,29 @@ class BridgeTest extends PHPUnit_Framework_TestCase {
null
),
array(
- '<10100302094228.33F0310091@charybdis.ellipsis.cx>',
+ 2,
+ '<20100302094228.33F0310091@charybdis.ellipsis.cx>',
null,
null,
- true,
+ false,
null
- )
- );
- }
-
- /**
- * @dataProvider providerRegisterMessage4
- */
- public function testRegisterMessage4($postId, $messageId, $inReplyTo, $refs,
- $expected, $ex) {
- if ($ex) $this->setExpectedException($ex);
- $bridge = new Bridge($this->db);
- $this->assertEquals(
- $expected,
- $bridge->registerMessage($postId, $messageId, $inReplyTo, $refs)
- );
- }
-
- public function providerRegisterMessage4() {
- return array(
- array(null, null, null, null, 'Exception'),
+ ),
array(
2,
- '<20100302094228.33F0310091@charybdis.ellipsis.cx>',
+ '<10100302094228.33F0310091@charybdis.ellipsis.cx>',
null,
null,
- false,
+ true,
null
),
array(
- 2,
+ null,
'<10100302094228.33F0310091@charybdis.ellipsis.cx>',
null,
null,
true,
null
- )
+ )
);
}