/** * This constructor initializes the PDO metadata storage handler with the specified * configuration. The configuration is an associative array with the following * possible elements (set in config.php): * - 'usePersistentConnection': TRUE/FALSE if database connection should be persistent. * - 'dsn': The database connection string. * - 'username': Database user name * - 'password': Password for the database user. * * @param array $config An associative array with the configuration for this handler. */ public function __construct($config) { assert('is_array($config)'); $this->db = SimpleSAML\Database::getInstance(); }
/** * @covers SimpleSAML\Database::getInstance * @covers SimpleSAML\Database::generateInstanceId * @covers SimpleSAML\Database::__construct * @covers SimpleSAML\Database::connect * @covers SimpleSAML\Database::getSlave * @test */ public function slaves() { $getSlave = self::getMethod('getSlave'); $master = spl_object_hash(PHPUnit_Framework_Assert::readAttribute($this->db, 'dbMaster')); $slave = spl_object_hash($getSlave->invokeArgs($this->db, array())); $this->assertTrue($master == $slave, "getSlave should have returned the master database object"); $config = array('database.dsn' => 'sqlite::memory:', 'database.username' => null, 'database.password' => null, 'database.prefix' => 'phpunit_', 'database.persistent' => true, 'database.slaves' => array(array('dsn' => 'sqlite::memory:', 'username' => null, 'password' => null))); $sspConfiguration = new SimpleSAML_Configuration($config, "test/SimpleSAML/DatabaseTest.php"); $msdb = SimpleSAML\Database::getInstance($sspConfiguration); $slaves = PHPUnit_Framework_Assert::readAttribute($msdb, 'dbSlaves'); $gotSlave = spl_object_hash($getSlave->invokeArgs($msdb, array())); $this->assertEquals(spl_object_hash($slaves[0]), $gotSlave, "getSlave should have returned a slave database object"); }