From 201a6c73c1720ce69f7bf0da6072b2e010c42308 Mon Sep 17 00:00:00 2001 From: MELLINGER Olivier Date: Wed, 16 Oct 2019 12:36:26 +0200 Subject: [PATCH 1/7] - add 2 new data types in ParameterContainer class in order to manage differently BLOB from CLOB, - for oci8 driver: add a new case statement in bindParametersFromContainer() method to save data binded as BLOB --- src/Adapter/Driver/Oci8/Statement.php | 7 +++++++ src/Adapter/ParameterContainer.php | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/Adapter/Driver/Oci8/Statement.php b/src/Adapter/Driver/Oci8/Statement.php index 2d8ca1eef8..e7a8e6323a 100644 --- a/src/Adapter/Driver/Oci8/Statement.php +++ b/src/Adapter/Driver/Oci8/Statement.php @@ -289,11 +289,18 @@ protected function bindParametersFromContainer() $type = SQLT_BIN; break; case ParameterContainer::TYPE_LOB: + case ParameterContainer::TYPE_CLOB: $type = OCI_B_CLOB; $clob = oci_new_descriptor($this->driver->getConnection()->getResource(), OCI_DTYPE_LOB); $clob->writetemporary($value, OCI_TEMP_CLOB); $value = $clob; break; + case ParameterContainer::TYPE_BLOB: + $type = OCI_B_BLOB; + $blob = oci_new_descriptor($this->driver->getConnection()->getResource(), OCI_DTYPE_LOB); + $blob->writetemporary($value, OCI_TEMP_BLOB); + $value = $blob; + break; case ParameterContainer::TYPE_STRING: default: $type = SQLT_CHR; diff --git a/src/Adapter/ParameterContainer.php b/src/Adapter/ParameterContainer.php index c630837752..acb9e9b9e0 100644 --- a/src/Adapter/ParameterContainer.php +++ b/src/Adapter/ParameterContainer.php @@ -22,6 +22,8 @@ class ParameterContainer implements Iterator, ArrayAccess, Countable const TYPE_BINARY = 'binary'; const TYPE_STRING = 'string'; const TYPE_LOB = 'lob'; + const TYPE_BLOB = 'blob'; + const TYPE_CLOB = 'clob'; /** * Data From 0e20b2b4762f885b4e9881f7f8cd8584d2e30931 Mon Sep 17 00:00:00 2001 From: MELLINGER Olivier Date: Thu, 17 Oct 2019 11:47:31 +0200 Subject: [PATCH 2/7] - created test cases for oci8 copy/pasting the ones existing for the other drivers, - created 3 test cases to test the blob/clob implementation --- .ci/oracle_fixtures.sh | 5 + phpunit.xml.dist | 5 +- .../Adapter/Driver/Oci8/ConnectionTest.php | 25 +++ .../Adapter/Driver/Oci8/TableGatewayTest.php | 150 ++++++++++++++++++ .../Adapter/Driver/Oci8/TraitSetup.php | 44 +++++ .../integration/Adapter/Platform/Oci8Test.php | 78 +++++++++ test/integration/IntegrationTestListener.php | 5 +- .../Platform/Oci8FixtureLoader.php | 100 ++++++++++++ test/integration/TestFixtures/oci8.sql | 55 +++++++ 9 files changed, 463 insertions(+), 4 deletions(-) create mode 100644 .ci/oracle_fixtures.sh create mode 100644 test/integration/Adapter/Driver/Oci8/ConnectionTest.php create mode 100644 test/integration/Adapter/Driver/Oci8/TableGatewayTest.php create mode 100644 test/integration/Adapter/Driver/Oci8/TraitSetup.php create mode 100644 test/integration/Adapter/Platform/Oci8Test.php create mode 100644 test/integration/Platform/Oci8FixtureLoader.php create mode 100644 test/integration/TestFixtures/oci8.sql diff --git a/.ci/oracle_fixtures.sh b/.ci/oracle_fixtures.sh new file mode 100644 index 0000000000..82f692d98c --- /dev/null +++ b/.ci/oracle_fixtures.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +echo "Configure Oracle test database" + +"CREATE DATABASE test DATAFILE 'zenddb_test' SIZE 10M" diff --git a/phpunit.xml.dist b/phpunit.xml.dist index e58cf9e02c..5816ec07a0 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -43,11 +43,12 @@ - - + + + diff --git a/test/integration/Adapter/Driver/Oci8/ConnectionTest.php b/test/integration/Adapter/Driver/Oci8/ConnectionTest.php new file mode 100644 index 0000000000..70b0f0ab9e --- /dev/null +++ b/test/integration/Adapter/Driver/Oci8/ConnectionTest.php @@ -0,0 +1,25 @@ +variables); + $connection->connect(); + + self::assertTrue($connection->isConnected()); + $connection->disconnect(); + } +} diff --git a/test/integration/Adapter/Driver/Oci8/TableGatewayTest.php b/test/integration/Adapter/Driver/Oci8/TableGatewayTest.php new file mode 100644 index 0000000000..07c5951a1d --- /dev/null +++ b/test/integration/Adapter/Driver/Oci8/TableGatewayTest.php @@ -0,0 +1,150 @@ + 'OCI8', + 'connection_string' => $this->variables['connectionstring'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'character_set' => $this->variables['charset'], + 'options' => ['buffer_results' => true] + ]); + $tableGateway = new TableGateway('TEST', $adapter); + $rowset = $tableGateway->select('ID = 0'); + + $this->assertNull($rowset->current()); + } + + /** + * @see https://github.com/zendframework/zend-db/issues/330 + */ + public function testSelectWithEmptyCurrentWithoutBufferResult() + { + $adapter = new Adapter([ + 'driver' => 'OCI8', + 'connection_string' => $this->variables['connectionstring'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'character_set' => $this->variables['charset'], + 'options' => ['buffer_results' => false] + ]); + $tableGateway = new TableGateway('TEST', $adapter); + $rowset = $tableGateway->select('ID = 0'); + + $this->assertNull($rowset->current()); + } + + /** + * @see https://github.com/zendframework/zend-db/pull/396 + */ + public function testBlobWithOci8() + { + $adapter = new Adapter([ + 'driver' => 'OCI8', + 'connection_string' => $this->variables['connectionstring'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'character_set' => $this->variables['charset'], + 'options' => ['buffer_results' => false] + ]); + $tableGateway = new TableGateway('TEST', $adapter); + + $blob = 'very long sentence that is in fact not very long that tests blob'; + + $data = new ParameterContainer(); + $data->setFromArray(['CONTENT_BLOB' => $blob]); + $data->offsetSetErrata('CONTENT_BLOB', ParameterContainer::TYPE_BLOB); + + $sql = "UPDATE TEST SET CONTENT_BLOB= :CONTENT_BLOB WHERE ID = 1"; + $stm = $tableGateway->getAdapter()->getDriver()->createStatement($sql); + $stm->setParameterContainer($data); + $stm->execute(); + + $rowset = $tableGateway->select('ID = 1')->current(); + + $this->assertInstanceOf('OCI-Lob', $rowset['CONTENT_BLOB']); + $value = $rowset['CONTENT_BLOB']->read($rowset['CONTENT_BLOB']->size()); + $this->assertEquals($blob, $value); + } + + /** + * @see https://github.com/zendframework/zend-db/pull/396 + */ + public function testClobWithOci8() + { + $adapter = new Adapter([ + 'driver' => 'OCI8', + 'connection_string' => $this->variables['connectionstring'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'character_set' => $this->variables['charset'], + 'options' => ['buffer_results' => false] + ]); + $tableGateway = new TableGateway('TEST', $adapter); + + $clob = 'very long sentence that is in fact not very long that tests clob'; + + $data = new ParameterContainer(); + $data->setFromArray(['CONTENT_CLOB' => $clob]); + $data->offsetSetErrata('CONTENT_CLOB', ParameterContainer::TYPE_CLOB); + + $sql = "UPDATE TEST SET CONTENT_CLOB= :CONTENT_CLOB WHERE ID = 1"; + $stm = $tableGateway->getAdapter()->getDriver()->createStatement($sql); + $stm->setParameterContainer($data); + $stm->execute(); + + $rowset = $tableGateway->select('ID = 1')->current(); + + $this->assertInstanceOf('OCI-Lob', $rowset['CONTENT_CLOB']); + $value = $rowset['CONTENT_CLOB']->read($rowset['CONTENT_CLOB']->size()); + $this->assertEquals($clob, $value); + } + + /** + * @see https://github.com/zendframework/zend-db/pull/396 + */ + public function testLobWithOci8() + { + $adapter = new Adapter([ + 'driver' => 'OCI8', + 'connection_string' => $this->variables['connectionstring'], + 'username' => $this->variables['username'], + 'password' => $this->variables['password'], + 'character_set' => $this->variables['charset'], + 'options' => ['buffer_results' => false] + ]); + $tableGateway = new TableGateway('TEST', $adapter); + + $clob = 'very long sentence that is in fact not very long that tests lob'; + + $data = new ParameterContainer(); + $data->setFromArray(['CONTENT_CLOB' => $clob]); + $data->offsetSetErrata('CONTENT_CLOB', ParameterContainer::TYPE_LOB); + + $sql = "UPDATE TEST SET CONTENT_CLOB= :CONTENT_CLOB WHERE ID = 2"; + $stm = $tableGateway->getAdapter()->getDriver()->createStatement($sql); + $stm->setParameterContainer($data); + $stm->execute(); + + $rowset = $tableGateway->select('ID = 2')->current(); + + $this->assertInstanceOf('OCI-Lob', $rowset['CONTENT_CLOB']); + $value = $rowset['CONTENT_CLOB']->read($rowset['CONTENT_CLOB']->size()); + $this->assertEquals($clob, $value); + } +} diff --git a/test/integration/Adapter/Driver/Oci8/TraitSetup.php b/test/integration/Adapter/Driver/Oci8/TraitSetup.php new file mode 100644 index 0000000000..d0881893f5 --- /dev/null +++ b/test/integration/Adapter/Driver/Oci8/TraitSetup.php @@ -0,0 +1,44 @@ + 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING', + 'username' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME', + 'password' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD', + 'charset' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET', + 'database' => 'TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE', + ]; + + /** + * Sets up the fixture, for example, opens a network connection. + * This method is called before a test is executed. + */ + protected function setUp() + { + if (!getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8')) { + $this->markTestSkipped('Oci8 integration test disabled'); + } + + if (!extension_loaded('oci8')) { + $this->fail('The phpunit group integration-oci8 was enabled, but the extension is not loaded.'); + } + + foreach ($this->variables as $name => $value) { + if (!getenv($value)) { + $this->markTestSkipped(sprintf( + 'Missing required variable %s from phpunit.xml for this integration test', + $value + )); + } + $this->variables[$name] = getenv($value); + } + } +} diff --git a/test/integration/Adapter/Platform/Oci8Test.php b/test/integration/Adapter/Platform/Oci8Test.php new file mode 100644 index 0000000000..91045e86e4 --- /dev/null +++ b/test/integration/Adapter/Platform/Oci8Test.php @@ -0,0 +1,78 @@ +markTestSkipped(__CLASS__ . ' integration tests are not enabled!'); + } + if (extension_loaded('oci8')) { + $this->adapters['oci8'] = oci_connect( + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET'), + null); + } + if (extension_loaded('pdo_oci')) { + $this->adapters['pdo_oci'] = new \PDO( + 'oci:dbname=' . getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD') + ); + } + } + + public function testQuoteValueWithOci8() + { + if (!isset($this->adapters['oci8']) + || !$this->adapters['oci8'] instanceof \Oracle) { + $this->markTestSkipped('Oracle (oci8) not configured in unit test configuration file'); + } + $oracle = new Oracle($this->adapters['oci8']); + $value = $oracle->quoteValue('value'); + self::assertEquals('\'value\'', $value); + + $oracle = new Oracle(new Oci8\Oci8(new Oci8\Connection($this->adapters['oci8']))); + $value = $oracle->quoteValue('value'); + self::assertEquals('\'value\'', $value); + } + + public function testQuoteValueWithPdoOci() + { + if (!isset($this->adapters['pdo_oci']) + || !$this->adapters['pdo_oci'] instanceof \PDO) { + $this->markTestSkipped('Oracle (pdo_oci) not configured in unit test configuration file'); + } + $oracle = new Pdo($this->adapters['pdo_oci']); + $value = $oracle->quoteValue('value'); + self::assertEquals('\'value\'', $value); + + $oracle = new Pdo(new Pdo\Pdo(new Pdo\Connection($this->adapters['pdo_oci']))); + $value = $oracle->quoteValue('value'); + self::assertEquals('\'value\'', $value); + } + + +} diff --git a/test/integration/IntegrationTestListener.php b/test/integration/IntegrationTestListener.php index 9bb4dcaa31..9908f8120b 100644 --- a/test/integration/IntegrationTestListener.php +++ b/test/integration/IntegrationTestListener.php @@ -9,9 +9,7 @@ namespace ZendIntegrationTest\Db; -use Exception; use PDO; -use PDOException; use PHPUnit\Framework\BaseTestListener; use PHPUnit_Framework_TestSuite as TestSuite; use ZendIntegrationTest\Db\Platform\FixtureLoader; @@ -40,6 +38,9 @@ public function startTestSuite(TestSuite $suite) if (getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_PGSQL')) { $this->fixtureLoader = new \ZendIntegrationTest\Db\Platform\PgsqlFixtureLoader(); } + if (getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8')) { + $this->fixtureLoader = new \ZendIntegrationTest\Db\Platform\Oci8FixtureLoader(); + } if (! isset($this->fixtureLoader)) { return; diff --git a/test/integration/Platform/Oci8FixtureLoader.php b/test/integration/Platform/Oci8FixtureLoader.php new file mode 100644 index 0000000000..64fece77a3 --- /dev/null +++ b/test/integration/Platform/Oci8FixtureLoader.php @@ -0,0 +1,100 @@ +oci8 = oci_pconnect( + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET'), + null); + + + $this->dropDatabase(); + /*if (false === $this->oci8->exec(sprintf( + "CREATE DATABASE %s", + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE') + ))) { + throw new \Exception(sprintf( + "I cannot create the Oci8 %s test database: %s", + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE'), + print_r(oci_error($this->oci8), true) + )); + }*/ + + + /*unset($this->oci8); + $this->oci8 = oci_connect( + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET'), + null);*/ + + $sql = file_get_contents($this->fixtureFile); + $sql2 = <<oci8, $sql2); + $ret = oci_execute($resource); + if (false === $ret) { + throw new \Exception(sprintf( + "I cannot create the table for database %s. Check the %s file. %s ", + getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE'), + $this->fixtureFile, + print_r(oci_error($this->oci8), true) + )); + } + } + + public function dropDatabase() + { + if (!$this->initialRun) { + // Not possible to drop database in Oracle. + + return; + } + $this->initialRun = false; + + $resource = oci_parse($this->oci8, 'DROP TABLE TEST CASCADE CONSTRAINTS'); + oci_execute($resource); + + $resource = oci_parse($this->oci8, 'DROP TABLE TEST_CHARSET CASCADE CONSTRAINTS'); + oci_execute($resource); + + $resource = oci_parse($this->oci8, 'DROP SEQUENCE test_sequence'); + oci_execute($resource); + + $resource = oci_parse($this->oci8, 'DROP SEQUENCE testcharset_sequence'); + oci_execute($resource); + + $resource = oci_parse($this->oci8, 'DROP TRIGGER TEST_ON_INSERT'); + oci_execute($resource); + + $resource = oci_parse($this->oci8, 'DROP TRIGGER TESTCHARSET_ON_INSERT'); + oci_execute($resource); + } +} diff --git a/test/integration/TestFixtures/oci8.sql b/test/integration/TestFixtures/oci8.sql new file mode 100644 index 0000000000..15a5dc871e --- /dev/null +++ b/test/integration/TestFixtures/oci8.sql @@ -0,0 +1,55 @@ +CREATE TABLE TEST +( + ID NUMBER(3, 0) NOT NULL ENABLE, + NAME VARCHAR2(255 CHAR) NOT NULL ENABLE, + VALUE VARCHAR2(255 CHAR) NOT NULL ENABLE, + CONTENT_BLOB BLOB, + CONTENT_CLOB CLOB, + CONSTRAINT TEST_PK PRIMARY KEY (ID) +); + +CREATE SEQUENCE test_sequence; + +CREATE OR REPLACE TRIGGER TEST_ON_INSERT + BEFORE INSERT + ON test + FOR EACH ROW + BEGIN + SELECT test_sequence.nextval + INTO :new.id + FROM dual; + END; +/ + +ALTER TRIGGER TEST_ON_INSERT ENABLE; + +INSERT INTO TEST (NAME, VALUE) VALUES ('foo', 'bar'); +INSERT INTO TEST (NAME, VALUE) VALUES ('bar', 'baz'); + +CREATE TABLE TEST_CHARSET +( + ID NUMBER(3, 0) NOT NULL ENABLE, + FIELD$ VARCHAR2(255 CHAR) NOT NULL ENABLE, + FIELD_ VARCHAR2(255 CHAR) NOT NULL ENABLE, + CONSTRAINT TESTCHARSET_PK PRIMARY KEY (ID) +); + +CREATE SEQUENCE testcharset_sequence; + +CREATE OR REPLACE TRIGGER TESTCHARSET_ON_INSERT + BEFORE INSERT + ON TEST_CHARSET + FOR EACH ROW + BEGIN + SELECT testcharset_sequence.nextval + INTO :new.id + FROM dual; + END; +/ + +ALTER TRIGGER TESTCHARSET_ON_INSERT ENABLE; + +INSERT INTO TEST_CHARSET (FIELD$, FIELD_) VALUES ('foo', 'bar'); +INSERT INTO TEST_CHARSET (FIELD$, FIELD_) VALUES ('bar', 'baz'); + +COMMIT; \ No newline at end of file From 043c136bdba8b66041b4fbf192319c56180ef21f Mon Sep 17 00:00:00 2001 From: melliol Date: Thu, 24 Oct 2019 11:34:38 +0200 Subject: [PATCH 3/7] test integration oci8 with travis (test with 7.0) --- .travis.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.travis.yml b/.travis.yml index e7b538f18c..746e444e24 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,7 @@ matrix: - LEGACY_DEPS="phpunit/phpunit zendframework/zend-hydrator" - TEST_INTEGRATION=true - TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL=true + - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true - php: 5.6 env: - DEPS=latest @@ -36,6 +37,14 @@ matrix: - LEGACY_DEPS="phpunit/phpunit zendframework/zend-hydrator" - TEST_INTEGRATION=true - TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL=true + - php: 7.0 + services: + - oci8 + env: + - DEPS=locked + - LEGACY_DEPS="phpunit/phpunit zendframework/zend-hydrator" + - TEST_INTEGRATION=true + - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true - php: 7.0 env: - DEPS=latest @@ -52,6 +61,7 @@ matrix: - TEST_COVERAGE=true - TEST_INTEGRATION=true - TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL=true + - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true - php: 7.1 env: - DEPS=latest @@ -65,6 +75,7 @@ matrix: - DEPS=locked - TEST_INTEGRATION=true - TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL=true + - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true - php: 7.2 services: - postgresql @@ -74,6 +85,7 @@ matrix: - DEPS=locked - TEST_INTEGRATION=true - TESTS_ZEND_DB_ADAPTER_DRIVER_PGSQL=true + - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true - php: 7.2 env: - DEPS=latest From ae1d2cc6352a795326a1bc674d5603ce06846497 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 31 Dec 2019 12:17:25 -0600 Subject: [PATCH 4/7] CS fixes, update doc-blocks --- .../Adapter/Driver/Oci8/ConnectionTest.php | 6 +++++- .../Adapter/Driver/Oci8/TableGatewayTest.php | 11 +++++++--- .../Adapter/Driver/Oci8/TraitSetup.php | 2 +- .../integration/Adapter/Platform/Oci8Test.php | 21 +++++++++---------- 4 files changed, 24 insertions(+), 16 deletions(-) diff --git a/test/integration/Adapter/Driver/Oci8/ConnectionTest.php b/test/integration/Adapter/Driver/Oci8/ConnectionTest.php index 70b0f0ab9e..0ac403f2c6 100644 --- a/test/integration/Adapter/Driver/Oci8/ConnectionTest.php +++ b/test/integration/Adapter/Driver/Oci8/ConnectionTest.php @@ -1,4 +1,9 @@ setFromArray(['CONTENT_BLOB' => $blob]); $data->offsetSetErrata('CONTENT_BLOB', ParameterContainer::TYPE_BLOB); - $sql = "UPDATE TEST SET CONTENT_BLOB= :CONTENT_BLOB WHERE ID = 1"; + $sql = 'UPDATE TEST SET CONTENT_BLOB = :CONTENT_BLOB WHERE ID = 1'; $stm = $tableGateway->getAdapter()->getDriver()->createStatement($sql); $stm->setParameterContainer($data); $stm->execute(); @@ -103,7 +108,7 @@ public function testClobWithOci8() $data->setFromArray(['CONTENT_CLOB' => $clob]); $data->offsetSetErrata('CONTENT_CLOB', ParameterContainer::TYPE_CLOB); - $sql = "UPDATE TEST SET CONTENT_CLOB= :CONTENT_CLOB WHERE ID = 1"; + $sql = 'UPDATE TEST SET CONTENT_CLOB = :CONTENT_CLOB WHERE ID = 1'; $stm = $tableGateway->getAdapter()->getDriver()->createStatement($sql); $stm->setParameterContainer($data); $stm->execute(); @@ -136,7 +141,7 @@ public function testLobWithOci8() $data->setFromArray(['CONTENT_CLOB' => $clob]); $data->offsetSetErrata('CONTENT_CLOB', ParameterContainer::TYPE_LOB); - $sql = "UPDATE TEST SET CONTENT_CLOB= :CONTENT_CLOB WHERE ID = 2"; + $sql = 'UPDATE TEST SET CONTENT_CLOB = :CONTENT_CLOB WHERE ID = 2'; $stm = $tableGateway->getAdapter()->getDriver()->createStatement($sql); $stm->setParameterContainer($data); $stm->execute(); diff --git a/test/integration/Adapter/Driver/Oci8/TraitSetup.php b/test/integration/Adapter/Driver/Oci8/TraitSetup.php index d0881893f5..f9aabed9b9 100644 --- a/test/integration/Adapter/Driver/Oci8/TraitSetup.php +++ b/test/integration/Adapter/Driver/Oci8/TraitSetup.php @@ -1,7 +1,7 @@ markTestSkipped(__CLASS__ . ' integration tests are not enabled!'); @@ -33,7 +31,8 @@ public function setUp() getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD'), getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET'), - null); + null + ); } if (extension_loaded('pdo_oci')) { $this->adapters['pdo_oci'] = new \PDO( @@ -47,7 +46,8 @@ public function setUp() public function testQuoteValueWithOci8() { if (!isset($this->adapters['oci8']) - || !$this->adapters['oci8'] instanceof \Oracle) { + || !$this->adapters['oci8'] instanceof \Oracle + ) { $this->markTestSkipped('Oracle (oci8) not configured in unit test configuration file'); } $oracle = new Oracle($this->adapters['oci8']); @@ -62,7 +62,8 @@ public function testQuoteValueWithOci8() public function testQuoteValueWithPdoOci() { if (!isset($this->adapters['pdo_oci']) - || !$this->adapters['pdo_oci'] instanceof \PDO) { + || !$this->adapters['pdo_oci'] instanceof \PDO + ) { $this->markTestSkipped('Oracle (pdo_oci) not configured in unit test configuration file'); } $oracle = new Pdo($this->adapters['pdo_oci']); @@ -73,6 +74,4 @@ public function testQuoteValueWithPdoOci() $value = $oracle->quoteValue('value'); self::assertEquals('\'value\'', $value); } - - } From fdc98c8f75f04e922d9d20edabd25fb256119663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 31 Dec 2019 12:26:20 -0600 Subject: [PATCH 5/7] Updates fixture loader for Oci8 --- .../Platform/Oci8FixtureLoader.php | 51 ++++++------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/test/integration/Platform/Oci8FixtureLoader.php b/test/integration/Platform/Oci8FixtureLoader.php index 64fece77a3..43aa666db7 100644 --- a/test/integration/Platform/Oci8FixtureLoader.php +++ b/test/integration/Platform/Oci8FixtureLoader.php @@ -1,58 +1,37 @@ oci8 = oci_pconnect( getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME'), getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD'), getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET'), - null); - + null + ); $this->dropDatabase(); - /*if (false === $this->oci8->exec(sprintf( - "CREATE DATABASE %s", - getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE') - ))) { - throw new \Exception(sprintf( - "I cannot create the Oci8 %s test database: %s", - getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE'), - print_r(oci_error($this->oci8), true) - )); - }*/ - - - /*unset($this->oci8); - $this->oci8 = oci_connect( - getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_USERNAME'), - getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_PASSWORD'), - getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CONNECTIONSTRING'), - getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_CHARSET'), - null);*/ - + $sql = file_get_contents($this->fixtureFile); $sql2 = <<oci8, $sql2); $ret = oci_execute($resource); if (false === $ret) { - throw new \Exception(sprintf( - "I cannot create the table for database %s. Check the %s file. %s ", + throw new RuntimeException(sprintf( + 'I cannot create the table for database %s. Check the %s file. %s', getenv('TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8_DATABASE'), $this->fixtureFile, print_r(oci_error($this->oci8), true) From 0d3b407eeaee6f8850a1f882073d519bf333d781 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 31 Dec 2019 12:27:38 -0600 Subject: [PATCH 6/7] Adds empty line at the end of the file --- test/integration/TestFixtures/oci8.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/TestFixtures/oci8.sql b/test/integration/TestFixtures/oci8.sql index 15a5dc871e..fb10007efa 100644 --- a/test/integration/TestFixtures/oci8.sql +++ b/test/integration/TestFixtures/oci8.sql @@ -52,4 +52,4 @@ ALTER TRIGGER TESTCHARSET_ON_INSERT ENABLE; INSERT INTO TEST_CHARSET (FIELD$, FIELD_) VALUES ('foo', 'bar'); INSERT INTO TEST_CHARSET (FIELD$, FIELD_) VALUES ('bar', 'baz'); -COMMIT; \ No newline at end of file +COMMIT; From 30d0a0ce74d342c020c52ffb124bf3a76d809cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Bundyra?= Date: Tue, 31 Dec 2019 12:45:51 -0600 Subject: [PATCH 7/7] Fix indentations in Travis CI configuration --- .travis.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index 746e444e24..dc3e958b94 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,13 +38,13 @@ matrix: - TEST_INTEGRATION=true - TESTS_ZEND_DB_ADAPTER_DRIVER_MYSQL=true - php: 7.0 - services: - - oci8 - env: - - DEPS=locked - - LEGACY_DEPS="phpunit/phpunit zendframework/zend-hydrator" - - TEST_INTEGRATION=true - - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true + services: + - oci8 + env: + - DEPS=locked + - LEGACY_DEPS="phpunit/phpunit zendframework/zend-hydrator" + - TEST_INTEGRATION=true + - TESTS_ZEND_DB_ADAPTER_DRIVER_OCI8=true - php: 7.0 env: - DEPS=latest