List:Commits« Previous MessageNext Message »
From:uwendel Date:October 23 2007 11:35am
Subject:PHP mysqlnd svn commit: r1131 - trunk/tests/ext/pdo
View as plain text  
Author: uwendel
Date: 2007-10-23 11:35:51 +0200 (Tue, 23 Oct 2007)
New Revision: 1131

Added:
   trunk/tests/ext/pdo/pdo_get_available_drivers.phpt
Log:
Does *any* PDO function work as described in the manual?
This is said to be static but its not. Also, would be nice
if it would reject invalid arguments, its void.



Added: trunk/tests/ext/pdo/pdo_get_available_drivers.phpt
===================================================================
--- trunk/tests/ext/pdo/pdo_get_available_drivers.phpt	2007-10-22 16:32:08 UTC (rev 1130)
+++ trunk/tests/ext/pdo/pdo_get_available_drivers.phpt	2007-10-23 09:35:51 UTC (rev 1131)
@@ -0,0 +1,67 @@
+--TEST--
+PDO Common: PDOStatement::getAvailableDrivers()
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded('pdo')) die('skip');
+$dir = getenv('REDIR_TEST_DIR');
+if (false == $dir) die('skip no driver');
+require_once $dir . 'pdo_test.inc';
+PDOTest::skip();
+?>
+--FILE--
+<?php
+if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.dirname(__FILE__) .
'/../../pdo/tests/');
+require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
+$db = PDOTest::factory();
+
+try {
+	$tmp = PDO::getAvailableDrivers('args', 'args');
+	if ((false !== $tmp) && (!is_null($tmp)))
+		printf("[001] Typically functions that get invoked with invalid arguments return NULL
or false, this one returned %s\n",
+			gettype($tmp));
+
+	$tmp = PDO::getAvailableDrivers();
+	if (!is_array($tmp)) {
+		printf("[002] Expecting array, got %s¸\n", gettype($tmp));
+	} else {
+		if (count($tmp) < 1)
+			printf("[003] Expecting array with at least one element\n");
+
+		if (!isset($tmp[0]))
+			printf("[004] Array should be a list, indexing should start at zero\n");
+
+		$driver = $db->getAttribute(PDO::ATTR_DRIVER_NAME);
+		$found = false;
+		foreach ($tmp as $k => $v) {
+			if ($v === $driver) {
+				$found = true;
+				break;
+			}
+		}
+
+		if (!$found) {
+			printf("[005] getAttribute(PDO::ATTR_DRIVER_NAME) and PDO::getAvailableDrivers() seem
inconsistent. Dumping data.\n");
+			var_dump($driver);
+			var_dump($tmp);
+		}
+
+	}
+
+	/*
+	Citing the manual:
+		This function returns all currently available PDO drivers which can be used in DSN
parameter of PDO->__construct(). This is a static method.
+	*/
+	// Fatal error
+	$tmp = $db->getAvailableDrivers();
+	if (is_array($tmp))
+		printf("[006] This is not a static method, change the manual or the
implementation!\n");
+
+} catch (PDOException $e) {
+	printf("[007] %s, [%s] %s\n",
+		$e->getMessage(), $db->errorCode(), implode(' ', $db->errorInfo()));
+}
+
+print "done!";
+?>
+--EXPECTF--
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1131 - trunk/tests/ext/pdouwendel23 Oct