connection = new Connection($config); DbManager::getInstance()->addConnection($this->connection); $connection = DbManager::getInstance()->getConnection(); $this->assertTrue($connection === $this->connection); } function testAddConnection() { $config = new Config(MYSQL_CONFIG); DbManager::getInstance()->addConnection(new Connection($config), 'test'); $connection = DbManager::getInstance()->getConnection('test'); $this->assertFalse($connection === $this->connection); } function testOnQuery() { DbManager::getInstance()->onQuery(function ($ret, $temp, $start) { $this->assertTrue($ret instanceof Result); $this->assertTrue($temp instanceof QueryBuilder); $this->assertIsFloat($start); }); $queryBuild = new QueryBuilder(); $queryBuild->raw("show tables"); $data = DbManager::getInstance()->query($queryBuild); $this->assertTrue($data instanceof Result); } function testGetConnection() { $connection = DbManager::getInstance()->getConnection(); $queryBuild = new QueryBuilder(); $queryBuild->raw("show tables"); $data = $connection->defer()->query($queryBuild); $this->assertTrue($data instanceof Result); } function testQuery() { $queryBuild = new QueryBuilder(); $queryBuild->raw("show tables"); $data = DbManager::getInstance()->query($queryBuild); $this->assertTrue($data instanceof Result); } }