/**
  * Tests to ensure that the auto escape option is obeyed.
  */
 public function testAutoEscape()
 {
     $str = 'I\'m a string and it\'s got characters that could be escaped! <lalalala>';
     // First auto escape off.
     Database::setAutoEscape(false);
     $result = DatabaseTools::replaceVariables('{string:str}', array('str' => $str));
     $this->assertEquals('\'' . addcslashes($str, "'") . '\'', $result);
     // Now on!
     Database::setAutoEscape(true);
     $result = DatabaseTools::replaceVariables('{string:str}', array('str' => $str));
     $this->assertEquals('\'' . addcslashes(htmlspecialchars($str, ENT_QUOTES, 'UTF-8'), "'") . '\'', $result);
     Database::setAutoEscape(false);
 }
示例#2
0
 /**
  * Tests to ensure connecting to the database works.
  */
 public function testConnect()
 {
     $this->assertTrue(Database::connect());
 }
示例#3
0
 /**
  * Returns an instance of the Database.
  *
  * @return Database
  */
 public static function getDatabaseInstance()
 {
     if (is_null(self::$db)) {
         self::$db = Database::getInstance();
     }
     return self::$db;
 }
示例#4
0
 /**
  * Executes the built query.
  *
  * @return \Queryer\Driver\DatabaseDriverResult
  */
 public function execute()
 {
     // Is someone mocking us? Well... that's not very nice!
     if (!is_null(self::$mocker)) {
         return self::$mocker->execute($this->options);
     }
     // Otherwise we'll hit up the driver.
     return Database::getInstance()->execute($this->options);
 }
示例#5
0
 /**
  * Tests to ensure setting the auto escape option works.
  */
 public function testSetAutoEscape()
 {
     Database::setAutoEscape(true);
     $this->assertTrue(Database::getAutoEscape());
     // Set it back to the default.
     Database::setAutoEscape(false);
 }