Example #1
0
 public function test___construct()
 {
     $conn = \Xoops\Core\Database\Factory::getConnection();
     $instance = new $this->myClass($conn);
     $this->assertInstanceOf($this->myClass, $instance);
     $this->assertInstanceOf('Xoops\\Core\\Kernel\\XoopsObjectHandler', $instance);
 }
Example #2
0
 public function test_getInstance()
 {
     $conn = Factory::getConnection();
     $auth = new Xoops_Auth_ProvisioningTest_AuthAbstractInstance($conn);
     $instance = \Xoops\Auth\Provisioning::getInstance($auth);
     $instance2 = \Xoops\Auth\Provisioning::getInstance($auth);
     $this->assertSame($instance, $instance2);
 }
Example #3
0
 public function test_authenticate()
 {
     $conn = \Xoops\Core\Database\Factory::getConnection();
     $instance = new $this->myClass($conn);
     $uname = 'admin';
     $pwd = 'pwd';
     $value = $instance->authenticate($uname, $pwd);
     $this->assertSame(false, $value);
 }
Example #4
0
 /**
  * this is a legacy compatibility shim to make the legacy database available
  *
  * @param Connection $db reference to the {@link Connection} object
  */
 protected function __construct(Connection $db = null, $table = '', $className = '', $keyName = '', $identifierName = '')
 {
     if ($db === null) {
         $this->db2 = \Xoops\Core\Database\Factory::getConnection();
         $db = $this->db2;
     }
     $this->db = XoopsDatabaseFactory::getDatabaseConnection();
     // get legacy connection
     parent::__construct($db, $table, $className, $keyName, $identifierName);
 }
 public function test___construct()
 {
     $conn = \Xoops\Core\Database\Factory::getConnection();
     $table = 'table';
     $className = 'className';
     $keyName = 'keyName';
     $identifierName = 'identifierName';
     $instance = new $this->myclass($conn, $table, $className, $keyName, $identifierName);
     $this->assertInstanceOf($this->myclass, $instance);
     $this->assertInstanceOf('Xoops\\Core\\Kernel\\XoopsPersistableObjectHandler', $instance);
 }
 /**
  * Get a reference to the only instance of database class and connects to DB
  *
  * if the class has not been instantiated yet, this will also take
  * care of that
  *
  * Legacy support function
  *
  * NOTE: Persistance connection is not supported nor needed with Doctrine.
  *       XOOPS_DB_PCONNECT is ignored.
  *
  * @return XoopsDatabase Reference to the only instance of database class
  */
 public static function getDatabaseConnection()
 {
     static $legacy;
     $file = \XoopsBaseConfig::get('root-path') . '/class/database/mysqldatabase.php';
     if (!isset($legacy) && file_exists($file)) {
         require_once $file;
         if (!defined('XOOPS_DB_PROXY')) {
             $class = 'XoopsMysqlDatabaseSafe';
         } else {
             $class = 'XoopsMysqlDatabaseProxy';
         }
         \Xoops::getInstance()->events()->triggerEvent('core.class.database.databasefactory.connection', array(&$class));
         $legacy = new $class();
         $legacy->setPrefix(\XoopsBaseConfig::get('db-prefix'));
         $legacy->conn = \Xoops\Core\Database\Factory::getConnection();
     }
     if (is_null($legacy->conn)) {
         trigger_error('notrace:Unable to connect to database', E_USER_ERROR);
     }
     return $legacy;
 }
Example #7
0
 /**
  * @covers Xoops\Core\Database\Factory::getConnection
  */
 public function testGetConnection()
 {
     $result = Factory::getConnection();
     $this->assertInstanceOf('\\Xoops\\Core\\Database\\Connection', $result);
 }
Example #8
0
 /**
  * get database connection instance
  *
  * @return Xoops\Core\Database\Connection
  */
 public function db()
 {
     return \Xoops\Core\Database\Factory::getConnection();
 }
 public function setUp()
 {
     $this->conn = \Xoops\Core\Database\Factory::getConnection();
 }
Example #10
0
 /**
  * Constructor
  *
  */
 public function __construct()
 {
     Language::load('database', 'xmf');
     $this->db = Factory::getConnection();
     $this->queueReset();
 }
Example #11
0
 public function test___construct()
 {
     $conn = \Xoops\Core\Database\Factory::getConnection();
     $instance = new $this->myclass($conn);
     $this->assertInstanceOf($this->myclass, $instance);
 }
Example #12
0
 public function test_resetpwd()
 {
     $conn = \Xoops\Core\Database\Factory::getConnection();
     $auth = new Xoops_Auth_ProvisioningTest_AuthAbstractInstance($conn);
     $class = $this->myclass;
     $instance = $class::getInstance($auth);
     $instance->resetpwd();
     $this->assertTrue(true);
     // always OK
 }