Skip to content

oci8: most tests fail out-of-the-box #11804

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
orlitzky opened this issue Jul 27, 2023 · 4 comments
Closed

oci8: most tests fail out-of-the-box #11804

orlitzky opened this issue Jul 27, 2023 · 4 comments

Comments

@orlitzky
Copy link
Contributor

Description

If I build a fresh clone of php-src with,

# note: needs ORACLE_HOME set in the environment
$ ./configure --disable-all --enable-cli --enable-pdo --with-pdo-oci --with-oci8

and then run the tests, most of the oci8 tests fail:

$ sapi/cli/php -n ./run-tests.php -n ext/oci8/tests
...
Running selected tests.
FAIL oci_bind_array_by_name() and invalid values 1 [ext/oci8/tests/array_bind_001.phpt] 
FAIL oci_bind_array_by_name() and invalid values 2 [ext/oci8/tests/array_bind_002.phpt] 
BORK Fatal error: connect.inc: Failed to connect as 'system' to 'localhost/XE': ORA-12541: TNS:no listener in /home/mjo/src/php-src/ext/oci8/tests/connect.inc on line 14 [ext/oci8/tests/array_bind_003.phpt] reason: invalid output from SKIPIF
BORK Fatal error: connect.inc: Failed to connect as 'system' to 'localhost/XE': ORA-12541: TNS:no listener in /home/mjo/src/php-src/ext/oci8/tests/connect.inc on line 14 [ext/oci8/tests/array_bind_004.phpt] reason: invalid output from SKIPIF
...

The ones that I've looked at are all expecting to be able to connect to a running Oracle DB via ext/oci8/tests/connect.inc:

$ cat ext/oci8/tests/connect.inc 
<?php

require("details.inc");

if (!empty($dbase)) {
    $c = @oci_connect($user, $password, $dbase);
}
else {
    $c = @oci_connect($user, $password);
}

if (!$c) {
    $m = oci_error();
    trigger_error("connect.inc: Failed to connect as '$user' to '$dbase': ". $m['message'], E_USER_ERROR);
}

?>

Naturally that fails unless you've created a database at the right place and with the right credentials. The other database extensions like mysqli and pgsql handle this by skipping the tests if a connection cannot be made, as in ext/mysqli/tests/skipifconnectfailure.inc or ext/pgsql/tests/skipif.inc. I think oci8 should do the same.

PHP Version

git HEAD

Operating System

No response

@Girgias
Copy link
Member

Girgias commented Jul 28, 2023

They should indeed do that, maybe it's a simple copy/paste/adapt the skipif files from mysqli/pgsql?

@orlitzky
Copy link
Contributor Author

They should indeed do that, maybe it's a simple copy/paste/adapt the skipif files from mysqli/pgsql?

Surely. I think my main question was whether or not connect.inc could be adapted to work in the SKIPIF as well, i.e. something a bit less messy than a direct copy/paste. But it would work.

Is someone in charge of the oci8 extension? I don't actually have an oracle server to test the success case with.

@Girgias
Copy link
Member

Girgias commented Jul 29, 2023

Technically @cjbj but they are quite busy

orlitzky added a commit to orlitzky/php-src that referenced this issue Jul 29, 2023
Most oci8 tests fail out-of-the-box because a typical host won't have
an Oracle database instance available. Other database drivers like
mysqli and pgsql address this problem with an include file, inserted
into SKIPIF, that skips the test if no connection at all can be made.

This commits adds such a file (skipifconnectfailure.inc) for oci8, and
adds the corresponding SKIPIF to any tests that connect to a database.

Closes phpGH-11804
@orlitzky
Copy link
Contributor Author

Big but straightforward PR: #11820

jorgsowa pushed a commit to jorgsowa/php-src that referenced this issue Aug 16, 2023
Most oci8 tests fail out-of-the-box because a typical host won't have
an Oracle database instance available. Other database drivers like
mysqli and pgsql address this problem with an include file, inserted
into SKIPIF, that skips the test if no connection at all can be made.

This commits adds such a file (skipifconnectfailure.inc) for oci8, and
adds the corresponding SKIPIF to any tests that connect to a database.

Closes phpGH-11804

* ext/oci8/tests/lob_aliases.phpt: drop unnecessary SKIPIF.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants