Back to index

php5  5.3.10
Static Public Member Functions
PDOTest Class Reference
Inheritance diagram for PDOTest:
Inheritance graph
[legend]

List of all members.

Static Public Member Functions

static factory ($classname= 'PDO', $drop_test_tables=true)
static skip ()
static test_factory ($file)

Detailed Description

Definition at line 19 of file pdo_test.inc.


Member Function Documentation

static PDOTest::factory ( classname = 'PDO',
drop_test_tables = true 
) [static]

Definition at line 22 of file pdo_test.inc.

                                                                             {
              $dsn = getenv('PDOTEST_DSN');
              $user = getenv('PDOTEST_USER');
              $pass = getenv('PDOTEST_PASS');
              $attr = getenv('PDOTEST_ATTR');
              if (is_string($attr) && strlen($attr)) {
                     $attr = unserialize($attr);
              } else {
                     $attr = null;
              }

              if ($user === false) $user = NULL;
              if ($pass === false) $pass = NULL;

              $db = new $classname($dsn, $user, $pass, $attr);

              if (!$db) {
                     die("Could not create PDO object (DSN=$dsn, user=$user)\n");
              }

              // clean up any crufty test tables we might have left behind
              // on a previous run
              static $test_tables = array(
                     'test',
                     'test2',
                     'classtypes'
                     );
              if ($drop_test_tables) {
                     foreach ($test_tables as $table) {
                            $db->exec("DROP TABLE $table");
                     }
              }

              $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
              $db->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
              $db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
              return $db;
       }

Here is the caller graph for this function:

static PDOTest::skip ( ) [static]

Definition at line 61 of file pdo_test.inc.

                              {
              try {
                     $db = PDOTest::factory();
              } catch (PDOException $e) {
                     die("skip " . $e->getMessage());
              }
       }

Here is the call graph for this function:

static PDOTest::test_factory ( file) [static]

Definition at line 69 of file pdo_test.inc.

                                           {
              $data = file_get_contents($file);
              $data = preg_replace('/^.*--REDIRECTTEST--/s', '', $data);
              $config = eval($data);
              foreach ($config['ENV'] as $k => $v) {
                     putenv("$k=$v");
              }
              return self::factory();
       }

Here is the call graph for this function:


The documentation for this class was generated from the following file: