public function testGh91GetConnectionWithNullConnectionIsAlwaysDefault() { $connOne = ConnectionManager::getConnection('mysql'); $connTwo = ConnectionManager::getConnection(); $connThree = ConnectionManager::getConnection('mysql'); $connFour = ConnectionManager::getConnection(); $this->assertSame($connOne, $connThree); $this->assertSame($connTwo, $connThree); $this->assertSame($connFour, $connThree); }
public function setUp($connection_name = null) { require_once 'DatabaseLoader.php'; Table::clearCache(); $config = Config::instance(); $this->original_default_connection = $config->getDefaultConnection(); if ($connection_name) { $config->setDefaultConnection($connection_name); } /* if ($connection_name === 'sqlite' || $config->getDefaultConnection() === 'sqlite') { // need to create the db. the adapter specifically does not create it for us. //static::$db = \substr(Config::instance()->getConnection('sqlite'), 9); //new Sqlite(static::$db); //$file_db = new PDO('sqlite:messaging.sqlite3'); if ($GLOBALS['OS'] !== 'WIN') { new \PDO('sqlite:../Fixtures/test.db'); } else { new \PDO('sqlite:../Fixtures/test.db'); } var_dump($config); var_dump($GLOBALS['OS']); exit(); } */ $this->connection_name = $connection_name; try { $this->conn = ConnectionManager::getConnection($connection_name); } catch (ExceptionDatabase $e) { $this->markTestSkipped($connection_name . ' failed to connect. ' . $e->getMessage()); } $GLOBALS['Activerecord_LOG'] = false; $loader = new DatabaseLoader($this->conn); $loader->resetTableData(); if (self::$log) { $GLOBALS['Activerecord_LOG'] = true; } }
public function reestablishConnection($close = true) { // if connection name property is null the connection manager will use the default connection $connection = $this->class->getStaticPropertyValue('connection', null); if ($close) { ConnectionManager::dropConnection($connection); static::clearCache(); } return $this->conn = ConnectionManager::getConnection($connection); }
public function testSubstituteEscapeQuotesWithConnectionsEscapeMethod() { try { $conn = ConnectionManager::getConnection(); } catch (ExceptionDatabase $e) { $this->markTestSkipped('failed to connect. ' . $e->getMessage()); } $a = new Expressions(null, 'name=?', "Tito's Guild"); $a->setConnection($conn); $escaped = $conn->escape("Tito's Guild"); $this->assertEquals("name={$escaped}", $a->toString(true)); }