/** * Ensures that all the prerequisites exist for connecting via mysqli */ public function setUp() { if (!extension_loaded("mysqli")) { $this->markTestSkipped("MySQLi extension is not loaded"); } // Ensure the proper configuration exists $config = new \r8\Test\Config("MYSQLI", array("HOST", "PORT", "DATABASE", "USERNAME", "PASSWORD", "TABLE")); $config->test(); // Test the connection $mysqli = @new mysqli(MYSQLI_HOST, MYSQLI_USERNAME, MYSQLI_PASSWORD, MYSQLI_DATABASE, MYSQLI_PORT); if ($mysqli->connect_error) { $this->markTestSkipped("MySQLi Connection Error: " . mysqli_connect_error()); } $result = $mysqli->query("DROP TEMPORARY TABLE IF EXISTS `" . MYSQLI_TABLE . "`"); if (!$result) { $this->markTestSkipped("MySQLi Error (#" . $mysqli->errno . "): " . $mysqli->error); } $result = $mysqli->query("CREATE TEMPORARY TABLE `" . MYSQLI_TABLE . "` (\n `id` INT NOT NULL auto_increment ,\n `label` VARCHAR( 255 ) NOT NULL ,\n `data` VARCHAR( 255 ) NOT NULL ,\n PRIMARY KEY ( `id` ) ,\n INDEX ( `label` ))"); if (!$result) { $this->markTestSkipped("MySQLi Error (#" . $mysqli->errno . "): " . $mysqli->error); } $result = $mysqli->query("INSERT INTO `" . MYSQLI_TABLE . "`\n VALUES (1, 'alpha', 'one'),\n (2, 'beta', 'two'),\n (3, 'gamma', 'three')"); if (!$result) { $this->markTestSkipped("MySQLi Error (#" . $mysqli->errno . "): " . $mysqli->error); } $this->db = $mysqli; }
public function setUp() { if (!extension_loaded('memcache')) { $this->markTestSkipped("Memcache extension not loaded"); } // Ensure the proper configuration exists $config = new \r8\Test\Config("MEMCACHE", array("HOST", "PORT")); $config->test(); // Test the connection $memcache = new Memcache(); if (!@$memcache->connect(MEMCACHE_HOST, MEMCACHE_PORT)) { $this->markTestSkipped("Unable to connect to Memcached server"); } }
public function setUp() { if (!extension_loaded('memcached')) { $this->markTestSkipped("Memcached extension not loaded"); } // Ensure the proper configuration exists $config = new \r8\Test\Config("MEMCACHE", array("HOST", "PORT")); $config->test(); $cache = new \Memcached(); $cache->addServer(MEMCACHE_HOST, MEMCACHE_PORT); if ($cache->getStats() === FALSE) { $this->markTestSkipped("Unable to connect to Memcached server"); } }
/** * Ensures that all the prerequisites exist for connecting via mysqli */ public function setUp() { if (!extension_loaded("mysqli")) { $this->markTestSkipped("MySQLi extension is not loaded"); } // Ensure the proper configuration exists $config = new \r8\Test\Config("MYSQLI", array("HOST", "PORT", "DATABASE", "USERNAME", "PASSWORD", "TABLE")); $config->test(); // Test the connection $mysqli = @new mysqli(MYSQLI_HOST, MYSQLI_USERNAME, MYSQLI_PASSWORD, MYSQLI_DATABASE, MYSQLI_PORT); if ($mysqli->connect_error) { $this->markTestSkipped("MySQLi Connection Error: " . mysqli_connect_error()); } $mysqli->close(); }
/** * Ensures that all the prerequisites exist for connecting to a SQLite db */ public function setUp() { if (!extension_loaded("sqlite")) { $this->markTestSkipped("SQLite extension is not loaded"); } // Ensure the proper configuration exists $config = new \r8\Test\Config("SQLITE", array("FILE", "TABLE")); $config->test(); // Test the connection $error = null; $db = @sqlite_open(SQLITE_FILE, 0666, $error); if (!$db) { $this->markTestSkipped("SQLite Connection Error: " . $error); } }
/** * Ensures that all the prerequisites exist for connecting to a SQLite db */ public function setUp() { if (!extension_loaded("sqlite")) { $this->markTestSkipped("SQLite extension is not loaded"); } // Ensure the proper configuration exists $config = new \r8\Test\Config("SQLITE", array("FILE", "TABLE")); $config->test(); // Test the connection $error = null; $db = @sqlite_open(SQLITE_FILE, 0666, $error); if (!$db) { $this->markTestSkipped("SQLite Connection Error: " . $error); } $error = null; $result = sqlite_query($db, "CREATE TEMPORARY TABLE " . SQLITE_TABLE . "(\n id INT NOT NULL PRIMARY KEY,\n label VARCHAR( 255 ) NOT NULL,\n data VARCHAR( 255 ) NOT NULL\n )", SQLITE_ASSOC, $error); if (!$result) { $this->markTestSkipped("SQLite Error: " . $error); } $error = null; $result = sqlite_query($db, "INSERT INTO " . SQLITE_TABLE . " VALUES (1, 'alpha', 'one')", SQLITE_ASSOC, $error); if (!$result) { $this->markTestSkipped("SQLite Error: " . $error); } $error = null; $result = sqlite_query($db, "INSERT INTO " . SQLITE_TABLE . " VALUES (2, 'beta', 'two')", SQLITE_ASSOC, $error); if (!$result) { $this->markTestSkipped("SQLite Error: " . $error); } $error = null; $result = sqlite_query($db, "INSERT INTO " . SQLITE_TABLE . " VALUES (3, 'gamma', 'three')", SQLITE_ASSOC, $error); if (!$result) { $this->markTestSkipped("SQLite Error: " . $error); } $this->db = $db; }