Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: oracle23ai
Browse files Browse the repository at this point in the history
yajra committed Jan 21, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 4790b5a commit 88f8014
Showing 3 changed files with 24 additions and 53 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -18,10 +18,11 @@ jobs:

services:
oracle:
image: deepdiver/docker-oracle-xe-11g:2.0
image: container-registry.oracle.com/database/free:latest-lite
ports:
- 49160:22
- 1521:1521
env:
ORACLE_PWD: oracle

strategy:
fail-fast: true
3 changes: 0 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
@@ -26,8 +26,5 @@
"dev-master": "3.x-dev"
}
},
"scripts": {
"docker": "docker run -d -p 49160:22 -p 1521:1521 deepdiver/docker-oracle-xe-11g"
},
"minimum-stability": "stable"
}
69 changes: 21 additions & 48 deletions tests/ConnectionTest.php
Original file line number Diff line number Diff line change
@@ -7,17 +7,12 @@ class ConnectionTest extends TestCase
{
const DEFAULT_USER = 'system';
const DEFAULT_PWD = 'oracle';
const DEFAULT_DSN = 'oci:dbname=127.0.0.1:1521/xe';
const DEFAULT_DSN = 'oci:dbname=127.0.0.1:1521/free';

/**
* @var Oci8
*/
protected $con = null;
protected ?Oci8 $con = null;

/**
* Set up a new object.
*
* @return null
*/
public function setUp(): void
{
@@ -29,20 +24,16 @@ public function setUp(): void

/**
* Test if it is a valid object.
*
* @return null
*/
public function testObject()
public function testObject(): void
{
$this->assertNotNull($this->con);
}

/**
* Test if can connect using persistent connections.
*
* @return null
*/
public function testPersistentConnection()
public function testPersistentConnection(): void
{
$user = getenv('OCI_USER') ?: self::DEFAULT_USER;
$pwd = getenv('OCI_PWD') ?: self::DEFAULT_PWD;
@@ -53,10 +44,8 @@ public function testPersistentConnection()

/**
* Test if can connect, using parameters.
*
* @return null
*/
public function testConnectionWithParameters()
public function testConnectionWithParameters(): void
{
$user = getenv('OCI_USER') ?: self::DEFAULT_USER;
$pwd = getenv('OCI_PWD') ?: self::DEFAULT_PWD;
@@ -68,7 +57,7 @@ public function testConnectionWithParameters()
/**
* Test if throws an exception when failing to open connection.
*/
public function testInvalidConnection()
public function testInvalidConnection(): void
{
$user = 'pdooci';
$pwd = 'pdooci';
@@ -82,21 +71,17 @@ public function testInvalidConnection()

/**
* Set and get an attribute.
*
* @return null
*/
public function testAttributes()
public function testAttributes(): void
{
$this->con->setAttribute(PDO::ATTR_AUTOCOMMIT, true);
$this->assertTrue($this->con->getAttribute(PDO::ATTR_AUTOCOMMIT));
}

/**
* Test the error code.
*
* @return null
*/
public function testErrorCode()
public function testErrorCode(): void
{
$this->expectException(PDOException::class);
$this->expectExceptionCode(942);
@@ -105,20 +90,16 @@ public function testErrorCode()

/**
* Test if OCI is present on the available drivers.
*
* @return null
*/
public function testDrivers()
public function testDrivers(): void
{
$this->assertTrue(in_array('oci', $this->con->getAvailableDrivers()));
}

/**
* Test if is on a transaction.
*
* @return null
*/
public function testInTransaction()
public function testInTransaction(): void
{
$this->con->beginTransaction();
$this->assertTrue($this->con->inTransaction());
@@ -128,10 +109,8 @@ public function testInTransaction()

/**
* Test quotes.
*
* @return null
*/
public function testQuote()
public function testQuote(): void
{
$this->assertEquals("'Nice'", $this->con->quote('Nice'));
$this->assertEquals("'Naughty '' string'", $this->con->quote('Naughty \' string'));
@@ -140,29 +119,25 @@ public function testQuote()
/**
* Test if fails if requiring the last inserted id without a sequence.
*
* @return null
*
* @throws \ReflectionException
*/
public function testLastIdWithoutSequence()
public function testLastIdWithoutSequence(): void
{
$this->assertEquals(0, $this->con->lastInsertId());
}

/**
* Test if returns the last inserted id with a sequence.
*
* @return null
*
* @throws \ReflectionException
*/
public function testLastIdWithSequence()
public function testLastIdWithSequence(): void
{
$id = $this->con->lastInsertId('person_sequence');
$this->assertTrue(is_numeric($id));
}

public function testCaseDefaultValue()
public function testCaseDefaultValue(): void
{
$case = $this->con->getAttribute(PDO::ATTR_CASE);
$this->assertEquals(PDO::CASE_NATURAL, $case);
@@ -171,44 +146,42 @@ public function testCaseDefaultValue()
/**
* Test setting case.
*
* @param int $case
*
* @dataProvider caseProvider
*/
public function testSettingCase($case)
public function testSettingCase(int $case): void
{
$this->con->setAttribute(PDO::ATTR_CASE, $case);
$this->assertEquals($case, $this->con->getAttribute(PDO::ATTR_CASE));
}

public function caseProvider()
public function caseProvider(): array
{
return [
[PDO::CASE_LOWER],
[PDO::CASE_UPPER],
];
}

public function testQuery()
public function testQuery(): void
{
$statement = $this->con->query('SELECT table_name FROM user_tables', null, null, null);
$this->assertInstanceOf(PDOStatement::class, $statement);
}

public function testClose()
public function testClose(): void
{
$this->con->close();
$this->assertEquals(['00000', null, null], $this->con->errorInfo());
}

public function testBindParamSingle()
public function testBindParamSingle(): void
{
$stmt = $this->con->prepare('INSERT INTO person (name) VALUES (?)');
$var = 'Joop';
$this->assertTrue($stmt->bindParam(1, $var, PDO::PARAM_STR));
}

public function testBindParamMultiple()
public function testBindParamMultiple(): void
{
$stmt = $this->con->prepare('INSERT INTO person, email (name) VALUES (:person, :email)');
$var = 'Joop';
@@ -217,7 +190,7 @@ public function testBindParamMultiple()
$this->assertTrue($stmt->bindParam(':email', $email, PDO::PARAM_STR));
}

public function testSetConnectionIdentifier()
public function testSetConnectionIdentifier(): void
{
$expectedIdentifier = 'PDO_OCI8_CON';

0 comments on commit 88f8014

Please sign in to comment.