[PECL-CVS] [pecl-database-pdo_ibm] pdo-class-8.5: Make test use driver's class constants on PHP 8.4+

[email protected] (Calvin Buckley)
Newsgroups php.pecl.cvs
Message-ID <[email protected]>
Author: Calvin Buckley (NattyNarwhal)
Date: 2025-09-11T12:26:36-03:00

Commit: https://github.com/php/pecl-database-pdo_ibm/commit/eb96a7ceceb0618090b1770967ec55c36c4c0603
Raw diff: https://github.com/php/pecl-database-pdo_ibm/commit/eb96a7ceceb0618090b1770967ec55c36c4c0603.diff

Make test use driver's class constants on PHP 8.4+

Needed because on 8.5, the PDO ones trigger a deprecation message.

IBM i specific tests also need this, but they don't run in CI yet.

Changed paths:
  M  tests/fvt_client_info.phpt


Diff:

diff --git a/tests/fvt_client_info.phpt b/tests/fvt_client_info.phpt
index d44fee3..8d5ee86 100644
--- a/tests/fvt_client_info.phpt
+++ b/tests/fvt_client_info.phpt
@@ -11,22 +11,33 @@ pdo_ibm: Client Info
 		{
 			print "Attempting to connect..\n";
 			$this->connect();
+
+			// Use class constants in 8.4 or newer, 8.5 will show
+			// a deprecation message when using the PDO constants
+			$userID = version_compare(PHP_VERSION, '8.4.0') >= 0
+				? \PDO\Ibm::ATTR_INFO_USERID : PDO::SQL_ATTR_INFO_USERID;
+			$acctStr = version_compare(PHP_VERSION, '8.4.0') >= 0
+				? \PDO\Ibm::ATTR_INFO_ACCTSTR : PDO::SQL_ATTR_INFO_ACCTSTR;
+			$applName = version_compare(PHP_VERSION, '8.4.0') >= 0
+				? \PDO\Ibm::ATTR_INFO_APPLNAME : PDO::SQL_ATTR_INFO_APPLNAME;
+			$wrkstnName = version_compare(PHP_VERSION, '8.4.0') >= 0
+				? \PDO\Ibm::ATTR_INFO_WRKSTNNAME : PDO::SQL_ATTR_INFO_WRKSTNNAME;
 			
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_USERID));
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_ACCTSTR));
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_APPLNAME));
+			var_dump($this->db->getAttribute($userID));
+			var_dump($this->db->getAttribute($acctStr));
+			var_dump($this->db->getAttribute($applName));
 			// This will default to the hostname of the system nowadays.
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_WRKSTNNAME));
+			var_dump($this->db->getAttribute($wrkstnName));
 		
-			$this->db->setAttribute(PDO::SQL_ATTR_INFO_USERID, "MyUser");
-			$this->db->setAttribute(PDO::SQL_ATTR_INFO_ACCTSTR, "MyAccountString");
-			$this->db->setAttribute(PDO::SQL_ATTR_INFO_APPLNAME, "MyApp");
-			$this->db->setAttribute(PDO::SQL_ATTR_INFO_WRKSTNNAME, "MyWorkStation");
+			$this->db->setAttribute($userID, "MyUser");
+			$this->db->setAttribute($acctStr, "MyAccountString");
+			$this->db->setAttribute($applName, "MyApp");
+			$this->db->setAttribute($wrkstnName, "MyWorkStation");
 			
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_USERID));
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_ACCTSTR));
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_APPLNAME));
-			var_dump($this->db->getAttribute(PDO::SQL_ATTR_INFO_WRKSTNNAME));
+			var_dump($this->db->getAttribute($userID));
+			var_dump($this->db->getAttribute($acctStr));
+			var_dump($this->db->getAttribute($applName));
+			var_dump($this->db->getAttribute($wrkstnName));
 		}
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.