Author: Kris.Wallsmith
Date: 2010-03-10 13:08:52 +0100 (Wed, 10 Mar 2010)
New Revision: 28457
Modified:
plugins/sfDoctrineMasterSlavePlugin/trunk/lib/connection/sfDoctrineMasterSlaveConnectionManager.class.php
plugins/sfDoctrineMasterSlavePlugin/trunk/test/unit/connection/sfDoctrineMasterSlaveConnectionManagerTest.php
Log:
[sfDoctrineMasterSlavePlugin] updated slave accessor to accept a connection as
an argument like the master accessor
Modified:
plugins/sfDoctrineMasterSlavePlugin/trunk/lib/connection/sfDoctrineMasterSlaveConnectionManager.class.php
===================================================================
---
plugins/sfDoctrineMasterSlavePlugin/trunk/lib/connection/sfDoctrineMasterSlaveConnectionManager.class.php
2010-03-10 11:57:46 UTC (rev 28456)
+++
plugins/sfDoctrineMasterSlavePlugin/trunk/lib/connection/sfDoctrineMasterSlaveConnectionManager.class.php
2010-03-10 12:08:52 UTC (rev 28457)
@@ -106,7 +106,7 @@
/**
* Returns a slave connection for a certain group.
*
- * @param string $group A connection group name
+ * @param string|Doctrine_Connection $group A Doctrine connection or
connection group name
*
* @return Doctrine_Connection A Doctrine connection object
*
@@ -119,6 +119,11 @@
$group = $this->getDefaultGroup();
}
+ if ($group instanceof Doctrine_Connection)
+ {
+ $group = $this->getConnectionGroup($group);
+ }
+
// use the master connection if we're in a transaction
$master = $this->getMasterConnection($group);
if ($master->getTransactionLevel())
Modified:
plugins/sfDoctrineMasterSlavePlugin/trunk/test/unit/connection/sfDoctrineMasterSlaveConnectionManagerTest.php
===================================================================
---
plugins/sfDoctrineMasterSlavePlugin/trunk/test/unit/connection/sfDoctrineMasterSlaveConnectionManagerTest.php
2010-03-10 11:57:46 UTC (rev 28456)
+++
plugins/sfDoctrineMasterSlavePlugin/trunk/test/unit/connection/sfDoctrineMasterSlaveConnectionManagerTest.php
2010-03-10 12:08:52 UTC (rev 28457)
@@ -5,7 +5,7 @@
*/
include dirname(__FILE__).'/../../../../../test/bootstrap/unit.php';
-$t = new lime_test(19);
+$t = new lime_test(21);
$manager = Doctrine_Manager::getInstance();
$pdo = new
PDO('sqlite://'.sfConfig::get('sf_cache_dir').'/master_slave_test.sqlite');
@@ -65,11 +65,11 @@
try
{
$connectionManager->getMasterConnection('default');
- $t->fail('->getMasterConnection() throws an exception if there is not master
connection');
+ $t->fail('->getMasterConnection() throws an exception if there is no master
connection');
}
catch (Exception $e)
{
- $t->pass('->getMasterConnection() throws an exception if there is not master
connection');
+ $t->pass('->getMasterConnection() throws an exception if there is no master
connection');
}
$connectionManager->setConnections(array(
@@ -90,6 +90,8 @@
$connections = $connectionManager->getConnections();
$t->is($slave->getName(), $connections['default']['current_slave'],
'->getSlaveConnection() returns a slave');
$t->ok(in_array($connections['default']['current_slave'],
$connections['default']['slaves']), '->getSlaveConnection() returns a slave');
+$t->ok(in_array($connectionManager->getSlaveConnection($conn3)->getName(),
$connections['default']['slaves']), '->getSlaveConnection() accepts a master
connection');
+$t->ok(in_array($connectionManager->getSlaveConnection($conn2)->getName(),
$connections['default']['slaves']), '->getSlaveConnection() accepts a slave
connection');
$slave = $connectionManager->getSlaveConnection();
$connections = $connectionManager->getConnections();
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.