diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 4b512efbf..77bc36aa1 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -13,20 +13,9 @@ jobs:
matrix:
experimental:
- false
- php:
- - "5.3"
- - "5.4"
- - "5.5"
- - "5.6"
- - "7.0"
- - "7.1"
- - "7.2"
- - "7.3"
- - "7.4"
# https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions#example-including-additional-values-into-combinations
include:
- php: "8.0"
- experimental: true
runs-on: ubuntu-20.04
env:
@@ -86,6 +75,6 @@ jobs:
- name: "Run PHPUnit tests (Experimental: ${{ matrix.experimental }})"
env:
FAILURE_ACTION: "${{ matrix.experimental == true }}"
- run: vendor/bin/phpunit --verbose || $FAILURE_ACTION
+ run: vendor/bin/phpunit --verbose tests/Zend/Db || $FAILURE_ACTION
# vim:ft=yaml:et:ts=2:sw=2
diff --git a/packages/zend-db/library/Zend/Db/Adapter/Db2.php b/packages/zend-db/library/Zend/Db/Adapter/Db2.php
index 6c42bb678..cc896f138 100644
--- a/packages/zend-db/library/Zend/Db/Adapter/Db2.php
+++ b/packages/zend-db/library/Zend/Db/Adapter/Db2.php
@@ -79,7 +79,7 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract
*
* @var int execution flag (DB2_AUTOCOMMIT_ON or DB2_AUTOCOMMIT_OFF)
*/
- protected $_execute_mode = DB2_AUTOCOMMIT_ON;
+ protected $_execute_mode;
/**
* Default class name for a DB statement.
@@ -111,6 +111,17 @@ class Zend_Db_Adapter_Db2 extends Zend_Db_Adapter_Abstract
'NUMERIC' => Zend_Db::FLOAT_TYPE
);
+ public function __construct($config)
+ {
+ // Only assign the value if constant is present
+ // The required extension check is performed in _connect()
+ if (defined('DB2_AUTOCOMMIT_ON')) {
+ $this->_execute_mode = DB2_AUTOCOMMIT_ON;
+ }
+
+ parent::__construct($config);
+ }
+
/**
* Creates a connection resource.
*
diff --git a/packages/zend-db/library/Zend/Db/Statement/Pdo.php b/packages/zend-db/library/Zend/Db/Statement/Pdo.php
index a6a84a80f..fd33beee7 100644
--- a/packages/zend-db/library/Zend/Db/Statement/Pdo.php
+++ b/packages/zend-db/library/Zend/Db/Statement/Pdo.php
@@ -252,6 +252,9 @@ public function fetch($style = null, $cursor = null, $offset = null)
}
try {
return $this->_stmt->fetch($style, $cursor, $offset);
+ } catch (ValueError $e) {
+ // require_once 'Zend/Db/Statement/Exception.php';
+ throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode());
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
@@ -290,6 +293,9 @@ public function fetchAll($style = null, $col = null)
} else {
return $this->_stmt->fetchAll($style);
}
+ } catch (ValueError $e) {
+ // require_once 'Zend/Db/Statement/Exception.php';
+ throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode());
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
@@ -431,6 +437,10 @@ public function setFetchMode($mode)
$this->_fetchMode = $mode;
try {
return $this->_stmt->setFetchMode($mode);
+ } catch (ValueError $e) {
+ // require_once 'Zend/Db/Statement/Exception.php';
+ throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode());
+
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
diff --git a/packages/zend-db/library/Zend/Db/Statement/Pdo/Ibm.php b/packages/zend-db/library/Zend/Db/Statement/Pdo/Ibm.php
index c428b11d9..359d1e7a5 100644
--- a/packages/zend-db/library/Zend/Db/Statement/Pdo/Ibm.php
+++ b/packages/zend-db/library/Zend/Db/Statement/Pdo/Ibm.php
@@ -85,6 +85,9 @@ public function _bindParam($parameter, &$variable, $type = null, $length = null,
} else {
return $this->_stmt->bindParam($parameter, $variable, $type, $length, $options);
}
+ } catch (ValueError $e) {
+ // require_once 'Zend/Db/Statement/Exception.php';
+ throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode());
} catch (PDOException $e) {
// require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage(), $e->getCode(), $e);
diff --git a/packages/zend-log/library/Zend/Log/Writer/Stream.php b/packages/zend-log/library/Zend/Log/Writer/Stream.php
index 895970567..794aa0170 100644
--- a/packages/zend-log/library/Zend/Log/Writer/Stream.php
+++ b/packages/zend-log/library/Zend/Log/Writer/Stream.php
@@ -75,7 +75,17 @@ public function __construct($streamOrUrl, $mode = null)
$streamOrUrl = $streamOrUrl['stream'];
}
- if (! $this->_stream = @fopen($streamOrUrl, $mode, false)) {
+ try {
+ $this->_stream = @fopen($streamOrUrl, $mode, false);
+ } catch (ValueError $e) {
+ // require_once 'Zend/Log/Exception.php';
+ throw new Zend_Log_Exception($e->getMessage(), $e->getCode());
+ } catch (TypeError $e) {
+ // require_once 'Zend/Log/Exception.php';
+ throw new Zend_Log_Exception($e->getMessage(), $e->getCode());
+ }
+
+ if (!$this->_stream) {
// require_once 'Zend/Log/Exception.php';
$msg = "\"$streamOrUrl\" cannot be opened with mode \"$mode\"";
throw new Zend_Log_Exception($msg);
@@ -130,7 +140,14 @@ protected function _write($event)
{
$line = $this->_formatter->format($event);
- if (false === @fwrite($this->_stream, $line)) {
+ try {
+ $result = @fwrite($this->_stream, $line);
+ } catch (TypeError $e) {
+ // require_once 'Zend/Log/Exception.php';
+ throw new Zend_Log_Exception($e->getMessage(), $e->getCode());
+ }
+
+ if ($result === false) {
// require_once 'Zend/Log/Exception.php';
throw new Zend_Log_Exception("Unable to write to stream");
}
diff --git a/tests/Zend/AllTests.php b/tests/Zend/AllTests.php
index 4dce5b5bd..3618634cb 100644
--- a/tests/Zend/AllTests.php
+++ b/tests/Zend/AllTests.php
@@ -63,7 +63,6 @@
require_once 'Zend/Loader/AllTests.php';
require_once 'Zend/LocaleTest.php';
require_once 'Zend/Locale/AllTests.php';
-require_once 'Zend/Log/AllTests.php';
require_once 'Zend/Mail/AllTests.php';
require_once 'Zend/Markup/AllTests.php';
require_once 'Zend/Measure/AllTests.php';
diff --git a/tests/Zend/Db/Adapter/Db2Test.php b/tests/Zend/Db/Adapter/Db2Test.php
deleted file mode 100644
index 645662d54..000000000
--- a/tests/Zend/Db/Adapter/Db2Test.php
+++ /dev/null
@@ -1,373 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE
- );
-
- public function testAdapterDescribeTablePrimaryAuto()
- {
- $desc = $this->_db->describeTable('zfbugs');
-
- $this->assertTrue($desc['bug_id']['PRIMARY']);
- $this->assertEquals(1, $desc['bug_id']['PRIMARY_POSITION']);
- $this->assertTrue($desc['bug_id']['IDENTITY']);
- }
-
- public function testAdapterDescribeTableAttributeColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_name']['TABLE_NAME'], 'Expected table name to be zfproducts');
- $this->assertEquals('product_name', $desc['product_name']['COLUMN_NAME'], 'Expected column name to be product_name');
- $this->assertEquals(2, $desc['product_name']['COLUMN_POSITION'], 'Expected column position to be 2');
- $this->assertRegExp('/varchar/i', $desc['product_name']['DATA_TYPE'], 'Expected data type to be VARCHAR');
- $this->assertEquals('', $desc['product_name']['DEFAULT'], 'Expected default to be empty string');
- $this->assertTrue( $desc['product_name']['NULLABLE'], 'Expected product_name to be nullable');
- if (!$this->_db->isI5()) {
- $this->assertEquals(0, $desc['product_name']['SCALE'], 'Expected scale to be 0');
- } else {
- $this->assertNull( $desc['product_name']['SCALE'], 'Expected scale to be 0');
- }
- $this->assertEquals(0, $desc['product_name']['PRECISION'], 'Expected precision to be 0');
- $this->assertFalse( $desc['product_name']['PRIMARY'], 'Expected product_name not to be a primary key');
- $this->assertNull( $desc['product_name']['PRIMARY_POSITION'], 'Expected product_name to return null for PRIMARY_POSITION');
- $this->assertFalse( $desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY');
- }
-
- public function testAdapterDescribeTablePrimaryKeyColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME'], 'Expected table name to be zfproducts');
- $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME'], 'Expected column name to be product_id');
- $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION'], 'Expected column position to be 1');
- $this->assertEquals('', $desc['product_id']['DEFAULT'], 'Expected default to be empty string');
- $this->assertFalse( $desc['product_id']['NULLABLE'], 'Expected product_id not to be nullable');
- $this->assertEquals(0, $desc['product_id']['SCALE'], 'Expected scale to be 0');
- $this->assertEquals(0, $desc['product_id']['PRECISION'], 'Expected precision to be 0');
- $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key');
- $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']);
- }
-
- /**
- * Used by _testAdapterOptionCaseFoldingNatural()
- * DB2 and Oracle return identifiers in uppercase naturally,
- * so those test suites will override this method.
- */
- protected function _testAdapterOptionCaseFoldingNaturalIdentifier()
- {
- return 'CASE_FOLDED_IDENTIFIER';
- }
-
- public function testAdapterTransactionCommit()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- // use our default connection as the Connection1
- $dbConnection1 = $this->_db;
-
- // create a second connection to the same database
- $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams());
- $dbConnection2->getConnection();
- if ($dbConnection2->isI5()) {
- $dbConnection2->query('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE');
- } else {
- $dbConnection2->query('SET ISOLATION LEVEL = UR');
- }
-
- // notice the number of rows in connection 2
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)');
-
- // start an explicit transaction in connection 1
- $dbConnection1->beginTransaction();
-
- // delete a row in connection 1
- $rowsAffected = $dbConnection1->delete(
- 'zfbugs',
- "$bug_id = 1"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should see one less row in connection 2
- // because it is doing an uncommitted read
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table (step 2) because conn2 is doing an uncommitted read');
-
- // commit the DELETE
- $dbConnection1->commit();
-
- // now we should see one fewer rows in connection 2
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 3)');
-
- // delete another row in connection 1
- $rowsAffected = $dbConnection1->delete(
- 'zfbugs',
- "$bug_id = 2"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should see results immediately, because
- // the db connection returns to auto-commit mode
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(2, $count);
- }
-
- public function testAdapterTransactionRollback()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- // use our default connection as the Connection1
- $dbConnection1 = $this->_db;
-
- // create a second connection to the same database
- $dbConnection2 = Zend_Db::factory($this->getDriver(), $this->_util->getParams());
- $dbConnection2->getConnection();
- if ($dbConnection2->isI5()) {
- $dbConnection2->query('SET TRANSACTION ISOLATION LEVEL SERIALIZABLE');
- } else {
- $dbConnection2->query('SET ISOLATION LEVEL = UR');
- }
-
- // notice the number of rows in connection 2
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)');
-
- // start an explicit transaction in connection 1
- $dbConnection1->beginTransaction();
-
- // delete a row in connection 1
- $rowsAffected = $dbConnection1->delete(
- 'zfbugs',
- "$bug_id = 1"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should see one less row in connection 2
- // because it is doing an uncommitted read
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table (step 2) because conn2 is doing an uncommitted read');
-
- // rollback the DELETE
- $dbConnection1->rollback();
-
- // now we should see the same number of rows
- // because the DELETE was rolled back
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table after DELETE is rolled back (step 3)');
-
- // delete another row in connection 1
- $rowsAffected = $dbConnection1->delete(
- 'zfbugs',
- "$bug_id = 2"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should see results immediately, because
- // the db connection returns to auto-commit mode
- $count = $dbConnection2->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 4)');
- }
-
- public function testAdapterAlternateStatement()
- {
- $this->_testAdapterAlternateStatement('Test_Db2Statement');
- }
-
- /**
- * OVERRIDDEN COMMON TEST CASE
- *
- * This test case will produce a value with two internally set values,
- * autocommit = 1
- * DB2_ATTR_CASE = 0
- */
- public function testAdapterZendConfigEmptyDriverOptions()
- {
- Zend_Loader::loadClass('Zend_Config');
- $params = $this->_util->getParams();
- $params['driver_options'] = '';
- $params = new Zend_Config($params);
-
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
-
- $config = $db->getConfig();
-
- $expectedValue = array(
- 'autocommit' => 1,
- 'DB2_ATTR_CASE' => 0
- );
- $this->assertEquals($expectedValue, $config['driver_options']);
- }
-
- /**
- * OVERRIDDEN COMMON TEST CASE
- *
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * OVERRRIDEEN COMMON TEST CASE
- *
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $string = 'St John"s Wort';
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * OVERRIDDEN FROM COMMON TEST CASE
- *
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * OVERRIDDEN FROM COMMON TEST CASE
- *
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $string = 'id=?';
- $param = 'St John"s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * OVERRIDDEN FROM COMMON TEST CASE
- *
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $string = 'id = ?';
- $param = 'St John\'s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- /**
- * This is "related" to the issue. It appears the fix for
- * describeTable is relatively untestable due to the fact that
- * its primary focus is to reduce the query time, not the result
- * set.
- *
- * @group ZF-5169
- */
- public function testAdapterSchemaOptionInListTables()
- {
- $params = $this->_util->getParams();
- unset($params['schema']);
- $connection = Zend_Db::factory($this->getDriver(), $params);
- $tableCountNoSchema = count($connection->listTables());
-
- $dbConfig = $this->_db->getConfig();
- if ($this->_db->isI5()) {
- if (isset($dbConfig['driver_options']['i5_lib'])) {
- $schema = $dbConfig['driver_options']['i5_lib'];
- }
- } elseif (!$this->_db->isI5()) {
- $schema = $this->_util->getSchema();
- } else {
- $this->markTestSkipped('No valid schema to test against.');
- return;
- }
-
- $params = $this->_util->getParams();
- $params['schema'] = $schema;
- $connection = Zend_Db::factory($this->getDriver(), $params);
- $tableCountSchema = count($connection->listTables());
-
- $this->assertGreaterThan(0, $tableCountNoSchema, 'Adapter without schema should produce large result');
- $this->assertGreaterThan(0, $tableCountSchema, 'Adapter with schema should produce large result');
-
- $this->assertTrue(($tableCountNoSchema > $tableCountSchema), 'Table count with schema provided should be less than without.');
- }
-
- /**
- * @group ZF-8399
- */
- public function testLongQueryWithTextField()
- {
- $this->markTestSkipped($this->getDriver() . ' does not have TEXT field type');
- }
-
- public function getDriver()
- {
- return 'Db2';
- }
-
-}
diff --git a/tests/Zend/Db/Adapter/MysqliTest.php b/tests/Zend/Db/Adapter/MysqliTest.php
deleted file mode 100644
index f238d71e8..000000000
--- a/tests/Zend/Db/Adapter/MysqliTest.php
+++ /dev/null
@@ -1,297 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'MEDIUMINT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'SERIAL' => Zend_Db::BIGINT_TYPE,
- 'DEC' => Zend_Db::FLOAT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'FIXED' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Test AUTO_QUOTE_IDENTIFIERS option
- * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true
- *
- * MySQL actually allows delimited identifiers to remain
- * case-insensitive, so this test overrides its parent.
- */
- public function testAdapterAutoQuoteIdentifiersTrue()
- {
- $params = $this->_util->getParams();
-
- $params['options'] = array(
- Zend_Db::AUTO_QUOTE_IDENTIFIERS => true
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
-
- $select = $this->_db->select();
- $select->from('zfproducts');
- $stmt = $this->_db->query($select);
- $result1 = $stmt->fetchAll();
- $this->assertEquals(3, count($result1), 'Expected 3 rows in first query result');
-
- $this->assertEquals(1, $result1[0]['product_id']);
-
- $select = $this->_db->select();
- $select->from('zfproducts');
- try {
- $stmt = $this->_db->query($select);
- $result2 = $stmt->fetchAll();
- $this->assertEquals(3, count($result2), 'Expected 3 rows in second query result');
- $this->assertEquals($result1, $result2);
- } catch (Zend_Exception $e) {
- $this->fail('exception caught where none was expected.');
- }
- }
-
- public function testAdapterInsertSequence()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support sequences');
- }
-
- /**
- * test that quoteColumnAs() accepts a string
- * and an alias, and returns each as delimited
- * identifiers, with 'AS' in between.
- */
- public function testAdapterQuoteColumnAs()
- {
- $string = "foo";
- $alias = "bar";
- $value = $this->_db->quoteColumnAs($string, $alias);
- $this->assertEquals('`foo` AS `bar`', $value);
- }
-
- /**
- * test that quoteColumnAs() accepts a string
- * and an alias, but ignores the alias if it is
- * the same as the base identifier in the string.
- */
- public function testAdapterQuoteColumnAsSameString()
- {
- $string = 'foo.bar';
- $alias = 'bar';
- $value = $this->_db->quoteColumnAs($string, $alias);
- $this->assertEquals('`foo`.`bar`', $value);
- }
-
- /**
- * test that quoteIdentifier() accepts a string
- * and returns a delimited identifier.
- */
- public function testAdapterQuoteIdentifier()
- {
- $value = $this->_db->quoteIdentifier('table_name');
- $this->assertEquals('`table_name`', $value);
- }
-
- /**
- * test that quoteIdentifier() accepts an array
- * and returns a qualified delimited identifier.
- */
- public function testAdapterQuoteIdentifierArray()
- {
- $array = array('foo', 'bar');
- $value = $this->_db->quoteIdentifier($array);
- $this->assertEquals('`foo`.`bar`', $value);
- }
-
- /**
- * test that quoteIdentifier() accepts an array
- * containing a Zend_Db_Expr, and returns strings
- * as delimited identifiers, and Exprs as unquoted.
- */
- public function testAdapterQuoteIdentifierArrayDbExpr()
- {
- $expr = new Zend_Db_Expr('*');
- $array = array('foo', $expr);
- $value = $this->_db->quoteIdentifier($array);
- $this->assertEquals('`foo`.*', $value);
- }
-
- /**
- * test that quoteIdentifer() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIdentifierDoubleQuote()
- {
- $string = 'table_"_name';
- $value = $this->_db->quoteIdentifier($string);
- $this->assertEquals('`table_"_name`', $value);
- }
-
- /**
- * test that quoteIdentifer() accepts an integer
- * and returns a delimited identifier as with a string.
- */
- public function testAdapterQuoteIdentifierInteger()
- {
- $int = 123;
- $value = $this->_db->quoteIdentifier($int);
- $this->assertEquals('`123`', $value);
- }
-
- /**
- * test that quoteIdentifier() accepts a string
- * containing a dot (".") character, splits the
- * string, quotes each segment individually as
- * delimited identifers, and returns the imploded
- * string.
- */
- public function testAdapterQuoteIdentifierQualified()
- {
- $string = 'table.column';
- $value = $this->_db->quoteIdentifier($string);
- $this->assertEquals('`table`.`column`', $value);
- }
-
- /**
- * test that quoteIdentifer() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIdentifierSingleQuote()
- {
- $string = "table_'_name";
- $value = $this->_db->quoteIdentifier($string);
- $this->assertEquals('`table_\'_name`', $value);
- }
-
- /**
- * test that quoteTableAs() accepts a string and an alias,
- * and returns each as delimited identifiers.
- * Most RDBMS want an 'AS' in between.
- */
- public function testAdapterQuoteTableAs()
- {
- $string = "foo";
- $alias = "bar";
- $value = $this->_db->quoteTableAs($string, $alias);
- $this->assertEquals('`foo` AS `bar`', $value);
- }
-
- /**
- * test that describeTable() returns correct types
- * @group ZF-3624
- *
- */
- public function testAdapterDescribeTableAttributeColumnFloat()
- {
- $desc = $this->_db->describeTable('zfprice');
- $this->assertEquals('zfprice', $desc['price']['TABLE_NAME']);
- $this->assertRegExp('/float/i', $desc['price']['DATA_TYPE']);
- }
-
- /**
- * Ensures that the PDO Buffered Query does not throw the error
- * 2014 General error
- *
- * @group ZF-2101
- * @link http://framework.zend.com/issues/browse/ZF-2101
- * @return void
- */
- public function testAdapterToEnsurePdoBufferedQueryThrowsNoError()
- {
- $params = $this->_util->getParams();
- $db = Zend_Db::factory($this->getDriver(), $params);
-
- // Set default bound value
- $customerId = 1;
-
- // Stored procedure returns a single row
- $stmt = $db->prepare('CALL zf_test_procedure(?)');
- $stmt->bindParam(1, $customerId);
- $stmt->execute();
- $result = $stmt->fetchAll();
- $this->assertEquals(1, $result[0]['product_id']);
-
- // Reset statement
- $stmt->closeCursor();
-
- // Stored procedure returns a single row
- $stmt = $db->prepare('CALL zf_test_procedure(?)');
- $stmt->bindParam(1, $customerId);
- $stmt->execute();
- $this->assertEquals(1, $result[0]['product_id']);
- }
-
- public function testAdapterAlternateStatement()
- {
- $this->_testAdapterAlternateStatement('Test_MysqliStatement');
- }
-
- public function testMySqliInitCommand()
- {
- $params = $this->_util->getParams();
- $params['driver_options'] = array(
- 'mysqli_init_command' => 'SET AUTOCOMMIT=0;'
- );
-
- $db = Zend_Db::factory($this->getDriver(), $params);
-
- $sql = 'SELECT @@AUTOCOMMIT as autocommit';
-
- $row = $db->fetchRow($sql);
-
- $this->assertEquals(0, $row['autocommit']);
- }
-
- public function getDriver()
- {
- return 'Mysqli';
- }
-
-}
diff --git a/tests/Zend/Db/Adapter/OracleTest.php b/tests/Zend/Db/Adapter/OracleTest.php
deleted file mode 100644
index f638e6b5b..000000000
--- a/tests/Zend/Db/Adapter/OracleTest.php
+++ /dev/null
@@ -1,548 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE,
- 'NUMBER' => Zend_Db::FLOAT_TYPE,
- );
-
- public function testAdapterDescribeTablePrimaryAuto()
- {
- $this->markTestSkipped('Oracle does not support auto-increment');
- }
-
- public function testAdapterDescribeTablePrimaryKeyColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']);
- $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']);
- $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']);
- $this->assertEquals('', $desc['product_id']['DEFAULT']);
- $this->assertFalse( $desc['product_id']['NULLABLE']);
- $this->assertEquals(0, $desc['product_id']['SCALE']);
- // Oracle reports precsion 11 for integers
- $this->assertEquals(11, $desc['product_id']['PRECISION']);
- $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key');
- $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']);
- $this->assertFalse( $desc['product_id']['IDENTITY']);
- }
-
- /**
- * Test the Adapter's fetchAll() method.
- */
- public function testAdapterFetchAll()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1));
- $this->assertEquals(2, count($result));
- $this->assertThat($result[0], $this->arrayHasKey('product_id'));
- $this->assertEquals('2', $result[0]['product_id']);
- }
-
- /**
- * ZF-4330: Oracle binds variables by name
- * Test that fetchAssoc() still fetched an associative array
- * after the adapter's default fetch mode is set to something else.
- */
- public function testAdapterFetchAllOverrideFetchMode()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $col_name = $this->_db->foldCase('product_id');
-
- $this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
-
- // Test associative array
- $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1), Zend_Db::FETCH_ASSOC);
- $this->assertEquals(2, count($result));
- $this->assertTrue(is_array($result[0]));
- $this->assertEquals(2, count($result[0])); // count columns
- $this->assertEquals(2, $result[0][$col_name]);
-
- // Test numeric and associative array
- // OCI8 driver does not support fetchAll(FETCH_BOTH), use fetch() in a loop instead
-
- // Ensure original fetch mode has been retained
- $result = $this->_db->fetchAll("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1));
- $this->assertEquals(2, count($result));
- $this->assertTrue(is_object($result[0]));
- $this->assertEquals(2, $result[0]->$col_name);
- }
-
- /**
- * Test the Adapter's fetchAssoc() method.
- */
- public function testAdapterFetchAssoc()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $result = $this->_db->fetchAssoc("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id DESC", array(":id"=>1));
- foreach ($result as $idKey => $row) {
- $this->assertThat($row, $this->arrayHasKey('product_id'));
- $this->assertEquals($idKey, $row['product_id']);
- }
- }
-
- /**
- * ZF-4275: Oracle binds variables by name
- * Test that fetchAssoc() still fetched an associative array
- * after the adapter's default fetch mode is set to something else.
- */
- public function testAdapterFetchAssocAfterSetFetchMode()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
- $result = $this->_db->fetchAssoc("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id DESC", array(":id"=>1));
- $this->assertTrue(is_array($result));
- $this->assertEquals(array('product_id', 'product_name'), array_keys(current($result)));
- }
-
- /**
- * Test the Adapter's fetchCol() method.
- */
- public function testAdapterFetchCol()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $result = $this->_db->fetchCol("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1));
- $this->assertEquals(2, count($result)); // count rows
- $this->assertEquals(2, $result[0]);
- $this->assertEquals(3, $result[1]);
- }
-
- /**
- * ZF-4275: Oracle binds variables by name
- * Test that fetchCol() still fetched an associative array
- * after the adapter's default fetch mode is set to something else.
- */
- public function testAdapterFetchColAfterSetFetchMode()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
- $result = $this->_db->fetchCol("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1));
- $this->assertTrue(is_array($result));
- $this->assertEquals(2, count($result)); // count rows
- $this->assertEquals(2, $result[0]);
- $this->assertEquals(3, $result[1]);
- }
-
- /**
- * Test the Adapter's fetchOne() method.
- */
- public function testAdapterFetchOne()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $prod = 'Linux';
- $result = $this->_db->fetchOne("SELECT $product_name FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1));
- $this->assertEquals($prod, $result);
- }
-
-
- /**
- * ZF-4275: Oracle binds variables by name
- * Test that fetchCol() still fetched an associative array
- * after the adapter's default fetch mode is set to something else.
- */
- public function testAdapterFetchOneAfterSetFetchMode()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
- $prod = 'Linux';
- $result = $this->_db->fetchOne("SELECT $product_name FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1));
- $this->assertTrue(is_string($result));
- $this->assertEquals($prod, $result);
- }
-
- /**
- * Test the Adapter's fetchPairs() method.
- */
- public function testAdapterFetchPairs()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $prod = 'Linux';
- $result = $this->_db->fetchPairs("SELECT $product_id, $product_name FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1));
- $this->assertEquals(2, count($result)); // count rows
- $this->assertEquals($prod, $result[2]);
- }
-
- /**
- * ZF-4275: Oracle binds variables by name
- * Test the Adapter's fetchPairs() method.
- */
- public function testAdapterFetchPairsAfterSetFetchMode()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
- $prod = 'Linux';
- $result = $this->_db->fetchPairs("SELECT $product_id, $product_name FROM $products WHERE $product_id > :id ORDER BY $product_id ASC", array(":id"=>1));
- $this->assertTrue(is_array($result));
- $this->assertEquals(2, count($result)); // count rows
- $this->assertEquals($prod, $result[2]);
- }
-
- /**
- * Test the Adapter's fetchRow() method.
- */
- public function testAdapterFetchRow()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1));
- $this->assertEquals(2, count($result)); // count columns
- $this->assertEquals(2, $result['product_id']);
- }
-
- /**
- * ZF-4330: Oracle binds variables by name
- * Test that fetchAssoc() still fetched an associative array
- * after the adapter's default fetch mode is set to something else.
- */
- public function testAdapterFetchRowOverrideFetchMode()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $col_name = $this->_db->foldCase('product_id');
-
- $this->_db->setFetchMode(Zend_Db::FETCH_OBJ);
-
- // Test associative array
- $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1), Zend_Db::FETCH_ASSOC);
- $this->assertTrue(is_array($result));
- $this->assertEquals(2, count($result)); // count columns
- $this->assertEquals(2, $result['product_id']);
-
- // Test numeric and associative array
- // OCI8 driver does not support fetchAll(FETCH_BOTH), use fetch() in a loop instead
-
- // Ensure original fetch mode has been retained
- $result = $this->_db->fetchRow("SELECT * FROM $products WHERE $product_id > :id ORDER BY $product_id", array(":id"=>1));
- $this->assertTrue(is_object($result));
- $this->assertEquals(2, $result->$col_name);
- }
-
- /**
- * @group ZF-10829
- */
- public function testAdapterGetPersistentConnection()
- {
- $params = $this->_util->getParams();
- $params['persistent'] = 1;
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
- $this->assertTrue($db->isConnected());
- }
-
- public function testAdapterInsert()
- {
- $row = array (
- 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'),
- 'product_name' => 'Solaris',
- );
- $rowsAffected = $this->_db->insert('zfproducts', $row);
- $this->assertEquals(1, $rowsAffected);
- $lastInsertId = $this->_db->lastInsertId('zfproducts', null); // implies 'zfproducts_seq'
- $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq');
- $this->assertEquals('4', (string) $lastInsertId, 'Expected new id to be 4');
- $this->assertEquals('4', (string) $lastSequenceId, 'Expected new id to be 4');
- }
-
- public function testAdapterInsertDbExpr()
- {
- $row = array (
- 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'),
- 'product_name' => new Zend_Db_Expr('UPPER(\'Solaris\')')
- );
- $rowsAffected = $this->_db->insert('zfproducts', $row);
- $this->assertEquals(1, $rowsAffected);
- $product_id = $this->_db->quoteIdentifier('product_id', true);
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where("$product_id = 4");
- $result = $this->_db->fetchAll($select);
- $this->assertTrue(is_array($result));
- $this->assertEquals('SOLARIS', $result[0]['product_name']);
- }
-
- /**
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $value = $this->_db->quote('St John"s Wort');
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $value = $this->_db->quoteInto('id=?', 'St John"s Wort');
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $value = $this->_db->quoteInto('id = ?', 'St John\'s Wort');
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteTableAs() accepts a string and an alias,
- * and returns each as delimited identifiers.
- * Oracle does not want the 'AS' in between.
- */
- public function testAdapterQuoteTableAs()
- {
- $string = "foo";
- $alias = "bar";
- $value = $this->_db->quoteTableAs($string, $alias);
- $this->assertEquals('"foo" "bar"', $value);
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterLobAsString()
- {
- $this->assertFalse($this->_db->getLobAsString());
- $this->_db->setLobAsString(true);
- $this->assertTrue($this->_db->getLobAsString());
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterLobAsStringFromDriverOptions()
- {
- $params = $this->_util->getParams();
- $params['driver_options'] = array(
- 'lob_as_string' => true
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
- $this->assertTrue($db->getLobAsString());
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchRow()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $value = $this->_db->fetchRow("SELECT * FROM $documents WHERE $document_id = 1");
- $class = 'OCI-Lob';
- $this->assertTrue($value['doc_clob'] instanceof $class);
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $lob = $value['doc_clob'];
- $this->assertEquals($expected, $lob->read($lob->size()));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchRowLobAsString()
- {
- $this->_db->setLobAsString(true);
- parent::testAdapterReadClobFetchRow();
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchAssoc()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $value = $this->_db->fetchAssoc("SELECT * FROM $documents WHERE $document_id = 1");
- $class = 'OCI-Lob';
- $this->assertTrue($value[1]['doc_clob'] instanceof $class);
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $lob = $value[1]['doc_clob'];
- $this->assertEquals($expected, $lob->read($lob->size()));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchAssocLobAsString()
- {
- $this->_db->setLobAsString(true);
- parent::testAdapterReadClobFetchAssoc();
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchOne()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $document_clob = $this->_db->quoteIdentifier('doc_clob');
- $value = $this->_db->fetchOne("SELECT $document_clob FROM $documents WHERE $document_id = 1");
- $class = 'OCI-Lob';
- $this->assertTrue($value instanceof $class);
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $lob = $value;
- $this->assertEquals($expected, $lob->read($lob->size()));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchOneLobAsString()
- {
- $this->_db->setLobAsString(true);
- parent::testAdapterReadClobFetchOne();
- }
-
- /**
- * Used by _testAdapterOptionCaseFoldingNatural()
- * DB2 and Oracle return identifiers in uppercase naturally,
- * so those test suites will override this method.
- */
- protected function _testAdapterOptionCaseFoldingNaturalIdentifier()
- {
- return 'CASE_FOLDED_IDENTIFIER';
- }
-
- public function testAdapterOptionCaseFoldingUpper()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not support case-folding array keys yet.');
- }
-
- public function testAdapterOptionCaseFoldingLower()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not support case-folding array keys yet.');
- }
-
- public function testAdapterTransactionCommit()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with transactions');
- }
-
- public function testAdapterTransactionRollback()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with transactions');
- }
-
- public function testAdapterAlternateStatement()
- {
- $this->_testAdapterAlternateStatement('Test_OracleStatement');
- }
-
- /**
- * @group ZF-8399
- */
- public function testLongQueryWithTextField()
- {
- $this->markTestSkipped($this->getDriver() . ' does not have TEXT field type');
- }
-
- public function getDriver()
- {
- return 'Oracle';
- }
-}
diff --git a/tests/Zend/Db/Adapter/Pdo/IbmTest.php b/tests/Zend/Db/Adapter/Pdo/IbmTest.php
deleted file mode 100644
index 72e5913ba..000000000
--- a/tests/Zend/Db/Adapter/Pdo/IbmTest.php
+++ /dev/null
@@ -1,107 +0,0 @@
-_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestIncomplete('IDS needs special consideration for transactions');
- } else {
- parent::testAdapterTransactionCommit();
- }
- }
-
- public function testAdapterTransactionRollback()
- {
- $server = $this->_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestIncomplete('IDS needs special consideration for transactions');
- } else {
- parent::testAdapterTransactionCommit();
- }
- }
-
- public function testAdapterLimitInvalidArgumentException()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $sql = $this->_db->limit("SELECT * FROM $products", 0);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
-
- $this->assertEquals(0, count($result), 'Expecting to see 0 rows returned');
-
- try {
- $sql = $this->_db->limit("SELECT * FROM $products", 1, -1);
- $this->fail('Expected to catch Zend_Db_Adapter_Exception');
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Adapter_Exception,
- 'Expecting object of type Zend_Db_Adapter_Exception, got '.get_class($e));
- }
- }
-
- /**
- * Used by _testAdapterOptionCaseFoldingNatural()
- * DB2 returns identifiers in uppercase naturally,
- * while IDS does not
- */
- protected function _testAdapterOptionCaseFoldingNaturalIdentifier()
- {
- $server = $this->_util->getServer();
-
- if ($server == 'DB2') {
- return 'CASE_FOLDED_IDENTIFIER';
- }
- return 'case_folded_identifier';
- }
-}
diff --git a/tests/Zend/Db/Adapter/Pdo/MssqlTest.php b/tests/Zend/Db/Adapter/Pdo/MssqlTest.php
deleted file mode 100644
index 3516aa01f..000000000
--- a/tests/Zend/Db/Adapter/Pdo/MssqlTest.php
+++ /dev/null
@@ -1,380 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE,
- 'MONEY' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'SMALLMONEY' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Test AUTO_QUOTE_IDENTIFIERS option
- * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true
- */
- public function testAdapterAutoQuoteIdentifiersTrue()
- {
- $params = $this->_util->getParams();
-
- $params['options'] = array(
- Zend_Db::AUTO_QUOTE_IDENTIFIERS => true
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
-
- $select = $this->_db->select();
- $select->from('zfproducts');
- $stmt = $this->_db->query($select);
- $result = $stmt->fetchAll();
- $this->assertEquals(3, count($result), 'Expected 3 rows in first query result');
-
- $this->assertEquals(1, $result[0]['product_id']);
- }
-
- public function testAdapterDescribeTableAttributeColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_name']['TABLE_NAME']);
- $this->assertEquals('product_name', $desc['product_name']['COLUMN_NAME']);
- $this->assertEquals(2, $desc['product_name']['COLUMN_POSITION']);
- $this->assertRegExp('/varchar/i', $desc['product_name']['DATA_TYPE']);
- $this->assertEquals('', $desc['product_name']['DEFAULT']);
- $this->assertFalse( $desc['product_name']['NULLABLE'], 'Expected product_name not to be nullable');
- $this->assertNull( $desc['product_name']['SCALE'], 'scale is not 0');
- // MS SQL Server reports varchar length in the PRECISION field. Whaaa?!?
- $this->assertEquals(100, $desc['product_name']['PRECISION'], 'precision is not 100');
- $this->assertFalse( $desc['product_name']['PRIMARY'], 'Expected product_name not to be a primary key');
- $this->assertNull( $desc['product_name']['PRIMARY_POSITION'], 'Expected product_name to return null for PRIMARY_POSITION');
- $this->assertFalse( $desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY');
- }
-
- public function testAdapterDescribeTablePrimaryKeyColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']);
- $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']);
- $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']);
- $this->assertEquals('', $desc['product_id']['DEFAULT']);
- $this->assertFalse( $desc['product_id']['NULLABLE'], 'Expected product_id not to be nullable');
- $this->assertEquals(0, $desc['product_id']['SCALE'], 'scale is not 0');
- $this->assertEquals(10, $desc['product_id']['PRECISION'], 'precision is not 10');
- $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key');
- $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']);
- }
-
- /**
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $string = 'St John"s Wort';
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $string = 'id=?';
- $param = 'St John"s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $string = 'id = ?';
- $param = 'St John\'s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- public function testAdapterInsertSequence()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support sequences.');
- }
-
- public function testAdapterInsertDbExpr()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- $expr = new Zend_Db_Expr('2+3');
-
- $row = array (
- 'bug_id' => $expr,
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
-
- $this->_db->query("SET IDENTITY_INSERT $bugs ON");
-
- $rowsAffected = $this->_db->insert('zfbugs', $row);
- $this->assertEquals(1, $rowsAffected);
-
- $this->_db->query("SET IDENTITY_INSERT $bugs OFF");
-
- $value = $this->_db->fetchOne("SELECT $bug_id FROM $bugs WHERE $bug_id = 5");
- $this->assertEquals(5, $value);
- }
-
- public function testAdapterTransactionCommit()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- $dbConnection1 = $this->_db;
-
- // notice the number of rows at beginning
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)');
-
- // start an explicit transaction
- $this->_db->beginTransaction();
-
- // delete a row in connection 1
- $rowsAffected = $this->_db->delete(
- 'zfbugs',
- "$bug_id = 1"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // commit the DELETE
- $this->_db->commit();
-
- // now we should see one fewer rows
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 3)');
- }
-
- public function testAdapterTransactionRollback()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- // notice the number of rows at beginning
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)');
-
- // start an explicit transaction in connection 1
- $this->_db->beginTransaction();
-
- // delete a row in connection 1
- $rowsAffected = $this->_db->delete(
- 'zfbugs',
- "$bug_id = 1"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should still see 3 rows
- // because the DELETE has not been committed yet
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table (step 2)');
-
- // rollback the DELETE
- $this->_db->rollback();
-
- // now we should see the original number of rows
- // because the DELETE was rolled back
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table after DELETE is rolled back (step 3)');
- }
-
- /**
- * Test the Adapter's insert() method.
- * This requires providing an associative array of column=>value pairs.
- */
- public function testAdapterInsert()
- {
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
- $rowsAffected = $this->_db->insert('zfbugs', $row);
- $this->assertEquals(1, $rowsAffected);
- $lastInsertId = $this->_db->lastInsertId();
- $this->assertTrue(is_int($lastInsertId));
- $this->assertEquals('5', (string) $lastInsertId,
- 'Expected new id to be 5');
- }
-
- /**
- * @group ZF-4099
- */
- public function testAdapterLimitWorksWithOrderByClause()
- {
- // more values
- $this->_db->insert('zfproducts', array('product_name' => 'Unix'));
- $this->_db->insert('zfproducts', array('product_name' => 'Windows'));
- $this->_db->insert('zfproducts', array('product_name' => 'AIX'));
- $this->_db->insert('zfproducts', array('product_name' => 'I5'));
- $this->_db->insert('zfproducts', array('product_name' => 'Linux'));
-
- $select = $this->_db->select();
- $select->from('zfproducts')
- ->order(array('product_name ASC', 'product_id DESC'))
- ->limit(4, 4);
- $products = $this->_db->fetchAll($select);
- $expectedProducts = array(
- 0 => array('product_id' => '3', 'product_name' => 'OS X'),
- 1 => array('product_id' => '4', 'product_name' => 'Unix'),
- 2 => array('product_id' => '5', 'product_name' => 'Windows'),
- 3 => array ('product_id' => '1', 'product_name' => 'Windows')
- );
- $this->assertEquals($expectedProducts, $products);
- }
-
- /**
- * @group ZF-4251
- */
- public function testAdapterLimitWorksWithDistinctClause()
- {
- $this->_db->insert('zfproducts', array('product_name' => 'Unix'));
- $this->_db->insert('zfproducts', array('product_name' => 'Windows'));
- $this->_db->insert('zfproducts', array('product_name' => 'AIX'));
- $this->_db->insert('zfproducts', array('product_name' => 'I5'));
- $this->_db->insert('zfproducts', array('product_name' => 'Linux'));
-
- $sql = 'SELECT DISTINCT product_name FROM zfproducts ORDER BY product_name DESC';
- $sql = $this->_db->limit($sql, 3, 3);
- $products = $this->_db->fetchAll($sql);
- $expectedProducts = array(
- 0 => array('product_name' => 'Linux'),
- 1 => array('product_name' => 'I5'),
- 2 => array('product_name' => 'AIX')
- );
- $this->assertEquals($expectedProducts, $products);
- }
-
- /**
- * @group ZF-5823
- */
- public function testAdapterLimitWithoutOffsetProducesConciseSql()
- {
- $sql = 'SELECT * FROM foo ORDER BY bar DESC';
- $this->assertEquals('SELECT TOP 3 * FROM foo ORDER BY bar DESC', $this->_db->limit($sql, 3));
-
- $sql = 'SELECT DISTINCT * FROM foo ORDER BY bar DESC';
- $this->assertEquals('SELECT DISTINCT TOP 3 * FROM foo ORDER BY bar DESC', $this->_db->limit($sql, 3));
- }
-
- /**
- * @group ZF-7629
- */
- public function testAdapterDescribeTableWithSchemaName()
- {
- $productsTableInfo = $this->_db->describeTable('zfproducts', 'dbo');
- $this->assertArrayHasKey('product_id', $productsTableInfo);
- $this->assertArrayHasKey('product_name', $productsTableInfo);
- }
-
- /**
- * test that quote() escapes null byte character
- * in a string.
- */
- public function testAdapterQuoteNullByteCharacter()
- {
- $string = "1\0";
- $value = $this->_db->quote($string);
- $this->assertEquals("'1\\000'", $value);
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Adapter/Pdo/OciTest.php b/tests/Zend/Db/Adapter/Pdo/OciTest.php
deleted file mode 100644
index 5c9df449a..000000000
--- a/tests/Zend/Db/Adapter/Pdo/OciTest.php
+++ /dev/null
@@ -1,266 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'BINARY_DOUBLE' => Zend_Db::FLOAT_TYPE,
- 'BINARY_FLOAT' => Zend_Db::FLOAT_TYPE,
- 'NUMBER' => Zend_Db::FLOAT_TYPE
- );
-
- public function testAdapterDescribeTablePrimaryAuto()
- {
- $this->markTestSkipped('Oracle does not support auto-increment');
- }
-
- public function testAdapterDescribeTablePrimaryKeyColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']);
- $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']);
- $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']);
- $this->assertEquals('', $desc['product_id']['DEFAULT']);
- $this->assertFalse( $desc['product_id']['NULLABLE']);
- $this->assertEquals(0, $desc['product_id']['SCALE']);
- // Oracle reports precsion 11 for integers
- $this->assertEquals(11, $desc['product_id']['PRECISION']);
- $this->assertTrue( $desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key');
- $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']);
- $this->assertFalse( $desc['product_id']['IDENTITY']);
- }
-
- public function testAdapterInsert()
- {
- $row = array (
- 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'),
- 'product_name' => 'Solaris',
- );
- $rowsAffected = $this->_db->insert('zfproducts', $row);
- $this->assertEquals(1, $rowsAffected);
- $lastInsertId = $this->_db->lastInsertId('zfproducts', null); // implies 'products_seq'
- $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq');
- $this->assertTrue(is_string($lastInsertId));
- $this->assertTrue(is_string($lastSequenceId));
- $this->assertEquals('4', (string) $lastInsertId, 'Expected new id to be 4');
- $this->assertEquals('4', (string) $lastSequenceId, 'Expected new id to be 4');
- }
-
- public function testAdapterInsertDbExpr()
- {
- $row = array (
- 'product_id' => new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq').'.NEXTVAL'),
- 'product_name' => new Zend_Db_Expr('UPPER(\'Solaris\')')
- );
- $rowsAffected = $this->_db->insert('zfproducts', $row);
- $this->assertEquals(1, $rowsAffected);
- $product_id = $this->_db->quoteIdentifier('product_id', true);
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where("$product_id = 4");
- $result = $this->_db->fetchAll($select);
- $this->assertTrue(is_array($result));
- $this->assertEquals('SOLARIS', $result[0]['product_name']);
- }
-
- /**
- * Used by _testAdapterOptionCaseFoldingNatural()
- * DB2 and Oracle return identifiers in uppercase naturally,
- * so those test suites will override this method.
- */
- protected function _testAdapterOptionCaseFoldingNaturalIdentifier()
- {
- return 'CASE_FOLDED_IDENTIFIER';
- }
-
- /**
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $string = 'St John"s Wort';
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $string = 'id=?';
- $param = 'St John"s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $string = 'id = ?';
- $param = 'St John\'s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteTableAs() accepts a string and an alias,
- * and returns each as delimited identifiers.
- * Oracle does not want the 'AS' in between.
- */
- public function testAdapterQuoteTableAs()
- {
- $string = "foo";
- $alias = "bar";
- $value = $this->_db->quoteTableAs($string, $alias);
- $this->assertEquals('"foo" "bar"', $value);
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchAll()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $value = $this->_db->fetchAll("SELECT * FROM $documents WHERE $document_id = 1");
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $this->assertEquals($expected, stream_get_contents($value[0]['doc_clob']));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchRow()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $value = $this->_db->fetchRow("SELECT * FROM $documents WHERE $document_id = 1");
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $this->assertEquals($expected, stream_get_contents($value['doc_clob']));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchAssoc()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $value = $this->_db->fetchAssoc("SELECT * FROM $documents WHERE $document_id = 1");
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $this->assertEquals($expected, stream_get_contents($value[1]['doc_clob']));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchCol()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $document_clob = $this->_db->quoteIdentifier('doc_clob');
- $value = $this->_db->fetchCol("SELECT $document_clob FROM $documents WHERE $document_id = 1");
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $this->assertEquals($expected, stream_get_contents($value[0]));
- }
-
- /**
- * @group ZF-5146
- */
- public function testAdapterReadClobFetchOne()
- {
- $documents = $this->_db->quoteIdentifier('zfdocuments');
- $document_id = $this->_db->quoteIdentifier('doc_id');
- $document_clob = $this->_db->quoteIdentifier('doc_clob');
- $value = $this->_db->fetchOne("SELECT $document_clob FROM $documents WHERE $document_id = 1");
- $expected = 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...';
- $this->assertEquals($expected, stream_get_contents($value));
- }
-
- /**
- * @group ZF-8399
- */
- public function testLongQueryWithTextField()
- {
- $this->markTestSkipped($this->getDriver() . ' does not have TEXT field type');
- }
-
- public function getDriver()
- {
- return 'Pdo_Oci';
- }
-}
diff --git a/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php b/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php
deleted file mode 100644
index 4200570d1..000000000
--- a/tests/Zend/Db/Adapter/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,240 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::INT_TYPE,
- 'SERIAL' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'BIGSERIAL' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'DOUBLE PRECISION' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE
- );
-
- public function testAdapterDescribeTablePrimaryAuto()
- {
- $desc = $this->_db->describeTable('zfbugs');
-
- $this->assertTrue($desc['bug_id']['PRIMARY']);
- $this->assertEquals(1, $desc['bug_id']['PRIMARY_POSITION']);
- $this->assertTrue($desc['bug_id']['IDENTITY']);
- }
-
- /**
- * Test the Adapter's insert() method.
- * This requires providing an associative array of column=>value pairs.
- */
- public function testAdapterInsert()
- {
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $rowsAffected = $this->_db->insert('zfbugs', $row);
- $this->assertEquals(1, $rowsAffected);
- $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq');
- $this->assertEquals((string) $lastInsertId, (string) $lastSequenceId,
- 'Expected last insert id to be equal to last sequence id');
- $this->assertEquals('5', (string) $lastInsertId,
- 'Expected new id to be 5');
- }
-
- public function testAdapterInsertSequence()
- {
- $row = array (
- 'product_id' => $this->_db->nextSequenceId('zfproducts_seq'),
- 'product_name' => 'Solaris',
- );
- $rowsAffected = $this->_db->insert('zfproducts', $row);
- $this->assertEquals(1, $rowsAffected);
- $lastInsertId = $this->_db->lastInsertId('zfproducts');
- $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq');
- $this->assertEquals((string) $lastInsertId, (string) $lastSequenceId,
- 'Expected last insert id to be equal to last sequence id');
- $this->assertEquals('4', (string) $lastInsertId,
- 'Expected new id to be 4');
- }
-
- public function testAdapterInsertDbExpr()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id', true);
- $bug_description = $this->_db->quoteIdentifier('bug_description', true);
-
- $expr = new Zend_Db_Expr('2+3');
-
- $row = array (
- 'bug_id' => $expr,
- 'bug_description' => 'New bug 5',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
- $rowsAffected = $this->_db->insert('zfbugs', $row);
- $this->assertEquals(1, $rowsAffected);
-
- $value = $this->_db->fetchOne("SELECT $bug_description FROM $bugs WHERE $bug_id = 5");
- $this->assertEquals('New bug 5', $value);
- }
-
- /**
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $value = $this->_db->quote('St John"s Wort');
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $value = $this->_db->quoteInto('id=?', 'St John"s Wort');
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $value = $this->_db->quoteInto('id = ?', 'St John\'s Wort');
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- function getDriver()
- {
- return 'Pdo_Pgsql';
- }
-
- /**
- * @group ZF-3972
- */
- public function testAdapterCharacterVarying()
- {
- $this->_util->createTable('zf_pgsql_charvary',
- array('pg_id' => 'character varying(4) NOT NULL',
- 'pg_info' => "character varying(1) NOT NULL DEFAULT 'A'::character varying"));
- $description = $this->_db->describeTable('zf_pgsql_charvary');
- $this->_util->dropTable('zf_pgsql_charvary');
- $this->assertEquals(null , $description['pg_id']['DEFAULT']);
- $this->assertEquals('A', $description['pg_info']['DEFAULT']);
- }
-
- /**
- * @group ZF-7640
- */
- public function testAdapterBpchar()
- {
- $this->_util->createTable('zf_pgsql_bpchar',
- array('pg_name' => "character(100) DEFAULT 'Default'::bpchar"));
- $description = $this->_db->describeTable('zf_pgsql_bpchar');
- $this->_util->dropTable('zf_pgsql_bpchar');
- $this->assertEquals('Default', $description['pg_name']['DEFAULT']);
- }
-
- /**
- * @group ZF-10160
- * @group ZF-10257
- */
- public function testQuoteIdentifiersInSequence()
- {
- $this->_util->createSequence('camelCase_id_seq');
- $this->_util->createSequence("single'quotes");
-
- $this->_db->nextSequenceId('camelCase_id_seq');
- $this->_db->nextSequenceId($this->_db->quoteIdentifier('camelCase_id_seq', true));
- $this->_db->lastSequenceId('camelCase_id_seq');
- $this->_db->lastSequenceId($this->_db->quoteIdentifier('camelCase_id_seq', true));
-
- // require_once 'Zend/Db/Expr.php';
- $this->_db->lastSequenceId(new Zend_Db_Expr('camelCase_id_seq'));
- $lastId = $this->_db->lastSequenceId(new Zend_Db_Expr('camelCase_id_seq'));
- $this->assertEquals(2, $lastId);
-
- $this->_db->nextSequenceId('"public"."camelCase_id_seq"');
- $lastId = $this->_db->lastSequenceId('"public"."camelCase_id_seq"');
- $this->assertEquals(3, $lastId);
-
- $this->_db->nextSequenceId("single'quotes");
- $lastId = $this->_db->lastSequenceId("single'quotes");
- $this->assertEquals(1, $lastId);
-
- $this->_util->dropSequence("single'quotes");
- $this->_util->dropSequence('camelCase_id_seq');
- }
-}
diff --git a/tests/Zend/Db/Adapter/Pdo/SqliteTest.php b/tests/Zend/Db/Adapter/Pdo/SqliteTest.php
deleted file mode 100644
index f709ae426..000000000
--- a/tests/Zend/Db/Adapter/Pdo/SqliteTest.php
+++ /dev/null
@@ -1,261 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INTEGER' => Zend_Db::BIGINT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Test AUTO_QUOTE_IDENTIFIERS option
- * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true
- *
- * SQLite actually allows delimited identifiers to remain
- * case-insensitive, so this test overrides its parent.
- */
- public function testAdapterAutoQuoteIdentifiersTrue()
- {
- $params = $this->_util->getParams();
-
- $params['options'] = array(
- Zend_Db::AUTO_QUOTE_IDENTIFIERS => true
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
-
- $select = $this->_db->select();
- $select->from('zfproducts');
- $stmt = $this->_db->query($select);
- $result1 = $stmt->fetchAll();
-
- $this->assertEquals(1, $result1[0]['product_id']);
-
- $select = $this->_db->select();
- $select->from('ZFPRODUCTS');
- try {
- $stmt = $this->_db->query($select);
- $result2 = $stmt->fetchAll();
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Statement_Exception,
- 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e));
- $this->fail('Unexpected exception '.get_class($e).' received: '.$e->getMessage());
- }
-
- $this->assertEquals($result1, $result2);
- }
-
-
- public function testAdapterConstructInvalidParamDbnameException()
- {
- $this->markTestSkipped($this->getDriver() . ' does not throw exception on missing dbname');
- }
-
- public function testAdapterConstructInvalidParamUsernameException()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support login credentials');
- }
-
- public function testAdapterConstructInvalidParamPasswordException()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support login credentials');
- }
-
- public function testAdapterInsertSequence()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support sequences');
- }
-
- /**
- * Used by:
- * - testAdapterOptionCaseFoldingNatural()
- * - testAdapterOptionCaseFoldingUpper()
- * - testAdapterOptionCaseFoldingLower()
- */
- protected function _testAdapterOptionCaseFoldingSetup(Zend_Db_Adapter_Abstract $db)
- {
- $db->getConnection();
- $this->_util->setUp($db);
- }
-
- /**
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $value = $this->_db->quote('St John"s Wort');
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $value = $this->_db->quoteInto('id=?', 'St John"s Wort');
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $value = $this->_db->quoteInto('id = ?', 'St John\'s Wort');
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- public function testAdapterTransactionAutoCommit()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support transactions or concurrency');
- }
-
- public function testAdapterTransactionCommit()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support transactions or concurrency');
- }
-
- public function testAdapterTransactionRollback()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support transactions or concurrency');
- }
-
- /**
- * @group ZF-2293
- */
- public function testAdapterSupportsLengthInTableMetadataForVarcharFields()
- {
- $metadata = $this->_db->describeTable('zfbugs');
- $this->assertEquals(100, $metadata['bug_description']['LENGTH']);
- $this->assertEquals(20, $metadata['bug_status']['LENGTH']);
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-
- public function testAdapterOptionFetchMode()
- {
- $params = $this->_util->getParams();
-
- $params['options'] = array(
- Zend_Db::FETCH_MODE => 'obj'
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
-
- //two extra lines to make SQLite work
- $db->query('CREATE TABLE zfproducts (id)');
- $db->insert('zfproducts', array('id' => 1));
-
- $select = $db->select()->from('zfproducts');
- $row = $db->fetchRow($select);
- $this->assertTrue($row instanceof stdClass);
- }
-
- protected function _testAdapterAlternateStatement($stmtClass)
- {
- $ip = get_include_path();
- $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '_files';
- $newIp = $dir . PATH_SEPARATOR . $ip;
- set_include_path($newIp);
-
- $params = $this->_util->getParams();
-
- $params['options'] = array(
- Zend_Db::AUTO_QUOTE_IDENTIFIERS => false
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
- $db->setStatementClass($stmtClass);
-
- $currentStmtClass = $db->getStatementClass();
- $this->assertEquals($stmtClass, $currentStmtClass);
-
- //extra fix for SQLite
- $db->query('CREATE TABLE zfbugs (id)');
-
- $bugs = $this->_db->quoteIdentifier('zfbugs');
-
- $stmt = $db->prepare("SELECT COUNT(*) FROM $bugs");
-
- $this->assertTrue($stmt instanceof $stmtClass,
- 'Expecting object of type ' . $stmtClass . ', got ' . get_class($stmt));
- }
-
- /**
- * test that quote() escapes null byte character
- * in a string.
- */
- public function testAdapterQuoteNullByteCharacter()
- {
- $string = "1\0";
- $value = $this->_db->quote($string);
- $this->assertEquals("'1\\000'", $value);
- }
-}
diff --git a/tests/Zend/Db/Adapter/SqlsrvTest.php b/tests/Zend/Db/Adapter/SqlsrvTest.php
deleted file mode 100644
index 5c617c226..000000000
--- a/tests/Zend/Db/Adapter/SqlsrvTest.php
+++ /dev/null
@@ -1,572 +0,0 @@
- Zend_Db::INT_TYPE,
- Zend_Db::BIGINT_TYPE => Zend_Db::BIGINT_TYPE,
- Zend_Db::FLOAT_TYPE => Zend_Db::FLOAT_TYPE,
- 'INT' => Zend_Db::INT_TYPE,
- 'SMALLINT' => Zend_Db::INT_TYPE,
- 'TINYINT' => Zend_Db::INT_TYPE,
- 'BIGINT' => Zend_Db::BIGINT_TYPE,
- 'DECIMAL' => Zend_Db::FLOAT_TYPE,
- 'FLOAT' => Zend_Db::FLOAT_TYPE,
- 'MONEY' => Zend_Db::FLOAT_TYPE,
- 'NUMERIC' => Zend_Db::FLOAT_TYPE,
- 'REAL' => Zend_Db::FLOAT_TYPE,
- 'SMALLMONEY' => Zend_Db::FLOAT_TYPE
- );
-
- /**
- * Test AUTO_QUOTE_IDENTIFIERS option
- * Case: Zend_Db::AUTO_QUOTE_IDENTIFIERS = true
- */
- public function testAdapterAutoQuoteIdentifiersTrue()
- {
- $params = $this->_util->getParams();
-
- $params['options'] = array(
- Zend_Db::AUTO_QUOTE_IDENTIFIERS => true
- );
- $db = Zend_Db::factory($this->getDriver(), $params);
- $db->getConnection();
-
- $select = $this->_db->select();
- $select->from('zfproducts');
- $stmt = $this->_db->query($select);
- $result = $stmt->fetchAll();
- $this->assertEquals(3, count($result), 'Expected 3 rows in first query result');
-
- $this->assertEquals(1, $result[0]['product_id']);
- }
-
- /**
- * Test the Adapter's insert() method.
- * This requires providing an associative array of column=>value pairs.
- */
- public function testAdapterInsert()
- {
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
-
- $rowsAffected = $this->_db->insert('zfbugs', $row);
- $this->assertEquals(1, $rowsAffected);
-
- $lastInsertId = $this->_db->lastInsertId();
- $this->assertTrue(is_string($lastInsertId));
- $this->assertEquals('5', (string) $lastInsertId,
- 'Expected new id to be 5');
-
- $lastInsertId = $this->_db->lastInsertId('zfbugs');
- $this->assertEquals('5', (string) $lastInsertId,
- 'Expected new id to be 5, selecting by table');
- }
-
- /**
- * Test the Adapter's insert() method.
- * This requires providing an associative array of column=>value pairs.
- * Multiple rows are insert in one query
- */
- public function testAdapterMultipleInsert()
- {
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
-
- $bugs = $this->_db->quoteIdentifier('zfbugs');
-
- $values = '(?, ?, ?, ?, ?, ?, ?)';
-
- $query = 'INSERT INTO ' . $bugs . ' VALUES ' . implode(',', array($values, $values, $values));
-
- $data = array();
-
- for ($i = 0; $i < 3; $i++) {
- foreach ($row as $value) {
- $data[] = $value;
- }
- }
-
- $stmt = $this->_db->query($query, $data);
- $rowsAffected = $stmt->rowCount();
- $this->assertEquals(3, $rowsAffected);
- }
-
- public function testAdapterDescribeTableAttributeColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_name']['TABLE_NAME']);
- $this->assertEquals('product_name', $desc['product_name']['COLUMN_NAME']);
- $this->assertEquals(2, $desc['product_name']['COLUMN_POSITION']);
- $this->assertRegExp('/varchar/i', $desc['product_name']['DATA_TYPE']);
- $this->assertEquals('', $desc['product_name']['DEFAULT']);
- $this->assertTrue($desc['product_name']['NULLABLE'], 'Expected product_name to be nullable');
- $this->assertNull($desc['product_name']['SCALE'], 'scale is not 0');
-
- // MS SQL Server reports varchar length in the PRECISION field. Whaaa?!?
- $this->assertEquals(100, $desc['product_name']['PRECISION'], 'precision is not 100');
- $this->assertFalse($desc['product_name']['PRIMARY'], 'Expected product_name not to be a primary key');
- $this->assertNull($desc['product_name']['PRIMARY_POSITION'], 'Expected product_name to return null for PRIMARY_POSITION');
- $this->assertFalse($desc['product_name']['IDENTITY'], 'Expected product_name to return false for IDENTITY');
- }
-
- /**
- * test that describeTable() returns empty array on not existing table
- * @group ZF-9079
- */
- public function testAdapterDescribeTableNotExistingTable()
- {
- $desc = $this->_db->describeTable('not_existing_table');
-
- $this->assertEquals(0, count($desc), 'Expected to have empty result');
- }
-
- public function testAdapterDescribeTablePrimaryKeyColumn()
- {
- $desc = $this->_db->describeTable('zfproducts');
-
- $this->assertEquals('zfproducts', $desc['product_id']['TABLE_NAME']);
- $this->assertEquals('product_id', $desc['product_id']['COLUMN_NAME']);
- $this->assertEquals(1, $desc['product_id']['COLUMN_POSITION']);
- $this->assertEquals('', $desc['product_id']['DEFAULT']);
- $this->assertFalse($desc['product_id']['NULLABLE'], 'Expected product_id not to be nullable');
- $this->assertEquals(0, $desc['product_id']['SCALE'], 'scale is not 0');
- $this->assertEquals(10, $desc['product_id']['PRECISION'], 'precision is not 10');
- $this->assertTrue($desc['product_id']['PRIMARY'], 'Expected product_id to be a primary key');
- $this->assertEquals(1, $desc['product_id']['PRIMARY_POSITION']);
- }
-
- /**
- * Test that quote() takes an array and returns
- * an imploded string of comma-separated, quoted elements.
- */
- public function testAdapterQuoteArray()
- {
- $array = array("it's", 'all', 'right!');
- $value = $this->_db->quote($array);
- $this->assertEquals("'it''s', 'all', 'right!'", $value);
- }
-
- /**
- * test that quote() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteDoubleQuote()
- {
- $string = 'St John"s Wort';
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John\"s Wort'", $value);
- }
-
- /**
- * test that quote() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteSingleQuote()
- {
- $string = "St John's Wort";
- $value = $this->_db->quote($string);
- $this->assertEquals("'St John''s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a double-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoDoubleQuote()
- {
- $string = 'id=?';
- $param = 'St John"s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id='St John\"s Wort'", $value);
- }
-
- /**
- * test that quoteInto() escapes a single-quote
- * character in a string.
- */
- public function testAdapterQuoteIntoSingleQuote()
- {
- $string = 'id = ?';
- $param = 'St John\'s Wort';
- $value = $this->_db->quoteInto($string, $param);
- $this->assertEquals("id = 'St John''s Wort'", $value);
- }
-
- public function testAdapterInsertSequence()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support sequences.');
- }
-
- public function testAdapterInsertDbExpr()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
- $expr = new Zend_Db_Expr('2+3');
-
- $row = array (
- 'bug_id' => $expr,
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
-
- $this->_db->query("SET IDENTITY_INSERT $bugs ON");
-
- $rowsAffected = $this->_db->insert('zfbugs', $row);
- $this->assertEquals(1, $rowsAffected);
-
- $this->_db->query("SET IDENTITY_INSERT $bugs OFF");
-
- $value = $this->_db->fetchOne("SELECT $bug_id FROM $bugs WHERE $bug_id = 5");
- $this->assertEquals(5, $value);
- }
-
- /**
- * @group ZF-1541
- */
- public function testCharacterSetUtf8()
- {
- // Create a new adapter
- $params = $this->_util->getParams();
-
- $params['charset'] = 'utf8';
-
- $db = Zend_Db::factory($this->getDriver(), $params);
-
- // create a new util object, with the new db adapter
- $driver = $this->getDriver();
- $utilClass = "Zend_Db_TestUtil_{$driver}";
- $util = new $utilClass();
- $util->setAdapter($db);
-
- // create test table using no identifier quoting
- $util->createTable('charsetutf8', array(
- 'id' => 'IDENTITY',
- 'stuff' => 'VARCHAR(32)'
- ));
- $tableName = $this->_util->getTableName('charsetutf8');
-
- $table = $db->quoteIdentifier('charsetutf8');
-
- $db->query("SET IDENTITY_INSERT $table ON");
-
- // insert into the table
- $numRows = $db->insert($tableName, array(
- 'id' => 1,
- 'stuff' => 'äöüß'
- ));
-
- // check if the row was inserted as expected
- $select = $db->select()->from($tableName, array('id', 'stuff'));
-
- $stmt = $db->query($select);
- $fetched = $stmt->fetchAll(Zend_Db::FETCH_NUM);
- $a = array(
- 0 => array(0 => 1, 1 => 'äöüß')
- );
- $this->assertEquals($a, $fetched,
- 'result of query not as expected');
-
- $db->query("SET IDENTITY_INSERT $table OFF");
-
- // clean up
- unset($stmt);
- $util->dropTable($tableName);
- }
-
- public function testAdapterTransactionCommit()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- // notice the number of rows in connection 2
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)');
-
- // start an explicit transaction in connection 1
- $this->_db->beginTransaction();
-
- // delete a row in connection 1
- $rowsAffected = $this->_db->delete(
- 'zfbugs',
- "$bug_id = 1"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should still see all rows in connection 2
- // because the DELETE has not been committed yet
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to still see 4 rows in bugs table (step 2); perhaps Adapter is still in autocommit mode?');
-
- // commit the DELETE
- $this->_db->commit();
-
- // now we should see one fewer rows in connection 2
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 3)');
-
- // delete another row in connection 1
- $rowsAffected = $this->_db->delete(
- 'zfbugs',
- "$bug_id = 2"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should see results immediately, because
- // the db connection returns to auto-commit mode
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(2, $count);
- }
-
- public function testAdapterTransactionRollback()
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs');
- $bug_id = $this->_db->quoteIdentifier('bug_id');
-
- // notice the number of rows in connection 2
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to see 4 rows in bugs table (step 1)');
-
- // start an explicit transaction in connection 1
- $this->_db->beginTransaction();
-
- // delete a row in connection 1
- $rowsAffected = $this->_db->delete(
- 'zfbugs',
- "$bug_id = 1"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should still see all rows in connection 2
- // because the DELETE has not been committed yet
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to still see 4 rows in bugs table (step 2); perhaps Adapter is still in autocommit mode?');
-
- // rollback the DELETE
- $this->_db->rollback();
-
- // now we should see the same number of rows
- // because the DELETE was rolled back
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(4, $count, 'Expecting to still see 4 rows in bugs table after DELETE is rolled back (step 3)');
-
- // delete another row in connection 1
- $rowsAffected = $this->_db->delete(
- 'zfbugs',
- "$bug_id = 2"
- );
- $this->assertEquals(1, $rowsAffected);
-
- // we should see results immediately, because
- // the db connection returns to auto-commit mode
- $count = $this->_db->fetchOne("SELECT COUNT(*) FROM $bugs");
- $this->assertEquals(3, $count, 'Expecting to see 3 rows in bugs table after DELETE (step 4)');
- }
-
- public function testCanChangeIsolationLevel()
- {
- $db = $this->_db;
-
- // All of these should work
- $this->assertTrue($db->setTransactionIsolationLevel(SQLSRV_TXN_READ_UNCOMMITTED));
- $this->assertTrue($db->setTransactionIsolationLevel(SQLSRV_TXN_READ_COMMITTED));
- $this->assertTrue($db->setTransactionIsolationLevel(SQLSRV_TXN_REPEATABLE_READ));
- $this->assertTrue($db->setTransactionIsolationLevel(SQLSRV_TXN_SNAPSHOT));
- $this->assertTrue($db->setTransactionIsolationLevel(SQLSRV_TXN_SERIALIZABLE));
-
- try {
- $db->setTransactionIsolationLevel('not existing isolation level');
- $this->fail("Not existing isolation types are allowed to set");
- } catch (Zend_Db_Adapter_Sqlsrv_Exception $e) {
- }
-
- $this->assertTrue($db->setTransactionIsolationLevel(), "Setting to default should work by passsing null or nothing");
- }
-
- /**
- * @group ZF-9252
- * @see zf-trunk/tests/Zend/Db/Adapter/Zend_Db_Adapter_TestCommon#testAdapterLimit()
- */
- public function testAdapterLimit()
- {
- parent::testAdapterLimit();
-
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $products.$product_id", 1);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
- $this->assertEquals(1, count($result),
- 'Expecting row count to be 1');
- $this->assertEquals(1, $result[0]['product_id'],
- 'Expecting to get product_id 1');
-
- }
-
- /**
- * @group ZF-9252
- * @see zf-trunk/tests/Zend/Db/Adapter/Zend_Db_Adapter_TestCommon#testAdapterLimitOffset()
- */
- public function testAdapterLimitOffset()
- {
- parent::testAdapterLimitOffset();
-
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $products.$product_id", 1, 1);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
- $this->assertEquals(1, count($result),
- 'Expecting row count to be 1');
- $this->assertEquals(2, $result[0]['product_id'],
- 'Expecting to get product_id 2');
- }
-
- /**
- * @group ZF-8148
- */
- public function testAdapterLimitOffsetWithOffsetExceedingRowCount()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $products.$product_id", 2, 2);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
- $this->assertEquals(1, count($result),
- 'Expecting row count to be 1');
- }
-
- /**
- * @group ZF-8148
- */
- public function testAdapterLimitWithoutOrder()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $sql = $this->_db->limit("SELECT * FROM $products", 1);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
- $this->assertEquals(1, count($result),
- 'Expecting row count to be 1');
- $this->assertEquals(1, $result[0]['product_id'],
- 'Expecting to get product_id 1');
- }
-
- /**
- * @group ZF-8148
- */
- public function testAdapterLimitOffsetWithoutOrder()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $sql = $this->_db->limit("SELECT * FROM $products", 1, 1);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
- $this->assertEquals(1, count($result),
- 'Expecting row count to be 1');
- $this->assertEquals(2, $result[0]['product_id'],
- 'Expecting to get product_id 2');
- }
-
- /**
- * @group ZF-8901
- */
- public function testAdapterLimitOffsetWithMultipleOrderColumns()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $sql = $this->_db->limit("SELECT * FROM $products ORDER BY $products.$product_id ASC, $products.$product_name DESC", 1, 1);
-
- $stmt = $this->_db->query($sql);
- $result = $stmt->fetchAll();
- $this->assertEquals(1, count($result),
- 'Expecting row count to be 1');
- $this->assertEquals(2, $result[0]['product_id'],
- 'Expecting to get product_id 2');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-
- /**
- * test that quote() escapes null byte character
- * in a string.
- */
- public function testAdapterQuoteNullByteCharacter()
- {
- $string = "1\0";
- $value = $this->_db->quote($string);
- $this->assertEquals("'1\\000'", $value);
- }
-}
diff --git a/tests/Zend/Db/AllTests.php b/tests/Zend/Db/AllTests.php
index 19e1a1262..a947869fd 100644
--- a/tests/Zend/Db/AllTests.php
+++ b/tests/Zend/Db/AllTests.php
@@ -59,20 +59,12 @@ public static function suite()
}
self::_addDbTestSuites($suite, 'Static');
- self::_addDbTestSuites($suite, 'Db2');
self::_addDbTestSuites($suite, 'Mysqli');
- self::_addDbTestSuites($suite, 'Oracle');
- self::_addDbTestSuites($suite, 'Sqlsrv');
/**
* @todo self::_addDbTestSuites($suite, 'Odbc');
*/
- self::_addDbTestSuites($suite, 'Pdo_Ibm');
- self::_addDbTestSuites($suite, 'Pdo_Mssql');
self::_addDbTestSuites($suite, 'Pdo_Mysql');
- self::_addDbTestSuites($suite, 'Pdo_Oci');
- self::_addDbTestSuites($suite, 'Pdo_Pgsql');
- self::_addDbTestSuites($suite, 'Pdo_Sqlite');
if (self::$_skipTestSuite !== null) {
$suite->addTest(self::$_skipTestSuite);
@@ -93,10 +85,7 @@ protected static function _addDbTestSuites($suite, $driver)
}
$ext = array(
- 'Oracle' => 'oci8',
- 'Db2' => 'ibm_db2',
'Mysqli' => 'mysqli',
- 'Sqlsrv' => 'sqlsrv',
/**
* @todo 'Odbc'
*/
diff --git a/tests/Zend/Db/Profiler/Db2Test.php b/tests/Zend/Db/Profiler/Db2Test.php
deleted file mode 100644
index 746f8c27b..000000000
--- a/tests/Zend/Db/Profiler/Db2Test.php
+++ /dev/null
@@ -1,55 +0,0 @@
-markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
-
- public function getDriver()
- {
- return 'Db2';
- }
-}
diff --git a/tests/Zend/Db/Profiler/FirebugTest.php b/tests/Zend/Db/Profiler/FirebugTest.php
deleted file mode 100644
index ccab26dc9..000000000
--- a/tests/Zend/Db/Profiler/FirebugTest.php
+++ /dev/null
@@ -1,219 +0,0 @@
-markTestSkipped('Requires PDO_Sqlite extension');
- }
-
- date_default_timezone_set('America/Los_Angeles');
-
- $this->_request = new Zend_Db_Profiler_FirebugTest_Request();
- $this->_response = new Zend_Db_Profiler_FirebugTest_Response();
-
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $channel->setRequest($this->_request);
- $channel->setResponse($this->_response);
-
- $this->_profiler = new Zend_Db_Profiler_Firebug();
- $this->_db = Zend_Db::factory('PDO_SQLITE',
- array('dbname' => ':memory:',
- 'profiler' => $this->_profiler));
- $this->_db->getConnection()->exec('CREATE TABLE foo (
- id INTEGNER NOT NULL,
- col1 VARCHAR(10) NOT NULL
- )');
- }
-
- public function tearDown()
- {
- if (extension_loaded('pdo_sqlite')) {
- $this->_db->getConnection()->exec('DROP TABLE foo');
- }
-
- Zend_Wildfire_Channel_HttpHeaders::destroyInstance();
- Zend_Wildfire_Plugin_FirePhp::destroyInstance();
- }
-
- public function testEnable()
- {
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $this->_db->insert('foo', array('id'=>1,'col1'=>'original'));
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $this->assertFalse($protocol->getMessages());
-
- $this->_profiler->setEnabled(true);
-
- $this->_db->insert('foo', array('id'=>1,'col1'=>'original'));
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $messages = $protocol->getMessages();
-
- $this->assertEquals(substr($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE]
- [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0],0,55),
- '[{"Type":"TABLE","Label":"Zend_Db_Profiler_Firebug (1 @');
- }
-
- public function testDisable()
- {
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $this->_profiler->setEnabled(true);
-
- $this->_db->insert('foo', array('id'=>1,'col1'=>'original'));
-
- $this->_profiler->setEnabled(false);
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $this->assertFalse($protocol->getMessages());
- }
-
- public function testCustomLabel()
- {
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $this->_profiler = new Zend_Db_Profiler_Firebug('Label 1');
- $this->_profiler->setEnabled(true);
- $this->_db->setProfiler($this->_profiler);
- $this->_db->insert('foo', array('id'=>1,'col1'=>'original'));
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $messages = $protocol->getMessages();
-
- $this->assertEquals(substr($messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE]
- [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0],0,38),
- '[{"Type":"TABLE","Label":"Label 1 (1 @');
- }
-
- public function testNoQueries()
- {
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $this->_profiler->setEnabled(true);
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $messages = $protocol->getMessages();
-
- $this->assertFalse($messages);
- }
-
- /**
- * @group ZF-6395
- */
- public function testNoQueriesAfterFiltering()
- {
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $profiler = $this->_profiler->setEnabled(true);
- $profiler->setFilterQueryType(Zend_Db_Profiler::INSERT | Zend_Db_Profiler::UPDATE);
- $this->_db->fetchAll('select * from foo');
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $messages = $protocol->getMessages();
-
- $this->assertFalse($messages);
- }
-
-}
-
-
-class Zend_Db_Profiler_FirebugTest_Request extends Zend_Controller_Request_Http
-{
- public function getHeader($header)
- {
- if ($header == 'User-Agent') {
- return 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 FirePHP/0.1.0';
- }
- }
-}
-
-class Zend_Db_Profiler_FirebugTest_Response extends Zend_Controller_Response_Http
-{
- public function canSendHeaders($throw = false)
- {
- return true;
- }
-}
diff --git a/tests/Zend/Db/Profiler/OracleTest.php b/tests/Zend/Db/Profiler/OracleTest.php
deleted file mode 100644
index f0f471c72..000000000
--- a/tests/Zend/Db/Profiler/OracleTest.php
+++ /dev/null
@@ -1,185 +0,0 @@
-_db->quoteIdentifier('bug_id', true);
-
- // prepare a query
- $select = $this->_db->select()
- ->from('zfbugs')
- ->where("$bug_id = :bug_id");
- $stmt = $this->_db->prepare($select->__toString());
-
- // execute query a first time
- $stmt->execute(array(':bug_id' => 2));
- $results = $stmt->fetchAll();
- $this->assertTrue(is_array($results));
- $this->assertEquals(2, $results[0]['bug_id']);
-
- // analyze query profiles
- $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true);
- $this->assertTrue(is_array($profiles), 'Expected array, got '.gettype($profiles));
- $this->assertEquals(1, count($profiles), 'Expected to find 1 profile');
- $qp = $profiles[0];
- $this->assertTrue($qp instanceof Zend_Db_Profiler_Query);
-
- // analyze query in the profile
- $sql = $qp->getQuery();
- $this->assertContains(" = :bug_id", $sql);
- $params = $qp->getQueryParams();
- $this->assertTrue(is_array($params));
- $this->assertEquals(array(':bug_id' => 2), $params);
-
- // execute query a second time
- $stmt->execute(array(':bug_id' => 3));
- $results = $stmt->fetchAll();
- $this->assertTrue(is_array($results));
- $this->assertEquals(3, $results[0]['bug_id']);
-
- // analyze query profiles
- $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true);
- $this->assertTrue(is_array($profiles), 'Expected array, got '.gettype($profiles));
- $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles');
- $qp = $profiles[1];
- $this->assertTrue($qp instanceof Zend_Db_Profiler_Query);
-
- // analyze query in the profile
- $sql = $qp->getQuery();
- $this->assertContains(" = :bug_id", $sql);
- $params = $qp->getQueryParams();
- $this->assertTrue(is_array($params));
- $this->assertEquals(array(':bug_id' => 3), $params);
- }
-
- public function testProfilerPreparedStatementWithBoundParams()
- {
- $bug_id = $this->_db->quoteIdentifier('bug_id', true);
-
- // prepare a query
- $select = $this->_db->select()
- ->from('zfbugs')
- ->where("$bug_id = :bug_id");
- $stmt = $this->_db->prepare($select->__toString());
-
- // execute query a first time
- $id = 1;
- $this->assertTrue($stmt->bindParam(':bug_id', $id));
- $id = 2;
- $stmt->execute();
- $results = $stmt->fetchAll();
- $this->assertTrue(is_array($results));
- $this->assertEquals(2, $results[0]['bug_id']);
-
- // analyze query profiles
- $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true);
- $this->assertTrue(is_array($profiles));
- $this->assertEquals(1, count($profiles), 'Expected to find 1 profile');
- $qp = $profiles[0];
- $this->assertTrue($qp instanceof Zend_Db_Profiler_Query);
-
- // analyze query in the profile
- $sql = $qp->getQuery();
- $this->assertContains(" = :bug_id", $sql);
- $params = $qp->getQueryParams();
- $this->assertTrue(is_array($params));
- $this->assertEquals(array(':bug_id' => 2), $params);
-
- // execute query a first time
- $id = 3;
- $stmt->execute();
- $results = $stmt->fetchAll();
- $this->assertTrue(is_array($results));
- $this->assertEquals(3, $results[0]['bug_id']);
-
- // analyze query profiles
- $profiles = $this->_db->getProfiler()->getQueryProfiles(null, true);
- $this->assertTrue(is_array($profiles));
- $this->assertEquals(2, count($profiles), 'Expected to find 2 profiles');
- $qp = $profiles[1];
- $this->assertTrue($qp instanceof Zend_Db_Profiler_Query);
-
- // analyze query in the profile
- $sql = $qp->getQuery();
- $this->assertContains(" = :bug_id", $sql);
- $params = $qp->getQueryParams();
- $this->assertTrue(is_array($params));
- $this->assertEquals(array(':bug_id' => 3), $params);
- }
-
- /**
- * Ensures that setFilterQueryType() actually filters
- *
- * @return void
- */
- protected function _testProfilerSetFilterQueryTypeCommon($queryType)
- {
- $bugs = $this->_db->quoteIdentifier('zfbugs', true);
- $bug_id = $this->_db->quoteIdentifier('bug_id', true);
- $bug_status = $this->_db->quoteIdentifier('bug_status', true);
-
- $prof = $this->_db->getProfiler();
- $prof->setEnabled(true);
-
- $this->assertSame($prof->setFilterQueryType($queryType), $prof);
- $this->assertEquals($queryType, $prof->getFilterQueryType());
-
- $this->_db->query("SELECT * FROM $bugs");
- $this->_db->query("INSERT INTO $bugs ($bug_id, $bug_status) VALUES (:id, :status)", array(':id' => 100,':status' => 'NEW'));
- $this->_db->query("DELETE FROM $bugs");
- $this->_db->query("UPDATE $bugs SET $bug_status = :status", array(':status'=>'FIXED'));
-
- $qps = $prof->getQueryProfiles();
- $this->assertTrue(is_array($qps), 'Expecting some query profiles, got none');
- foreach ($qps as $qp) {
- $qtype = $qp->getQueryType();
- $this->assertEquals($queryType, $qtype,
- "Found query type $qtype, which should have been filtered out");
- }
-
- $prof->setEnabled(false);
- }
-
- public function getDriver()
- {
- return 'Oracle';
- }
-}
diff --git a/tests/Zend/Db/Profiler/Pdo/IbmTest.php b/tests/Zend/Db/Profiler/Pdo/IbmTest.php
deleted file mode 100644
index 4b5cc3ff8..000000000
--- a/tests/Zend/Db/Profiler/Pdo/IbmTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-_db->quoteIdentifier('zfbugs', true);
- $bug_id = $this->_db->quoteIdentifier('bug_id', true);
- $bug_status = $this->_db->quoteIdentifier('bug_status', true);
-
- $prof = $this->_db->getProfiler();
- $prof->setEnabled(true);
-
- $this->assertSame($prof->setFilterQueryType($queryType), $prof);
- $this->assertEquals($queryType, $prof->getFilterQueryType());
-
- $this->_db->query("SELECT * FROM $bugs");
- $this->_db->query("INSERT INTO $bugs ($bug_id, $bug_status) VALUES (:id, :status)", array(':id' => 100,':status' => 'NEW'));
- $this->_db->query("DELETE FROM $bugs");
- $this->_db->query("UPDATE $bugs SET $bug_status = :status", array(':status'=>'FIXED'));
-
- $qps = $prof->getQueryProfiles();
- $this->assertTrue(is_array($qps), 'Expecting some query profiles, got none');
- foreach ($qps as $qp) {
- $qtype = $qp->getQueryType();
- $this->assertEquals($queryType, $qtype,
- "Found query type $qtype, which should have been filtered out");
- }
-
- $prof->setEnabled(false);
- }
-
- public function getDriver()
- {
- return 'Pdo_Oci';
- }
-}
diff --git a/tests/Zend/Db/Profiler/Pdo/PgsqlTest.php b/tests/Zend/Db/Profiler/Pdo/PgsqlTest.php
deleted file mode 100644
index 76354c3aa..000000000
--- a/tests/Zend/Db/Profiler/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,49 +0,0 @@
-markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-}
diff --git a/tests/Zend/Db/Profiler/SqlsrvTest.php b/tests/Zend/Db/Profiler/SqlsrvTest.php
deleted file mode 100644
index 96587ade8..000000000
--- a/tests/Zend/Db/Profiler/SqlsrvTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/Select/Db2Test.php b/tests/Zend/Db/Select/Db2Test.php
deleted file mode 100644
index 1d02e36ea..000000000
--- a/tests/Zend/Db/Select/Db2Test.php
+++ /dev/null
@@ -1,72 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support CROSS JOIN');
- }
-
- /**
- * ZF-5234: this test must be done on string field
- */
- protected function _selectColumnWithColonQuotedParameter ()
- {
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- /**
- * ZF-2017: Test bind use of the Zend_Db_Select class.
- * @group ZF-2017
- */
- public function testSelectQueryWithBinds()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support named parameters');
- }
-
- public function getDriver()
- {
- return 'Db2';
- }
-
-}
diff --git a/tests/Zend/Db/Select/OdbcTest.php b/tests/Zend/Db/Select/OdbcTest.php
deleted file mode 100644
index 5f5f53899..000000000
--- a/tests/Zend/Db/Select/OdbcTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- /**
- * ZF-4330 : Oracle doesn't use 'AS' to identify table alias
- */
- public function testSelectFromSelectObject ()
- {
- $select = $this->_selectFromSelectObject();
- $query = $select->assemble();
- $cmp = 'SELECT ' . $this->_db->quoteIdentifier('t') . '.* FROM (SELECT '
- . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM '
- . $this->_db->quoteIdentifier('subqueryTable') . ') '
- . $this->_db->quoteIdentifier('t');
- $this->assertEquals($query, $cmp);
- }
-
- /**
- * ZF-4330 : for Oracle, we must add order clause
- */
- public function testSelectWhereOr ()
- {
- $select = $this->_selectWhereOr();
- $select->order('product_id');
- $stmt = $this->_db->query($select);
- $result = $stmt->fetchAll();
- $this->assertEquals(2, count($result));
- $this->assertEquals(1, $result[0]['product_id']);
- $this->assertEquals(2, $result[1]['product_id']);
- }
-
- /**
- * ZF-4330 : for Oracle, we must add order clause
- */
- public function testSelectWhereOrWithParameter ()
- {
- $select = $this->_selectWhereOrWithParameter();
- $select->order('product_id');
- $stmt = $this->_db->query($select);
- $result = $stmt->fetchAll();
- $this->assertEquals(2, count($result));
- $this->assertEquals(1, $result[0]['product_id']);
- $this->assertEquals(2, $result[1]['product_id']);
- }
-
- public function getDriver ()
- {
- return 'Oracle';
- }
-}
diff --git a/tests/Zend/Db/Select/Pdo/IbmTest.php b/tests/Zend/Db/Select/Pdo/IbmTest.php
deleted file mode 100644
index 5d40c7fc9..000000000
--- a/tests/Zend/Db/Select/Pdo/IbmTest.php
+++ /dev/null
@@ -1,76 +0,0 @@
-_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestIncomplete('IDS does not support this SQL syntax');
- } else {
- parent::testSelectGroupByExpr();
- }
- }
-
- public function testSelectGroupByAutoExpr()
- {
- $server = $this->_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestIncomplete('IDS does not support this SQL syntax');
- } else {
- parent::testSelectGroupByAutoExpr();
- }
- }
-
- public function testSelectJoinCross()
- {
- $this->markTestSkipped($this->getDriver() . ' adapter support for CROSS JOIN not yet available');
- }
-}
diff --git a/tests/Zend/Db/Select/Pdo/MssqlTest.php b/tests/Zend/Db/Select/Pdo/MssqlTest.php
deleted file mode 100644
index 9bdbfcd61..000000000
--- a/tests/Zend/Db/Select/Pdo/MssqlTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function testSelectJoinQualified()
- {
- $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Select/Pdo/OciTest.php b/tests/Zend/Db/Select/Pdo/OciTest.php
deleted file mode 100644
index 75d99bdf3..000000000
--- a/tests/Zend/Db/Select/Pdo/OciTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- /**
- * ZF-4330 : Oracle doesn't use 'AS' to identify table alias
- */
- public function testSelectFromSelectObject ()
- {
- $select = $this->_selectFromSelectObject();
- $query = $select->assemble();
- $cmp = 'SELECT ' . $this->_db->quoteIdentifier('t') . '.* FROM (SELECT '
- . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM '
- . $this->_db->quoteIdentifier('subqueryTable') . ') '
- . $this->_db->quoteIdentifier('t');
- $this->assertEquals($query, $cmp);
- }
-
- /**
- * ZF-4330 : for Oracle, we must add order clause
- */
- public function testSelectWhereOr ()
- {
- $select = $this->_selectWhereOr();
- $select->order('product_id');
- $stmt = $this->_db->query($select);
- $result = $stmt->fetchAll();
- $this->assertEquals(2, count($result));
- $this->assertEquals(1, $result[0]['product_id']);
- $this->assertEquals(2, $result[1]['product_id']);
- }
-
- /**
- * ZF-4330 : for Oracle, we must add order clause
- */
- public function testSelectWhereOrWithParameter ()
- {
- $select = $this->_selectWhereOrWithParameter();
- $select->order('product_id');
- $stmt = $this->_db->query($select);
- $result = $stmt->fetchAll();
- $this->assertEquals(2, count($result));
- $this->assertEquals(1, $result[0]['product_id']);
- $this->assertEquals(2, $result[1]['product_id']);
- }
-
- public function getDriver ()
- {
- return 'Pdo_Oci';
- }
-}
diff --git a/tests/Zend/Db/Select/Pdo/PgsqlTest.php b/tests/Zend/Db/Select/Pdo/PgsqlTest.php
deleted file mode 100644
index 94f20b09c..000000000
--- a/tests/Zend/Db/Select/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,197 +0,0 @@
-_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- public function testSelectGroupByExpr()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
- }
-
- public function testSelectGroupByAutoExpr()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
- }
-
- /**
- * Ensures that from() provides expected behavior using schema specification
- *
- * @return void
- */
- public function testSelectFromSchemaSpecified()
- {
- $schema = 'public';
- $table = 'zfbugs';
-
- $sql = $this->_db->select()->from($table, '*', $schema);
-
- $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
-
- $rowset = $this->_db->fetchAll($sql);
-
- $this->assertEquals(4, count($rowset));
- }
-
- /**
- * Ensures that from() provides expected behavior using schema in the table name
- *
- * @return void
- */
- public function testSelectFromSchemaInName()
- {
- $schema = 'public';
- $table = 'zfbugs';
-
- $name = "$schema.$table";
-
- $sql = $this->_db->select()->from($name);
-
- $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
-
- $rowset = $this->_db->fetchAll($sql);
-
- $this->assertEquals(4, count($rowset));
- }
-
- /**
- * Ensures that from() overrides schema specification with schema in the table name
- *
- * @return void
- */
- public function testSelectFromSchemaInNameOverridesSchemaArgument()
- {
- $schema = 'public';
- $table = 'zfbugs';
-
- $name = "$schema.$table";
-
- $sql = $this->_db->select()->from($name, '*', 'ignored');
-
- $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
-
- $rowset = $this->_db->fetchAll($sql);
-
- $this->assertEquals(4, count($rowset));
- }
-
- public function testSqlInjectionWithOrder()
- {
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('MD5(1);select');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);select" ASC', $select->assemble());
-
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('name;select;MD5(1)');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "name;select;MD5(1)" ASC', $select->assemble());
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfSingleFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('productId DESC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId DESC', 'userId ASC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC, "userId" ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldButOnlyOneWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId', 'userId DESC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" ASC, "userId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- * @group ZF-381
- */
- public function testOrderOfConditionalFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('IF("productId" > 5,1,0) ASC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY IF("productId" > 5,1,0) ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-}
diff --git a/tests/Zend/Db/Select/Pdo/SqliteTest.php b/tests/Zend/Db/Select/Pdo/SqliteTest.php
deleted file mode 100644
index f9790c039..000000000
--- a/tests/Zend/Db/Select/Pdo/SqliteTest.php
+++ /dev/null
@@ -1,131 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support qualified table names');
- }
-
- public function testSelectJoinQualified()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support qualified table names');
- }
-
- public function testSelectFromForUpdate()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support FOR UPDATE');
- }
-
- public function testSelectJoinRight()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support RIGHT OUTER JOIN');
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-
- public function testSqlInjectionWithOrder()
- {
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('MD5(1);select');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);select" ASC', $select->assemble());
-
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('name;select;MD5(1)');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "name;select;MD5(1)" ASC', $select->assemble());
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfSingleFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('productId DESC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId DESC', 'userId ASC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC, "userId" ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldButOnlyOneWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId', 'userId DESC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" ASC, "userId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- * @group ZF-381
- */
- public function testOrderOfConditionalFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('IF("productId" > 5,1,0) ASC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY IF("productId" > 5,1,0) ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
-}
diff --git a/tests/Zend/Db/Select/SqlsrvTest.php b/tests/Zend/Db/Select/SqlsrvTest.php
deleted file mode 100644
index a55d42fb8..000000000
--- a/tests/Zend/Db/Select/SqlsrvTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support binding by name.');
- }
-
- public function testSelectColumnWithColonQuotedParameter()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support selecting int columns by varchar param.');
- }
-
- public function testSelectFromForUpdate()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support for update.');
- }
-
- public function testSelectFromQualified()
- {
- $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function testSelectJoinQualified()
- {
- $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/Statement/Db2Test.php b/tests/Zend/Db/Statement/Db2Test.php
deleted file mode 100644
index 24b2e4663..000000000
--- a/tests/Zend/Db/Statement/Db2Test.php
+++ /dev/null
@@ -1,135 +0,0 @@
-markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
- }
-
- public function testStatementErrorInfoKeyViolation()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
- }
-
- public function testStatementColumnCountForSelect()
- {
- $select = $this->_db->select()
- ->from('zfproducts');
-
- $stmt = $this->_db->prepare($select->__toString());
-
- $n = $stmt->columnCount();
- // DB2 returns the column count once the query has been prepared
- // while PDO returns it only after it has been executed
- $this->assertEquals(2, $n);
-
- $stmt->execute();
-
- $n = $stmt->columnCount();
- $stmt->closeCursor();
-
- $this->assertTrue(is_int($n));
- $this->assertEquals(2, $n);
- }
-
- public function testStatementBindParamByPosition()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
-
- public function testStatementBindParamByName()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $productIdValue = 4;
- $productNameValue = 'AmigaOS';
-
- try {
- $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)");
- // test with colon prefix
- $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true');
- // test with no colon prefix
- $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true');
- $this->fail('Expected to catch Zend_Db_Statement_Exception');
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Statement_Exception,
- 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e));
- $this->assertEquals("Invalid bind-variable name ':id'", $e->getMessage());
- }
- }
-
- public function testStatementBindValueByPosition()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding params');
- }
-
- public function testStatementBindValueByName()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $productIdValue = 4;
- $productNameValue = 'AmigaOS';
-
- try {
- $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:id, :name)");
- // test with colon prefix
- $this->assertTrue($stmt->bindParam(':id', $productIdValue), 'Expected bindParam(\':id\') to return true');
- // test with no colon prefix
- $this->assertTrue($stmt->bindParam('name', $productNameValue), 'Expected bindParam(\'name\') to return true');
- $this->fail('Expected to catch Zend_Db_Statement_Exception');
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Statement_Exception,
- 'Expecting object of type Zend_Db_Statement_Exception, got '.get_class($e));
- $this->assertEquals("Invalid bind-variable name ':id'", $e->getMessage());
- }
- }
-
- public function testStatementGetColumnMeta()
- {
- $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]');
- }
-
- public function getDriver()
- {
- return 'Db2';
- }
-
-}
diff --git a/tests/Zend/Db/Statement/OdbcTest.php b/tests/Zend/Db/Statement/OdbcTest.php
deleted file mode 100644
index b72a52af5..000000000
--- a/tests/Zend/Db/Statement/OdbcTest.php
+++ /dev/null
@@ -1,45 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support bound parameters by position');
- }
-
- public function testStatementBindValueByPosition()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support bound parameters by position');
- }
-
- public function testStatementErrorCodeKeyViolation()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
- }
-
- public function testStatementErrorInfoKeyViolation()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not return error codes correctly.');
- }
-
- public function testStatementExecuteWithParams()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)");
- $stmt->execute(array('product_id' => 4, 'product_name' => 'Solaris'));
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where("$product_id = 4");
- $result = $this->_db->fetchAll($select);
- $stmt->closeCursor();
-
- $this->assertEquals(array(array('product_id'=>4, 'product_name'=>'Solaris')), $result);
- }
-
- public function testStatementFetchAllStyleBoth()
- {
- $this->markTestIncomplete($this->getDriver() . ' driver does not support fetchAll(FETCH_BOTH)');
- }
-
- public function testStatementGetColumnMeta()
- {
- $this->markTestIncomplete($this->getDriver() . ' has not implemented getColumnMeta() yet [ZF-1424]');
- }
-
- public function testStatementNextRowset()
- {
- $select = $this->_db->select()
- ->from('zfproducts');
- $stmt = $this->_db->prepare($select->__toString());
- try {
- $stmt->nextRowset();
- $this->fail('Expected to catch Zend_Db_Statement_Oracle_Exception');
- } catch (Zend_Exception $e) {
- $this->assertTrue($e instanceof Zend_Db_Statement_Oracle_Exception,
- 'Expecting object of type Zend_Db_Statement_Oracle_Exception, got '.get_class($e));
- $this->assertEquals('HYC00 Optional feature not implemented', $e->getMessage());
- }
- $stmt->closeCursor();
- }
-
- /**
- * @group ZF-5927
- */
- public function testStatementReturnNullWithEmptyField()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $stmt = $this->_db->prepare("INSERT INTO $products ($product_id, $product_name) VALUES (:product_id, :product_name)");
- $stmt->execute(array('product_id' => 4, 'product_name' => null));
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where("$product_id = 4");
-
- $result = $this->_db->fetchAll($select);
- $this->assertTrue(array_key_exists('product_name', $result[0]), 'fetchAll must return null for empty fields with Oracle');
- $result = $this->_db->fetchRow($select);
- $this->assertTrue(array_key_exists('product_name', $result), 'fetchRow must return null for empty fields with Oracle');
- }
-
- public function testStatementSetFetchModeBoth()
- {
- $this->markTestIncomplete($this->getDriver() . ' does not implement FETCH_BOTH correctly.');
- }
-
- public function getDriver()
- {
- return 'Oracle';
- }
-}
diff --git a/tests/Zend/Db/Statement/Pdo/IbmTest.php b/tests/Zend/Db/Statement/Pdo/IbmTest.php
deleted file mode 100644
index c3a9cd353..000000000
--- a/tests/Zend/Db/Statement/Pdo/IbmTest.php
+++ /dev/null
@@ -1,114 +0,0 @@
-_db->select()
- ->from('zfproducts');
- $stmt = $this->_db->prepare($select->__toString());
-
- $result = $stmt->nextRowset();
-
- // there is no next rowset so $result should be false
- $this->assertFalse($result);
- $stmt->closeCursor();
- }
-
- public function testStatementColumnCountForSelect()
- {
- $select = $this->_db->select()
- ->from('zfproducts');
-
- $stmt = $this->_db->prepare($select->__toString());
-
- $n = $stmt->columnCount();
- $this->assertEquals(2, $n);
-
- $stmt->execute();
-
- $n = $stmt->columnCount();
- $stmt->closeCursor();
-
- $this->assertTrue(is_int($n));
- $this->assertEquals(2, $n);
- }
-
- public function testStatementGetSetAttribute()
- {
- $select = $this->_db->select()
- ->from('zfproducts');
- $stmt = $this->_db->prepare($select->__toString());
-
- $value = 'value';
- try {
- $stmt->setAttribute(1234, $value);
- } catch (Zend_Exception $e) {
- $this->assertContains('This driver doesn\'t support setting attributes', $e->getMessage());
- }
-
- try {
- $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #1");
- } catch (Zend_Exception $e) {
- $this->assertContains('Driver does not support this function: 1 Unknown attribute', $e->getMessage());
- return;
- }
-
- $valueArray = array('value1', 'value2');
- $stmt->setAttribute(1235, $valueArray);
- $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #1");
- $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2");
-
- $valueObject = new stdClass();
- $stmt->setAttribute(1236, $valueObject);
- $this->assertSame($valueObject, $stmt->getAttribute(1236), "Expected object");
- $this->assertEquals($valueArray, $stmt->getAttribute(1235), "Expected array #2");
- $this->assertEquals($value, $stmt->getAttribute(1234), "Expected '$value' #2");
- }
-}
diff --git a/tests/Zend/Db/Statement/Pdo/MssqlTest.php b/tests/Zend/Db/Statement/Pdo/MssqlTest.php
deleted file mode 100644
index 25c817c28..000000000
--- a/tests/Zend/Db/Statement/Pdo/MssqlTest.php
+++ /dev/null
@@ -1,101 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support meta data.');
- }
-
- public function testStatementExecuteWithParams()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- // Make IDENTITY column accept explicit value.
- // This can be done in only one table in a given session.
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON");
- parent::testStatementExecuteWithParams();
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF");
- }
-
- public function testStatementBindParamByPosition()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- // Make IDENTITY column accept explicit value.
- // This can be done in only one table in a given session.
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON");
- parent::testStatementBindParamByPosition();
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF");
- }
-
- public function testStatementBindParamByName()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- // Make IDENTITY column accept explicit value.
- // This can be done in only one table in a given session.
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON");
- parent::testStatementBindParamByName();
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF");
- }
-
- public function testStatementBindValueByPosition()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- // Make IDENTITY column accept explicit value.
- // This can be done in only one table in a given session.
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON");
- parent::testStatementBindValueByPosition();
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF");
- }
-
- public function testStatementBindValueByName()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- // Make IDENTITY column accept explicit value.
- // This can be done in only one table in a given session.
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products ON");
- parent::testStatementBindValueByName();
- $this->_db->getConnection()->exec("SET IDENTITY_INSERT $products OFF");
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Statement/Pdo/OciTest.php b/tests/Zend/Db/Statement/Pdo/OciTest.php
deleted file mode 100644
index f6da0c71d..000000000
--- a/tests/Zend/Db/Statement/Pdo/OciTest.php
+++ /dev/null
@@ -1,51 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support statement metadata');
- }
-
- public function getDriver()
- {
- return 'Pdo_Oci';
- }
-
-}
diff --git a/tests/Zend/Db/Statement/Pdo/PgsqlTest.php b/tests/Zend/Db/Statement/Pdo/PgsqlTest.php
deleted file mode 100644
index 40d350550..000000000
--- a/tests/Zend/Db/Statement/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,50 +0,0 @@
-markTestIncomplete($this->getDriver() . ' is having trouble with binding parameters');
- }
-
- public function testStatementBindParamByPosition()
- {
- $this->markTestIncomplete($this->getDriver() . ' is having trouble with binding parameters');
- }
-
- protected $_getColumnMetaKeys = array(
- 'native_type', 'sqlite:decl_type', 'flags', 'name', 'len', 'precision', 'pdo_type'
- );
-
- /**
- * @group ZF-7706
- */
- public function testStatementCanReturnDriverStatement()
- {
- $statement = parent::testStatementCanReturnDriverStatement();
- $this->assertTrue($statement->getDriverStatement() instanceof PDOStatement);
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-
-}
diff --git a/tests/Zend/Db/Statement/SqlsrvTest.php b/tests/Zend/Db/Statement/SqlsrvTest.php
deleted file mode 100644
index 581684905..000000000
--- a/tests/Zend/Db/Statement/SqlsrvTest.php
+++ /dev/null
@@ -1,193 +0,0 @@
-_db->quoteIdentifier('zfproducts');
-
- // Make IDENTITY column accept explicit value.
- // This can be done in only one table in a given session.
- sqlsrv_query($this->_db->getConnection(), "SET IDENTITY_INSERT $products ON");
- parent::testStatementExecuteWithParams();
- sqlsrv_query($this->_db->getConnection(), "SET IDENTITY_INSERT $products OFF");
- }
-
- public function testStatementBindParamByName()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support bind by name.');
- }
-
- public function testStatementBindValueByName()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support bind by name.');
- }
-
- public function testStatementBindParamByPosition()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support bind by position.');
- }
-
- public function testStatementBindValueByPosition()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support bind by position.');
- }
-
- public function testStatementNextRowset()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $query = "SELECT * FROM $products WHERE $product_id > 1 ORDER BY $product_id ASC";
- $stmt = $this->_db->query($query . ';' . $query);
-
- $result1 = $stmt->fetchAll();
-
- $stmt->nextRowset();
-
- $result2 = $stmt->fetchAll();
-
- $this->assertEquals(count($result1), count($result2));
- $this->assertEquals($result1, $result2);
-
- $stmt->closeCursor();
- }
-
- /*
- * @group ZF-8138
- */
- public function testStatementNextRowsetWithProcedure()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $products_procedure = $this->_db->quoteIdentifier('#InsertIntoProducts');
-
- $prodecure = "CREATE PROCEDURE $products_procedure
- @ProductName varchar(100)
- AS
- BEGIN
- -- insert row (result set 1)
- INSERT INTO $products
- ($product_name)
- VALUES
- (@ProductName);
-
- -- Get results (result set 2)
- SELECT * FROM $products;
- END";
-
- // create procedure
- $this->_db->query($prodecure);
-
- $stmt = $this->_db->query('{call ' . $products_procedure .'(?)}', array('Product'));
-
- $result1 = $stmt->rowCount();
-
- $this->assertEquals(1, $result1, 'Expected 1 row to be inserted');
-
- $stmt->nextRowset();
-
- $result2 = $stmt->fetchAll();
-
- $this->assertEquals(4, count($result2), 'Expected 3 results from original data and one 1 row');
- $this->assertEquals('Product', $result2[3]['product_name']);
-
- $stmt->closeCursor();
- }
-
- /*
- * @group ZF-7559
- */
- public function testStatementWithProcedure()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
-
- $products_procedure = $this->_db->quoteIdentifier('#GetProducts');
-
- $prodecure = "CREATE PROCEDURE $products_procedure
- AS
- BEGIN
- SELECT * FROM $products;
- END";
-
- // create procedure
- $this->_db->query($prodecure);
-
- $stmt = $this->_db->query('EXECUTE ' . $products_procedure);
-
- $result1 = $stmt->fetchAll();
-
- $this->assertEquals(3, count($result1), 'Expected 3 results from original data');
-
- $stmt->closeCursor();
- }
-
- public function testStatementErrorInfo()
- {
- $products = $this->_db->quoteIdentifier('zfproducts');
- $product_id = $this->_db->quoteIdentifier('product_id');
-
- $query = "INVALID SELECT * FROM INVALID TABLE WHERE $product_id > 1 ORDER BY $product_id ASC";
- $stmt = new Zend_Db_Statement_Sqlsrv($this->_db, $query);
-
- try {
- $stmt->fetchAll();
- $this->fail("Invalid query should have throw an error");
- } catch (Zend_Db_Statement_Sqlsrv_Exception $e) {
- // Exception is thrown, nothing to worry about
- $this->assertEquals(-11, $e->getCode());
- }
-
- $this->assertNotSame(false, $stmt->errorCode());
- $this->assertEquals(-11, $stmt->errorCode());
-
- $errors = $stmt->errorInfo();
- $this->assertEquals(2, count($errors));
- $this->assertEquals($stmt->errorCode(), $errors[0]);
- $this->assertTrue(is_string($errors[1]));
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/Table/Db2Test.php b/tests/Zend/Db/Table/Db2Test.php
deleted file mode 100644
index 952c8b4b6..000000000
--- a/tests/Zend/Db/Table/Db2Test.php
+++ /dev/null
@@ -1,46 +0,0 @@
-markTestSkipped($this->getDriver().' does not support auto-increment columns.');
- }
-
- public function testIsIdentity()
- {
- $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.');
- }
-
- /**
- * ZF-4330: Oracle needs sequence
- */
- public function testTableInsertWithSchema()
- {
- $schemaName = $this->_util->getSchema();
- $tableName = 'zfbugs';
- $identifier = join('.', array_filter(array($schemaName, $tableName)));
- $table = $this->_getTable('My_ZendDbTable_TableSpecial',
- array('name' => $tableName, 'schema' => $schemaName, Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq')
- );
-
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
-
- $profilerEnabled = $this->_db->getProfiler()->getEnabled();
- $this->_db->getProfiler()->setEnabled(true);
- $insertResult = $table->insert($row);
- $this->_db->getProfiler()->setEnabled($profilerEnabled);
-
- $qp = $this->_db->getProfiler()->getLastQueryProfile();
- $tableSpec = $this->_db->quoteIdentifier($identifier, true);
- $this->assertContains("INSERT INTO $tableSpec ", $qp->getQuery());
- }
-
- public function testTableInsertSequence()
- {
- $table = $this->_getTable('My_ZendDbTable_TableBugs',
- array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq'));
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => new Zend_Db_Expr(
- $this->_db->quoteInto('DATE ?', '2007-04-02')),
- 'updated_on' => new Zend_Db_Expr(
- $this->_db->quoteInto('DATE ?', '2007-04-02')),
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfbugs');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(5, $insertResult);
- }
-
- protected function _getRowForTableAndIdentityWithVeryLongName()
- {
- return array('thisisalongtablenameidentity' => 1, 'stuff' => 'information');
- }
-
- public function getDriver()
- {
- return 'Oracle';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Pdo/IbmTest.php b/tests/Zend/Db/Table/Pdo/IbmTest.php
deleted file mode 100644
index 30b91852d..000000000
--- a/tests/Zend/Db/Table/Pdo/IbmTest.php
+++ /dev/null
@@ -1,48 +0,0 @@
-markTestSkipped($this->getDriver().' does not support sequences.');
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Pdo/OciTest.php b/tests/Zend/Db/Table/Pdo/OciTest.php
deleted file mode 100644
index ac55a0e59..000000000
--- a/tests/Zend/Db/Table/Pdo/OciTest.php
+++ /dev/null
@@ -1,112 +0,0 @@
-markTestSkipped($this->getDriver().' does not support auto-increment keys.');
- }
-
- public function testIsIdentity()
- {
- $this->markTestSkipped($this->getDriver().' does not support auto-increment columns.');
- }
-
- /**
- * ZF-4330: Oracle needs sequence
- */
- public function testTableInsertWithSchema()
- {
- $schemaName = $this->_util->getSchema();
- $tableName = 'zfbugs';
- $identifier = join('.', array_filter(array($schemaName, $tableName)));
- $table = $this->_getTable('My_ZendDbTable_TableSpecial',
- array('name' => $tableName, 'schema' => $schemaName,Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq')
- );
-
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy',
- 'verified_by' => 'dduck'
- );
-
- $profilerEnabled = $this->_db->getProfiler()->getEnabled();
- $this->_db->getProfiler()->setEnabled(true);
- $insertResult = $table->insert($row);
- $this->_db->getProfiler()->setEnabled($profilerEnabled);
-
- $qp = $this->_db->getProfiler()->getLastQueryProfile();
- $tableSpec = $this->_db->quoteIdentifier($identifier, true);
- $this->assertContains("INSERT INTO $tableSpec ", $qp->getQuery());
- }
-
- public function testTableInsertSequence()
- {
- $table = $this->_getTable('My_ZendDbTable_TableBugs',
- array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq'));
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => new Zend_Db_Expr(
- $this->_db->quoteInto('DATE ?', '2007-04-02')),
- 'updated_on' => new Zend_Db_Expr(
- $this->_db->quoteInto('DATE ?', '2007-04-02')),
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfbugs');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(5, $insertResult);
- }
-
- protected function _getRowForTableAndIdentityWithVeryLongName()
- {
- return array('thisisalongtablenameidentity' => 1, 'stuff' => 'information');
- }
-
- public function getDriver()
- {
- return 'Pdo_Oci';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Pdo/PgsqlTest.php
deleted file mode 100644
index b6a809e54..000000000
--- a/tests/Zend/Db/Table/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,209 +0,0 @@
-_table['bugs'];
- $row = array (
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(5, $lastInsertId);
- }
-
- public function testTableInsertPkNull()
- {
- $table = $this->_table['bugs'];
- $row = array (
- 'bug_id' => null,
- 'bug_description' => 'New bug',
- 'bug_status' => 'NEW',
- 'created_on' => '2007-04-02',
- 'updated_on' => '2007-04-02',
- 'reported_by' => 'micky',
- 'assigned_to' => 'goofy'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id');
- $lastSequenceId = $this->_db->lastSequenceId('zfbugs_bug_id_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(5, $lastInsertId);
- }
-
- public function testTableInsertSequence()
- {
- $table = $this->_getTable('My_ZendDbTable_TableProducts',
- array(Zend_Db_Table_Abstract::SEQUENCE => 'zfproducts_seq'));
- $row = array (
- 'product_name' => 'Solaris'
- );
- $insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId('zfproducts');
- $lastSequenceId = $this->_db->lastSequenceId('zfproducts_seq');
- $this->assertEquals($insertResult, $lastInsertId);
- $this->assertEquals($insertResult, $lastSequenceId);
- $this->assertEquals(4, $insertResult);
- }
-
- /**
- * Ensures that the schema is null if not specified
- *
- * @return void
- */
- public function testTableSchemaNotSetIsNull()
- {
- $tableInfo = $this->_table['bugs']->info();
-
- $this->assertNull($tableInfo['schema']);
- }
-
- /**
- * Ensures that the schema is set by the 'schema' constructor configuration directive
- *
- * @return void
- */
- public function testTableSchemaSetByConstructorConfigSchema()
- {
- $schema = 'public';
-
- $config = array(
- 'db' => $this->_db,
- 'schema' => $schema
- );
-
- $table = new My_ZendDbTable_TableBugs($config);
-
- $tableInfo = $table->info();
-
- $this->assertEquals($schema, $tableInfo['schema']);
- }
-
- /**
- * Ensures that the schema is set by the 'name' constructor configuration directive
- *
- * @return void
- */
- public function testTableSchemaSetByConstructorConfigName()
- {
- $schema = 'public';
-
- $tableName = "$schema.zfbugs";
-
- $config = array(
- 'db' => $this->_db,
- 'name' => $tableName
- );
-
- $table = new My_ZendDbTable_TableBugs($config);
-
- $tableInfo = $table->info();
-
- $this->assertEquals($schema, $tableInfo['schema']);
- }
-
- /**
- * Ensures that a schema given in the 'name' constructor configuration directive overrides any schema specified
- * by the 'schema' constructor configuration directive.
- *
- * @return void
- */
- public function testTableSchemaConstructorConfigNameOverridesSchema()
- {
- $schema = 'public';
-
- $tableName = "$schema.zfbugs";
-
- $config = array(
- 'db' => $this->_db,
- 'schema' => 'foo',
- 'name' => $tableName
- );
-
- $table = new My_ZendDbTable_TableBugs($config);
-
- $tableInfo = $table->info();
-
- $this->assertEquals($schema, $tableInfo['schema']);
- }
-
- /**
- * Ensures that fetchAll() provides expected behavior when the schema is specified
- *
- * @return void
- */
- public function testTableFetchAllSchemaSet()
- {
- $schema = 'public';
-
- $config = array(
- 'db' => $this->_db,
- 'schema' => $schema,
- );
-
- $table = new My_ZendDbTable_TableBugs($config);
-
- $rowset = $table->fetchAll();
-
- $this->assertThat(
- $rowset,
- $this->isInstanceOf('Zend_Db_Table_Rowset')
- );
-
- $this->assertEquals(
- 4,
- count($rowset)
- );
- }
-}
diff --git a/tests/Zend/Db/Table/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Pdo/SqliteTest.php
deleted file mode 100644
index 83618be96..000000000
--- a/tests/Zend/Db/Table/Pdo/SqliteTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-markTestSkipped($this->getDriver().' does not support sequences.');
- }
-
- public function testDbTableSchemaSpecified()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support qualified table names');
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Relationships/Db2Test.php b/tests/Zend/Db/Table/Relationships/Db2Test.php
deleted file mode 100644
index c5bcd8f91..000000000
--- a/tests/Zend/Db/Table/Relationships/Db2Test.php
+++ /dev/null
@@ -1,45 +0,0 @@
-_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestSkipped('IDS serial columns cannot be updated');
- } else {
- parent::testTableRelationshipCascadingUpdateUsageBasicString();
- }
- }
-}
diff --git a/tests/Zend/Db/Table/Relationships/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Relationships/Pdo/MssqlTest.php
deleted file mode 100644
index f0cefa54c..000000000
--- a/tests/Zend/Db/Table/Relationships/Pdo/MssqlTest.php
+++ /dev/null
@@ -1,56 +0,0 @@
-markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function testTableRelationshipCascadingUpdateUsageInvalidNoop()
- {
- $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Relationships/Pdo/OciTest.php b/tests/Zend/Db/Table/Relationships/Pdo/OciTest.php
deleted file mode 100644
index 5dd464ff2..000000000
--- a/tests/Zend/Db/Table/Relationships/Pdo/OciTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function testTableRelationshipCascadingUpdateUsageInvalidNoop()
- {
- $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/Table/Row/Db2Test.php b/tests/Zend/Db/Table/Row/Db2Test.php
deleted file mode 100644
index c14489899..000000000
--- a/tests/Zend/Db/Table/Row/Db2Test.php
+++ /dev/null
@@ -1,47 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support auto-increment keys.');
- }
-
- /**
- * ZF-4330: Oracle need sequence
- */
- protected function _testTableRowSetReadOnlyGetTableBugs()
- {
- return $this->_getTable('My_ZendDbTable_TableBugs',
- array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq'));
- }
-
- public function getDriver()
- {
- return 'Oracle';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Row/Pdo/IbmTest.php b/tests/Zend/Db/Table/Row/Pdo/IbmTest.php
deleted file mode 100644
index 4fb4a94f7..000000000
--- a/tests/Zend/Db/Table/Row/Pdo/IbmTest.php
+++ /dev/null
@@ -1,55 +0,0 @@
-_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestSkipped('IDS Serial columns cannot be updated');
- } else {
- parent::testTableRowSetPrimaryKey();
- }
- }
-}
diff --git a/tests/Zend/Db/Table/Row/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Row/Pdo/MssqlTest.php
deleted file mode 100644
index ec30cbe76..000000000
--- a/tests/Zend/Db/Table/Row/Pdo/MssqlTest.php
+++ /dev/null
@@ -1,61 +0,0 @@
-markTestIncomplete($this->getDriver() . ': DEFAULT or NULL are not allowed as explicit identity values.');
- }
-
- public function testTableRowSetPrimaryKey()
- {
- $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function testTableRowSaveInsertSequence()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support sequences');
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Row/Pdo/OciTest.php b/tests/Zend/Db/Table/Row/Pdo/OciTest.php
deleted file mode 100644
index e765aa850..000000000
--- a/tests/Zend/Db/Table/Row/Pdo/OciTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support auto-increment keys.');
- }
-
- /**
- * ZF-4330: Oracle need sequence
- */
- protected function _testTableRowSetReadOnlyGetTableBugs()
- {
- return $this->_getTable('My_ZendDbTable_TableBugs',
- array(Zend_Db_Table_Abstract::SEQUENCE => 'zfbugs_seq'));
- }
-
- public function getDriver()
- {
- return 'Pdo_Oci';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Row/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Row/Pdo/PgsqlTest.php
deleted file mode 100644
index 50a5ad7cb..000000000
--- a/tests/Zend/Db/Table/Row/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support sequences');
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Row/SqlsrvTest.php b/tests/Zend/Db/Table/Row/SqlsrvTest.php
deleted file mode 100644
index 011f3ceaa..000000000
--- a/tests/Zend/Db/Table/Row/SqlsrvTest.php
+++ /dev/null
@@ -1,60 +0,0 @@
-markTestIncomplete($this->getDriver() . ': DEFAULT or NULL are not allowed as explicit identity values.');
- }
-
- public function testTableRowSetPrimaryKey()
- {
- $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function testTableRowSaveInsertSequence()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support sequences');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/Table/Rowset/Db2Test.php b/tests/Zend/Db/Table/Rowset/Db2Test.php
deleted file mode 100644
index 01861f5cd..000000000
--- a/tests/Zend/Db/Table/Rowset/Db2Test.php
+++ /dev/null
@@ -1,46 +0,0 @@
-_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- public function testSelectJoinCross()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support CROSS JOIN');
- }
-
- /**
- * ZF-2017: Test bind use of the Zend_Db_Select class.
- * @group ZF-2017
- */
- public function testSelectQueryWithBinds()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support named parameters');
- }
-
- public function getDriver()
- {
- return 'Db2';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Select/OdbcTest.php b/tests/Zend/Db/Table/Select/OdbcTest.php
deleted file mode 100644
index 9dd8383bd..000000000
--- a/tests/Zend/Db/Table/Select/OdbcTest.php
+++ /dev/null
@@ -1,46 +0,0 @@
-_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- /**
- * ZF-4330 : Oracle doesn't use 'AS' to identify table alias
- */
- public function testSelectFromSelectObject ()
- {
- $select = $this->_selectFromSelectObject();
- $query = $select->assemble();
- $cmp = 'SELECT ' . $this->_db->quoteIdentifier('t') . '.* FROM (SELECT '
- . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM '
- . $this->_db->quoteIdentifier('subqueryTable') . ') '
- . $this->_db->quoteIdentifier('t');
- $this->assertEquals($query, $cmp);
- }
-
- public function getDriver()
- {
- return 'Oracle';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Select/Pdo/IbmTest.php b/tests/Zend/Db/Table/Select/Pdo/IbmTest.php
deleted file mode 100644
index 6da0cff47..000000000
--- a/tests/Zend/Db/Table/Select/Pdo/IbmTest.php
+++ /dev/null
@@ -1,77 +0,0 @@
-_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestIncomplete('IDS does not support this SQL syntax');
- } else {
- parent::testSelectGroupByExpr();
- }
- }
-
- public function testSelectGroupByAutoExpr()
- {
- $server = $this->_util->getServer();
-
- if ($server == 'IDS') {
- $this->markTestIncomplete('IDS does not support this SQL syntax');
- } else {
- parent::testSelectGroupByAutoExpr();
- }
- }
-
- public function testSelectJoinCross()
- {
- $this->markTestSkipped($this->getDriver() . ' adapter support for CROSS JOIN not yet available');
- }
-}
diff --git a/tests/Zend/Db/Table/Select/Pdo/MssqlTest.php b/tests/Zend/Db/Table/Select/Pdo/MssqlTest.php
deleted file mode 100644
index fb9978b58..000000000
--- a/tests/Zend/Db/Table/Select/Pdo/MssqlTest.php
+++ /dev/null
@@ -1,57 +0,0 @@
-markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function testSelectJoinQualified()
- {
- $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function getDriver()
- {
- return 'Pdo_Mssql';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Select/Pdo/OciTest.php b/tests/Zend/Db/Table/Select/Pdo/OciTest.php
deleted file mode 100644
index 6ec3dcbc1..000000000
--- a/tests/Zend/Db/Table/Select/Pdo/OciTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
-_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- /**
- * ZF-4330 : Oracle doesn't use 'AS' to identify table alias
- */
- public function testSelectFromSelectObject ()
- {
- $select = $this->_selectFromSelectObject();
- $query = $select->assemble();
- $cmp = 'SELECT ' . $this->_db->quoteIdentifier('t') . '.* FROM (SELECT '
- . $this->_db->quoteIdentifier('subqueryTable') . '.* FROM '
- . $this->_db->quoteIdentifier('subqueryTable') . ') '
- . $this->_db->quoteIdentifier('t');
- $this->assertEquals($query, $cmp);
- }
-
- public function getDriver()
- {
- return 'Pdo_Oci';
- }
-
-}
diff --git a/tests/Zend/Db/Table/Select/Pdo/PgsqlTest.php b/tests/Zend/Db/Table/Select/Pdo/PgsqlTest.php
deleted file mode 100644
index e733e562d..000000000
--- a/tests/Zend/Db/Table/Select/Pdo/PgsqlTest.php
+++ /dev/null
@@ -1,201 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
- }
-
- public function testSelectGroupByAutoExpr()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support expressions in GROUP BY');
- }
-
- /**
- * Ensures that from() provides expected behavior using schema specification
- *
- * @return void
- */
- public function testSelectFromSchemaSpecified()
- {
- $schema = 'public';
- $table = 'zfbugs';
-
- $sql = $this->_db->select()->from($table, '*', $schema);
-
- $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
-
- $rowset = $this->_db->fetchAll($sql);
-
- $this->assertEquals(4, count($rowset));
- }
-
- /**
- * Ensures that from() provides expected behavior using schema in the table name
- *
- * @return void
- */
- public function testSelectFromSchemaInName()
- {
- $schema = 'public';
- $table = 'zfbugs';
-
- $name = "$schema.$table";
-
- $sql = $this->_db->select()->from($name);
-
- $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
-
- $rowset = $this->_db->fetchAll($sql);
-
- $this->assertEquals(4, count($rowset));
- }
-
- /**
- * Ensures that from() overrides schema specification with schema in the table name
- *
- * @return void
- */
- public function testSelectFromSchemaInNameOverridesSchemaArgument()
- {
- $schema = 'public';
- $table = 'zfbugs';
-
- $name = "$schema.$table";
-
- $sql = $this->_db->select()->from($name, '*', 'ignored');
-
- $this->assertRegExp("/FROM \"$schema\".\"$table\"/", $sql->__toString());
-
- $rowset = $this->_db->fetchAll($sql);
-
- $this->assertEquals(4, count($rowset));
- }
-
- /**
- * This test must be done on string field
- */
- protected function _selectColumnWithColonQuotedParameter ()
- {
- $product_name = $this->_db->quoteIdentifier('product_name');
-
- $select = $this->_db->select()
- ->from('zfproducts')
- ->where($product_name . ' = ?', "as'as:x");
- return $select;
- }
-
- public function testSqlInjectionWithOrder()
- {
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('MD5(1);select');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);select" ASC', $select->assemble());
-
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('name;select;MD5(1)');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "name;select;MD5(1)" ASC', $select->assemble());
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfSingleFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('productId DESC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId DESC', 'userId ASC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC, "userId" ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldButOnlyOneWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId', 'userId DESC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" ASC, "userId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- * @group ZF-381
- */
- public function testOrderOfConditionalFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('IF("productId" > 5,1,0) ASC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY IF("productId" > 5,1,0) ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
- }
diff --git a/tests/Zend/Db/Table/Select/Pdo/SqliteTest.php b/tests/Zend/Db/Table/Select/Pdo/SqliteTest.php
deleted file mode 100644
index 7400dd717..000000000
--- a/tests/Zend/Db/Table/Select/Pdo/SqliteTest.php
+++ /dev/null
@@ -1,135 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support qualified table names');
- }
-
- public function testSelectJoinQualified()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support qualified table names');
- }
-
- public function testSelectFromForUpdate()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support FOR UPDATE');
- }
-
- public function testSelectJoinRight()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support RIGHT OUTER JOIN');
- }
-
- public function getDriver()
- {
- return 'Pdo_Sqlite';
- }
-
- public function testSqlInjectionWithOrder()
- {
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('MD5(1);select');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "MD5(1);select" ASC', $select->assemble());
-
- $select = $this->_db->select();
- $select->from(array('p' => 'products'))->order('name;select;MD5(1)');
- $this->assertEquals('SELECT "p".* FROM "products" AS "p" ORDER BY "name;select;MD5(1)" ASC', $select->assemble());
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfSingleFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('productId DESC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId DESC', 'userId ASC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" DESC, "userId" ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- */
- public function testOrderOfMultiFieldButOnlyOneWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order(array ('productId', 'userId DESC'));
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY "productId" ASC, "userId" DESC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
- /**
- * @group ZF-378
- * @group ZF-381
- */
- public function testOrderOfConditionalFieldWithDirection()
- {
- $select = $this->_db->select();
- $select->from(array ('p' => 'product'))
- ->order('IF("productId" > 5,1,0) ASC');
-
- $expected = 'SELECT "p".* FROM "product" AS "p" ORDER BY IF("productId" > 5,1,0) ASC';
- $this->assertEquals($expected, $select->assemble(),
- 'Order direction of field failed');
- }
-
-}
diff --git a/tests/Zend/Db/Table/Select/SqlsrvTest.php b/tests/Zend/Db/Table/Select/SqlsrvTest.php
deleted file mode 100644
index 4f5c8f611..000000000
--- a/tests/Zend/Db/Table/Select/SqlsrvTest.php
+++ /dev/null
@@ -1,69 +0,0 @@
-markTestSkipped($this->getDriver() . ' does not support binding by name.');
- }
-
- public function testSelectColumnWithColonQuotedParameter()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support selecting int columns by varchar param.');
- }
-
- public function testSelectFromForUpdate()
- {
- $this->markTestSkipped($this->getDriver() . ' does not support for update.');
- }
-
- public function testSelectFromQualified()
- {
- $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function testSelectJoinQualified()
- {
- $this->markTestIncomplete($this->getDriver() . ' needs more syntax for qualified table names.');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/Table/SqlsrvTest.php b/tests/Zend/Db/Table/SqlsrvTest.php
deleted file mode 100644
index f1b01c297..000000000
--- a/tests/Zend/Db/Table/SqlsrvTest.php
+++ /dev/null
@@ -1,54 +0,0 @@
-markTestSkipped($this->getDriver().' does not support sequences.');
- }
-
- public function testTableCascadeUpdate()
- {
- $this->markTestSkipped($this->getDriver() . ' cannot update identity columns.');
- }
-
- public function getDriver()
- {
- return 'Sqlsrv';
- }
-}
diff --git a/tests/Zend/Db/TestSetup.php b/tests/Zend/Db/TestSetup.php
index 7e799b291..1de26d850 100644
--- a/tests/Zend/Db/TestSetup.php
+++ b/tests/Zend/Db/TestSetup.php
@@ -97,8 +97,12 @@ protected function _setUpAdapter()
*/
public function tearDown()
{
- $this->_util->tearDown();
- $this->_db->closeConnection();
+ if ($this->_util) {
+ $this->_util->tearDown();
+ }
+ if ($this->_db) {
+ $this->_db->closeConnection();
+ }
$this->_db = null;
}
diff --git a/tests/Zend/Db/TestUtil/Db2.php b/tests/Zend/Db/TestUtil/Db2.php
deleted file mode 100644
index 99e1ed56d..000000000
--- a/tests/Zend/Db/TestUtil/Db2.php
+++ /dev/null
@@ -1,201 +0,0 @@
-setAdapter($db);
- $this->createSequence('zfproducts_seq');
- parent::setUp($db);
- }
-
- public function getParams(array $constants = array())
- {
- $constants = array(
- 'host' => 'TESTS_ZEND_DB_ADAPTER_DB2_HOSTNAME',
- 'username' => 'TESTS_ZEND_DB_ADAPTER_DB2_USERNAME',
- 'password' => 'TESTS_ZEND_DB_ADAPTER_DB2_PASSWORD',
- 'dbname' => 'TESTS_ZEND_DB_ADAPTER_DB2_DATABASE',
- 'port' => 'TESTS_ZEND_DB_ADAPTER_DB2_PORT'
- );
-
- $params = parent::getParams($constants);
-
- if (isset($GLOBALS['TESTS_ZEND_DB_ADAPTER_DB2_DRIVER_OPTIONS'])) {
- $params['driver_options'] = $GLOBALS['TESTS_ZEND_DB_ADAPTER_DB2_DRIVER_OPTIONS'];
- }
-
- return $params;
- }
-
- public function getSchema()
- {
- $desc = $this->_db->describeTable('zfproducts');
- return $desc['product_id']['SCHEMA_NAME'];
- }
-
- /**
- * For DB2, override the Products table to use an
- * explicit sequence-based column.
- */
- protected function _getColumnsProducts()
- {
- return array(
- 'product_id' => 'INT NOT NULL PRIMARY KEY',
- 'product_name' => 'VARCHAR(100)'
- );
- }
-
- protected function _getDataProducts()
- {
- $data = parent::_getDataProducts();
- foreach ($data as &$row) {
- $row['product_id'] = new Zend_Db_Expr('NEXTVAL FOR '.$this->_db->quoteIdentifier('zfproducts_seq', true));
- }
- return $data;
- }
-
- protected function _getDataDocuments()
- {
- return array (
- array(
- 'doc_id' => 1,
- 'doc_clob' => 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...',
- 'doc_blob' => new Zend_Db_Expr("BLOB('this is the blob that never ends...".
- "this is the blob that never ends...".
- "this is the blob that never ends...')")
- )
- );
- }
-
- public function getSqlType($type)
- {
- if ($type == 'IDENTITY') {
- return 'INT NOT NULL GENERATED BY DEFAULT AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY';
- }
- if ($type == 'DATETIME') {
- return 'DATE';
- }
- return $type;
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- if ($this->_db->isI5()) {
- $tableList = $this->_db->fetchCol('SELECT UPPER(T.TABLE_NAME) FROM QSYS2.TABLES T '
- . $this->_db->quoteInto(' WHERE UPPER(T.TABLE_NAME) = UPPER(?)', $tableName)
- );
- } else {
- $tableList = $this->_db->fetchCol('SELECT UPPER(T.TABLE_NAME) FROM SYSIBM.TABLES T '
- . $this->_db->quoteInto(' WHERE UPPER(T.TABLE_NAME) = UPPER(?)', $tableName)
- );
- }
-
- if (in_array(strtoupper($tableName), $tableList)) {
- return null;
- }
- return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true);
- }
-
- protected function _getSqlDropTable($tableName)
- {
- if ($this->_db->isI5()) {
- $tableList = $this->_db->fetchCol('SELECT UPPER(T.TABLE_NAME) FROM QSYS2.TABLES T '
- . $this->_db->quoteInto(' WHERE UPPER(T.TABLE_NAME) = UPPER(?)', $tableName)
- );
- } else {
- $tableList = $this->_db->fetchCol('SELECT UPPER(T.TABLE_NAME) FROM SYSIBM.TABLES T '
- . $this->_db->quoteInto(' WHERE UPPER(T.TABLE_NAME) = UPPER(?)', $tableName)
- );
- }
-
- if (in_array(strtoupper($tableName), $tableList)) {
- return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true);
- }
- return null;
- }
-
- protected function _getSqlCreateSequence($sequenceName)
- {
- if ($this->_db->isI5()) {
- $sequenceQuery = 'SELECT UPPER(S.SEQNAME) FROM QSYS2.SYSSEQUENCES S '
- . $this->_db->quoteInto(' WHERE UPPER(S.SEQNAME) = UPPER(?)', $sequenceName);
- } else {
- $sequenceQuery = 'SELECT UPPER(S.SEQNAME) FROM SYSIBM.SYSSEQUENCES S '
- . $this->_db->quoteInto(' WHERE UPPER(S.SEQNAME) = UPPER(?)', $sequenceName);
- }
-
- $seqList = $this->_db->fetchCol($sequenceQuery);
-
- if (in_array(strtoupper($sequenceName), $seqList)) {
- return null;
- }
- return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true) . ' AS INT START WITH 1 INCREMENT BY 1 MINVALUE 1';
- }
-
- protected function _getSqlDropSequence($sequenceName)
- {
- if ($this->_db->isI5()) {
- $sequenceQuery = 'SELECT UPPER(S.SEQNAME) FROM QSYS2.SYSSEQUENCES S '
- . $this->_db->quoteInto(' WHERE UPPER(S.SEQNAME) = UPPER(?)', $sequenceName);
- } else {
- $sequenceQuery = 'SELECT UPPER(S.SEQNAME) FROM SYSIBM.SYSSEQUENCES S '
- . $this->_db->quoteInto(' WHERE UPPER(S.SEQNAME) = UPPER(?)', $sequenceName);
- }
-
- $seqList = $this->_db->fetchCol($sequenceQuery);
-
- if (in_array(strtoupper($sequenceName), $seqList)) {
- return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true) . ' RESTRICT';
- }
- return null;
- }
-
- protected function _rawQuery($sql)
- {
- $conn = $this->_db->getConnection();
- $result = @db2_exec($conn, $sql);
-
- if (!$result) {
- $e = db2_stmt_errormsg();
- // require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception("SQL error for \"$sql\": $e");
- }
- }
-
-}
diff --git a/tests/Zend/Db/TestUtil/Oracle.php b/tests/Zend/Db/TestUtil/Oracle.php
deleted file mode 100644
index e1d16cc33..000000000
--- a/tests/Zend/Db/TestUtil/Oracle.php
+++ /dev/null
@@ -1,59 +0,0 @@
-_db->getConnection();
- $stmt = oci_parse($conn, $sql);
- if (!$stmt) {
- $e = oci_error($conn);
- // require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception("SQL parse error for \"$sql\": ".$e['message']);
- }
- $retval = oci_execute($stmt);
- if (!$retval) {
- $e = oci_error($conn);
- // require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception("SQL execute error for \"$sql\": ".$e['message']);
- }
- }
-
-}
diff --git a/tests/Zend/Db/TestUtil/Pdo/Ibm.php b/tests/Zend/Db/TestUtil/Pdo/Ibm.php
deleted file mode 100644
index b1e2eb230..000000000
--- a/tests/Zend/Db/TestUtil/Pdo/Ibm.php
+++ /dev/null
@@ -1,184 +0,0 @@
-_db->describeTable('zfproducts');
- return $desc['product_id']['SCHEMA_NAME'];
- }
-
- protected function _getDataProducts()
- {
- $data = parent::_getDataProducts();
-
- $server = $this->getServer();
- if ($server == 'IDS') {
- foreach ($data as &$row) {
- $row['product_id'] = new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq', true) . ".NEXTVAL");
- }
- }
- return $data;
- }
-
- protected function _getDataDocuments()
- {
- $server = $this->getServer();
-
- if ($server == 'IDS') {
- return array (
- array(
- 'doc_id' => 1,
- 'doc_clob' => 'this is the clob that never ends...'.
- 'this is the clob that never ends...'.
- 'this is the clob that never ends...',
- 'doc_blob' => 'this is the blob that never ends...'.
- 'this is the blob that never ends...'.
- 'this is the blob that never ends...'
- )
- );
- }
-
- return parent::_getDataDocuments();
- }
-
- public function getSqlType($type)
- {
- $server = $this->getServer();
-
- if ($server == 'IDS') {
-
- if ($type == 'IDENTITY') {
- return 'SERIAL(1) PRIMARY KEY';
- }
- if ($type == 'DATETIME') {
- return 'DATE';
- }
- return $type;
- }
- return parent::getSqlType($type);
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- $server = $this->getServer();
-
- if ($server == 'IDS') {
- $tableList = $this->_db->fetchCol('SELECT T.TABNAME FROM SYSTABLES T '
- . $this->_db->quoteInto(' WHERE T.TABNAME = ?', $tableName)
- );
- if (in_array($tableName, $tableList)) {
- return null;
- }
- return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true);
- }
-
- return parent::_getSqlCreateTable($tableName);
- }
-
- protected function _getSqlDropTable($tableName)
- {
- $server = $this->getServer();
-
- if ($server == 'IDS') {
- $tableList = $this->_db->fetchCol('SELECT T.TABNAME FROM SYSTABLES T '
- . $this->_db->quoteInto(' WHERE T.TABNAME = ?', $tableName)
- );
- if (in_array($tableName, $tableList)) {
- return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true);
- }
- return null;
- }
-
- return parent::_getSqlDropTable($tableName);
- }
-
- protected function _getSqlCreateSequence($sequenceName)
- {
- $server = $this->getServer();
-
- if ($server == 'IDS') {
- $seqList = $this->_db->fetchCol('SELECT S.TABNAME FROM SYSTABLES S '
- . $this->_db->quoteInto(' WHERE S.TABNAME = ?', $sequenceName)
- . " AND S.TABTYPE = 'Q'"
- );
-
- if (in_array($sequenceName, $seqList)) {
- return null;
- }
- return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true) . ' START WITH 1 INCREMENT BY 1 MINVALUE 1';
- }
-
- return parent::_getSqlCreateSequence($sequenceName);
- }
-
- protected function _getSqlDropSequence($sequenceName)
- {
- $server = $this->getServer();
-
- if ($server == 'IDS') {
- $seqList = $this->_db->fetchCol('SELECT S.TABNAME FROM SYSTABLES S '
- . $this->_db->quoteInto(' WHERE S.TABNAME = ?', $sequenceName)
- . " AND S.TABTYPE = 'Q'"
- );
-
- if (in_array($sequenceName, $seqList)) {
- return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true);
- }
- return null;
- }
-
- return parent::_getSqlDropSequence($sequenceName);
- }
-
- public function getServer()
- {
- return substr($this->_db->getConnection()->getAttribute(PDO::ATTR_SERVER_INFO), 0, 3);
- }
-
- protected function _rawQuery($sql)
- {
- $conn = $this->_db->getConnection();
- $retval = $conn->query($sql);
- if (!$retval) {
- $e = $conn->error;
- // require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception("SQL error for \"$sql\": $e");
- }
- }
-}
diff --git a/tests/Zend/Db/TestUtil/Pdo/Mssql.php b/tests/Zend/Db/TestUtil/Pdo/Mssql.php
deleted file mode 100644
index c20a8c8a9..000000000
--- a/tests/Zend/Db/TestUtil/Pdo/Mssql.php
+++ /dev/null
@@ -1,127 +0,0 @@
- 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_HOSTNAME',
- 'username' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_USERNAME',
- 'password' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PASSWORD',
- 'dbname' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_DATABASE',
- 'port' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PORT',
- 'pdoType' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_PDOTYPE',
- 'charset' => 'TESTS_ZEND_DB_ADAPTER_PDO_MSSQL_CHARSET',
- );
-
- return parent::getParams($constants);
- }
-
- public function getSqlType($type)
- {
- if ($type == 'IDENTITY') {
- return 'INT NOT NULL IDENTITY PRIMARY KEY';
- }
- return $type;
- }
-
- protected function _getColumnsDocuments()
- {
- return array(
- 'doc_id' => 'INTEGER NOT NULL',
- 'doc_clob' => 'VARCHAR(8000)',
- 'doc_blob' => 'VARCHAR(8000)',
- 'PRIMARY KEY' => 'doc_id'
- );
- }
-
- protected function _getColumnsBugs()
- {
- return array(
- 'bug_id' => 'IDENTITY',
- 'bug_description' => 'VARCHAR(100) NULL',
- 'bug_status' => 'VARCHAR(20) NULL',
- 'created_on' => 'DATETIME NULL',
- 'updated_on' => 'DATETIME NULL',
- 'reported_by' => 'VARCHAR(100) NULL',
- 'assigned_to' => 'VARCHAR(100) NULL',
- 'verified_by' => 'VARCHAR(100) NULL'
- );
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- $sql = "exec sp_tables @table_name = " . $this->_db->quoteIdentifier($tableName, true);
- $stmt = $this->_db->query($sql);
- $tableList = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
-
- if (count($tableList) > 0 && $tableName == $tableList[0]['TABLE_NAME']) {
- return null;
- }
- return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName);
- }
-
- private function _getSqlDropElement($elementName, $typeElement = 'TABLE')
- {
- $sql = "exec sp_tables @table_name = " . $this->_db->quoteIdentifier($elementName, true);
- $stmt = $this->_db->query($sql);
- $elementList = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
-
- if (count($elementList) > 0 && $elementName == $elementList[0]['TABLE_NAME']) {
- return "DROP $typeElement " . $this->_db->quoteIdentifier($elementName);
- }
- return null;
- }
-
- protected function _getSqlDropTable($tableName)
- {
- return $this->_getSqlDropElement($tableName);
- }
-
- protected function _getSqlDropView($viewName)
- {
- return $this->_getSqlDropElement($viewName, 'VIEW');
- }
-
- public function createView()
- {
- parent::dropView();
- parent::createView();
- }
-}
diff --git a/tests/Zend/Db/TestUtil/Pdo/Oci.php b/tests/Zend/Db/TestUtil/Pdo/Oci.php
deleted file mode 100644
index 184965ba7..000000000
--- a/tests/Zend/Db/TestUtil/Pdo/Oci.php
+++ /dev/null
@@ -1,171 +0,0 @@
-_db = $db;
- $this->createSequence('zfbugs_seq');
- $this->createSequence('zfproducts_seq');
- parent::setUp($db);
- }
-
- public function getParams(array $constants = array())
- {
- $constants = array (
- 'host' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_HOSTNAME',
- 'username' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_USERNAME',
- 'password' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_PASSWORD',
- 'dbname' => 'TESTS_ZEND_DB_ADAPTER_ORACLE_SID'
- );
- return parent::getParams($constants);
- }
-
- public function getSqlType($type)
- {
- if (preg_match('/VARCHAR(.*)/', $type, $matches)) {
- return 'VARCHAR2' . $matches[1];
- }
- if ($type == 'IDENTITY') {
- return 'NUMBER(11) PRIMARY KEY';
- }
- if ($type == 'INTEGER') {
- return 'NUMBER(11)';
- }
- if ($type == 'DATETIME') {
- return 'TIMESTAMP';
- }
- return $type;
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- $tableList = $this->_db->fetchCol('SELECT UPPER(TABLE_NAME) FROM ALL_TABLES '
- . $this->_db->quoteInto(' WHERE UPPER(TABLE_NAME) = UPPER(?)', $tableName)
- );
- if (in_array(strtoupper($tableName), $tableList)) {
- return null;
- }
- return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName, true);
- }
-
- protected function _getSqlDropTable($tableName)
- {
- $tableList = $this->_db->fetchCol('SELECT UPPER(TABLE_NAME) FROM ALL_TABLES '
- . $this->_db->quoteInto(' WHERE UPPER(TABLE_NAME) = UPPER(?)', $tableName)
- );
- if (in_array(strtoupper($tableName), $tableList)) {
- return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName, true);
- }
- return null;
- }
-
- protected function _getSqlCreateSequence($sequenceName)
- {
- $seqList = $this->_db->fetchCol('SELECT UPPER(SEQUENCE_NAME) FROM ALL_SEQUENCES '
- . $this->_db->quoteInto(' WHERE UPPER(SEQUENCE_NAME) = UPPER(?)', $sequenceName)
- );
- if (in_array(strtoupper($sequenceName), $seqList)) {
- return null;
- }
- return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true);
- }
-
- protected function _getSqlDropSequence($sequenceName)
- {
- $seqList = $this->_db->fetchCol('SELECT UPPER(SEQUENCE_NAME) FROM ALL_SEQUENCES '
- . $this->_db->quoteInto(' WHERE UPPER(SEQUENCE_NAME) = UPPER(?)', $sequenceName)
- );
- if (in_array(strtoupper($sequenceName), $seqList)) {
- return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName, true);
- }
- return null;
- }
-
- protected function _getDataBugs()
- {
- $data = parent::_getDataBugs();
- foreach ($data as &$row) {
- $row['bug_id'] = new Zend_Db_Expr($this->_db->quoteIdentifier('zfbugs_seq', true).'.NEXTVAL');
- $row['created_on'] = new Zend_Db_Expr($this->_db->quoteInto('DATE ?', $row['created_on']));
- $row['updated_on'] = new Zend_Db_Expr($this->_db->quoteInto('DATE ?', $row['updated_on']));
- }
- return $data;
- }
-
- protected function _getDataDocuments()
- {
- $data = parent::_getDataDocuments();
- foreach ($data as &$row) {
- $quoted = $this->_db->quote($row['doc_clob']);
- $hex = bin2hex($row['doc_clob']);
- $row['doc_clob'] = new Zend_Db_Expr("TO_CLOB($quoted)");
- $row['doc_blob'] = new Zend_Db_Expr("TO_BLOB(HEXTORAW('$hex'))");
-
- }
- return $data;
- }
-
- protected function _getDataProducts()
- {
- $data = parent::_getDataProducts();
- foreach ($data as &$row) {
- $row['product_id'] = new Zend_Db_Expr($this->_db->quoteIdentifier('zfproducts_seq', true).'.NEXTVAL');
- }
- return $data;
- }
-
- protected function _getSqlCreateView($viewName)
- {
- return 'CREATE OR REPLACE VIEW ' . $this->_db->quoteIdentifier($viewName, true);
- }
-
- /**
- * ZF-4330: schemas on Oracle are specifics:
- * "A schema is owned by a database user and has the same name as that user."
- * http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14220/intro.htm#sthref69
- * @return string
- */
- public function getSchema()
- {
- $param = $this->getParams();
- return $param['username'];
- }
-
-}
diff --git a/tests/Zend/Db/TestUtil/Pdo/Pgsql.php b/tests/Zend/Db/TestUtil/Pdo/Pgsql.php
deleted file mode 100644
index 5f1b3b7f3..000000000
--- a/tests/Zend/Db/TestUtil/Pdo/Pgsql.php
+++ /dev/null
@@ -1,146 +0,0 @@
-_db = $db;
- $this->createSequence('zfproducts_seq');
- parent::setUp($db);
- }
-
- public function getParams(array $constants = array())
- {
- $constants = array (
- 'host' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_HOSTNAME',
- 'username' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME',
- 'password' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD',
- 'dbname' => 'TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE'
- );
- return parent::getParams($constants);
- }
-
- public function getSchema()
- {
- return 'public';
- }
-
- /**
- * For PostgreSQL, override the Products table to use an
- * explicit sequence-based column.
- */
- protected function _getColumnsProducts()
- {
- return array(
- 'product_id' => 'INT NOT NULL PRIMARY KEY',
- 'product_name' => 'VARCHAR(100)'
- );
- }
-
- protected function _getDataProducts()
- {
- $data = parent::_getDataProducts();
- foreach ($data as &$row) {
- $row['product_id'] = new Zend_Db_Expr('NEXTVAL('.$this->_db->quote('zfproducts_seq').')');
- }
- return $data;
- }
-
- public function getSqlType($type)
- {
- if ($type == 'IDENTITY') {
- return 'SERIAL PRIMARY KEY';
- }
- if ($type == 'DATETIME') {
- return 'TIMESTAMP';
- }
- if ($type == 'CLOB') {
- return 'TEXT';
- }
- if ($type == 'BLOB') {
- return 'TEXT';
- }
- return $type;
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- $tableList = $this->_db->fetchCol('SELECT relname AS table_name FROM pg_class '
- . $this->_db->quoteInto(' WHERE relkind = \'r\' AND relname = ?', $tableName)
- );
- if (in_array($tableName, $tableList)) {
- return null;
- }
- return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName);
- }
-
- protected function _getSqlDropTable($tableName)
- {
- $tableList = $this->_db->fetchCol('SELECT relname AS table_name FROM pg_class '
- . $this->_db->quoteInto(' WHERE relkind = \'r\' AND relname = ?', $tableName)
- );
- if (in_array($tableName, $tableList)) {
- return 'DROP TABLE ' . $this->_db->quoteIdentifier($tableName) . ' CASCADE';
- }
- return null;
- }
-
- protected function _getSqlCreateSequence($sequenceName)
- {
- $seqList = $this->_db->fetchCol('SELECT relname AS sequence_name FROM pg_class '
- . $this->_db->quoteInto(' WHERE relkind = \'S\' AND relname = ?', $sequenceName)
- );
- if (in_array($sequenceName, $seqList)) {
- return null;
- }
- return 'CREATE SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName);
- }
-
- protected function _getSqlDropSequence($sequenceName)
- {
- $seqList = $this->_db->fetchCol('SELECT relname AS sequence_name FROM pg_class '
- . $this->_db->quoteInto(' WHERE relkind = \'S\' AND relname = ?', $sequenceName)
- );
- if (in_array($sequenceName, $seqList)) {
- return 'DROP SEQUENCE ' . $this->_db->quoteIdentifier($sequenceName);
- }
- return null;
- }
-
-}
diff --git a/tests/Zend/Db/TestUtil/Pdo/Sqlite.php b/tests/Zend/Db/TestUtil/Pdo/Sqlite.php
deleted file mode 100644
index 69814d9ae..000000000
--- a/tests/Zend/Db/TestUtil/Pdo/Sqlite.php
+++ /dev/null
@@ -1,76 +0,0 @@
- 'TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_DATABASE'
- );
- return parent::getParams($constants);
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- return 'CREATE TABLE IF NOT EXISTS ' . $this->_db->quoteIdentifier($tableName);
- }
-
- protected function _getSqlDropTable($tableName)
- {
- return 'DROP TABLE IF EXISTS ' . $this->_db->quoteIdentifier($tableName);
- }
-
- public function getSqlType($type)
- {
- if ($type == 'IDENTITY') {
- return 'INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT';
- }
- return $type;
- }
-
- protected function _getSqlCreateView($viewName)
- {
- return 'CREATE VIEW IF NOT EXISTS ' . $this->_db->quoteIdentifier($viewName, true);
- }
-
- protected function _getSqlDropView($viewName)
- {
- return 'DROP VIEW IF EXISTS ' . $this->_db->quoteIdentifier($viewName, true);
- }
-}
diff --git a/tests/Zend/Db/TestUtil/Sqlsrv.php b/tests/Zend/Db/TestUtil/Sqlsrv.php
deleted file mode 100644
index 22263cff0..000000000
--- a/tests/Zend/Db/TestUtil/Sqlsrv.php
+++ /dev/null
@@ -1,143 +0,0 @@
- 'TESTS_ZEND_DB_ADAPTER_SQLSRV_HOSTNAME',
- 'username' => 'TESTS_ZEND_DB_ADAPTER_SQLSRV_USERNAME',
- 'password' => 'TESTS_ZEND_DB_ADAPTER_SQLSRV_PASSWORD',
- 'dbname' => 'TESTS_ZEND_DB_ADAPTER_SQLSRV_DATABASE',
- );
-
- $constants = parent::getParams($constants);
-
- return $constants;
- }
-
- public function getSqlType($type)
- {
- if ($type == 'IDENTITY') {
- return 'INT NOT NULL IDENTITY PRIMARY KEY';
- }
- return $type;
- }
-
- protected function _getColumnsDocuments()
- {
- return array(
- 'doc_id' => 'INTEGER NOT NULL',
- 'doc_clob' => 'VARCHAR(8000)',
- 'doc_blob' => 'VARCHAR(8000)',
- 'PRIMARY KEY' => 'doc_id',
- );
- }
-
- protected function _getColumnsBugs()
- {
- return array(
- 'bug_id' => 'IDENTITY',
- 'bug_description' => 'VARCHAR(100) NULL',
- 'bug_status' => 'VARCHAR(20) NULL',
- 'created_on' => 'DATETIME NULL',
- 'updated_on' => 'DATETIME NULL',
- 'reported_by' => 'VARCHAR(100) NULL',
- 'assigned_to' => 'VARCHAR(100) NULL',
- 'verified_by' => 'VARCHAR(100) NULL',
- );
- }
-
- protected function _getSqlCreateTable($tableName)
- {
- $sql = "exec sp_tables @table_name = " . $this->_db->quoteIdentifier($tableName, true);
- $stmt = $this->_db->query($sql);
- $tableList = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
-
- if (count($tableList) > 0 && $tableName == $tableList[0]['TABLE_NAME']) {
- return null;
- }
- return 'CREATE TABLE ' . $this->_db->quoteIdentifier($tableName);
- }
-
- protected function _getSqlDropElement($elementName, $typeElement = 'TABLE')
- {
- $sql = "exec sp_tables @table_name = " . $this->_db->quoteIdentifier($elementName, true);
- $stmt = $this->_db->query($sql);
- $elementList = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
-
- if (count($elementList) > 0 && $elementName == $elementList[0]['TABLE_NAME']) {
- return "DROP $typeElement " . $this->_db->quoteIdentifier($elementName);
- }
- return null;
- }
-
- protected function _getSqlDropTable($tableName)
- {
- return $this->_getSqlDropElement($tableName);
- }
-
- protected function _getSqlDropView($viewName)
- {
- return $this->_getSqlDropElement($viewName, 'VIEW');
- }
-
- public function getSchema()
- {
- $desc = $this->_db->describeTable('zfproducts');
- return $desc['product_id']['SCHEMA_NAME'];
- }
-
- public function createView()
- {
- parent::dropView();
- parent::createView();
- }
-
- protected function _rawQuery($sql)
- {
- $sqlsrv = $this->_db->getConnection();
- $retval = sqlsrv_query($sqlsrv, $sql);
- if (!$retval) {
- $e = sqlsrv_errors();
- $e = $e[0]['message'];
- // require_once 'Zend/Db/Exception.php';
- throw new Zend_Db_Exception("SQL error for \"$sql\": $e");
- }
- }
-}
diff --git a/tests/Zend/Log/AllTests.php b/tests/Zend/Log/AllTests.php
deleted file mode 100644
index d8174397f..000000000
--- a/tests/Zend/Log/AllTests.php
+++ /dev/null
@@ -1,62 +0,0 @@
-addTestSuite('Zend_Log_LogTest');
- $suite->addTest(Zend_Log_Filter_AllTests::suite());
- $suite->addTest(Zend_Log_Formatter_AllTests::suite());
- $suite->addTest(Zend_Log_Writer_AllTests::suite());
-
- return $suite;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_AllTests::main') {
- Zend_Log_AllTests::main();
-}
diff --git a/tests/Zend/Log/Filter/AllTests.php b/tests/Zend/Log/Filter/AllTests.php
deleted file mode 100644
index e2ec6d33e..000000000
--- a/tests/Zend/Log/Filter/AllTests.php
+++ /dev/null
@@ -1,63 +0,0 @@
-addTestSuite('Zend_Log_Filter_ChainingTest');
- $suite->addTestSuite('Zend_Log_Filter_MessageTest');
- $suite->addTestSuite('Zend_Log_Filter_PriorityTest');
- $suite->addTestSuite('Zend_Log_Filter_SuppressTest');
-
- return $suite;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Filter_AllTests::main') {
- Zend_Log_Filter_AllTests::main();
-}
diff --git a/tests/Zend/Log/Filter/ChainingTest.php b/tests/Zend/Log/Filter/ChainingTest.php
deleted file mode 100644
index 33a15dcd9..000000000
--- a/tests/Zend/Log/Filter/ChainingTest.php
+++ /dev/null
@@ -1,101 +0,0 @@
-log = fopen('php://memory', 'w');
- $this->logger = new Zend_Log();
- $this->logger->addWriter(new Zend_Log_Writer_Stream($this->log));
- }
-
- public function tearDown()
- {
- fclose($this->log);
- }
-
- public function testFilterAllWriters()
- {
- // filter out anything above a WARNing for all writers
- $this->logger->addFilter(Zend_Log::WARN);
-
- $this->logger->info($ignored = 'info-message-ignored');
- $this->logger->warn($logged = 'warn-message-logged');
-
- rewind($this->log);
- $logdata = stream_get_contents($this->log);
-
- $this->assertNotContains($ignored, $logdata);
- $this->assertContains($logged, $logdata);
- }
-
- public function testFilterOnSpecificWriter()
- {
- $log2 = fopen('php://memory', 'w');
- $writer2 = new Zend_Log_Writer_Stream($log2);
- $writer2->addFilter(Zend_Log::ERR);
-
- $this->logger->addWriter($writer2);
-
- $this->logger->warn($warn = 'warn-message');
- $this->logger->err($err = 'err-message');
-
- rewind($this->log);
- $logdata = stream_get_contents($this->log);
- $this->assertContains($warn, $logdata);
- $this->assertContains($err, $logdata);
-
- rewind($log2);
- $logdata = stream_get_contents($log2);
- $this->assertContains($err, $logdata);
- $this->assertNotContains($warn, $logdata);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Filter_ChainingTest::main') {
- Zend_Log_Filter_ChainingTest::main();
-}
diff --git a/tests/Zend/Log/Filter/MessageTest.php b/tests/Zend/Log/Filter/MessageTest.php
deleted file mode 100644
index f2fbd83f0..000000000
--- a/tests/Zend/Log/Filter/MessageTest.php
+++ /dev/null
@@ -1,99 +0,0 @@
-fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegexp('/invalid reg/i', $e->getMessage());
- }
- }
-
- public function testMessageFilter()
- {
- $filter = new Zend_Log_Filter_Message('/accept/');
- $this->assertTrue($filter->accept(array('message' => 'foo accept bar')));
- $this->assertFalse($filter->accept(array('message' => 'foo reject bar')));
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Mock",
- 'filterName' => "Message",
- 'filterParams' => array(
- 'regexp' => "/42/"
- ),
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- public function testFactoryWithConfig()
- {
- // require_once 'Zend/Config.php';
- $config = new Zend_Config(array('log' => array('memory' => array(
- 'writerName' => "Mock",
- 'filterName' => "Message",
- 'filterParams' => array(
- 'regexp' => "/42/"
- ),
- ))));
-
- $filter = Zend_Log_Filter_Message::factory($config->log->memory->filterParams);
- $this->assertTrue($filter instanceof Zend_Log_Filter_Message);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Filter_MessageTest::main') {
- Zend_Log_Filter_MessageTest::main();
-}
diff --git a/tests/Zend/Log/Filter/PriorityTest.php b/tests/Zend/Log/Filter/PriorityTest.php
deleted file mode 100644
index b76f2fad6..000000000
--- a/tests/Zend/Log/Filter/PriorityTest.php
+++ /dev/null
@@ -1,109 +0,0 @@
-assertTrue($filter->accept(array('priority' => 2)));
- $this->assertTrue($filter->accept(array('priority' => 1)));
- $this->assertFalse($filter->accept(array('priority' => 3)));
- }
-
- public function testComparisonOperatorCanBeChanged()
- {
- // accept above priority 2
- $filter = new Zend_Log_Filter_Priority(2, '>');
-
- $this->assertTrue($filter->accept(array('priority' => 3)));
- $this->assertFalse($filter->accept(array('priority' => 2)));
- $this->assertFalse($filter->accept(array('priority' => 1)));
- }
-
- public function testConstructorThrowsOnInvalidPriority()
- {
- try {
- new Zend_Log_Filter_Priority('foo');
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/must be an integer/i', $e->getMessage());
- }
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Mock",
- 'filterName' => "Priority",
- 'filterParams' => array(
- 'priority' => "Zend_Log::CRIT",
- 'operator' => "<="
- ),
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
-
- try {
- $logger = Zend_Log::factory(array('Null' => array(
- 'writerName' => 'Mock',
- 'filterName' => 'Priority',
- 'filterParams' => array(),
- )));
- } catch(Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/must be an integer/', $e->getMessage());
- }
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Filter_PriorityTest::main') {
- Zend_Log_Filter_PriorityTest::main();
-}
diff --git a/tests/Zend/Log/Filter/SuppressTest.php b/tests/Zend/Log/Filter/SuppressTest.php
deleted file mode 100644
index 96000fc91..000000000
--- a/tests/Zend/Log/Filter/SuppressTest.php
+++ /dev/null
@@ -1,97 +0,0 @@
-filter = new Zend_Log_Filter_Suppress();
- }
-
- public function testSuppressIsInitiallyOff()
- {
- $this->assertTrue($this->filter->accept(array()));
- }
-
- public function testSuppressOn()
- {
- $this->filter->suppress(true);
- $this->assertFalse($this->filter->accept(array()));
- $this->assertFalse($this->filter->accept(array()));
- }
-
- public function testSuppressOff()
- {
- $this->filter->suppress(false);
- $this->assertTrue($this->filter->accept(array()));
- $this->assertTrue($this->filter->accept(array()));
- }
-
- public function testSuppressCanBeReset()
- {
- $this->filter->suppress(true);
- $this->assertFalse($this->filter->accept(array()));
- $this->filter->suppress(false);
- $this->assertTrue($this->filter->accept(array()));
- $this->filter->suppress(true);
- $this->assertFalse($this->filter->accept(array()));
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Mock",
- 'filterName' => "Suppress"
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Filter_SuppressTest::main') {
- Zend_Log_Filter_SuppressTest::main();
-}
diff --git a/tests/Zend/Log/Formatter/AllTests.php b/tests/Zend/Log/Formatter/AllTests.php
deleted file mode 100644
index 57a2615b6..000000000
--- a/tests/Zend/Log/Formatter/AllTests.php
+++ /dev/null
@@ -1,61 +0,0 @@
-addTestSuite('Zend_Log_Formatter_FirebugTest');
- $suite->addTestSuite('Zend_Log_Formatter_SimpleTest');
- $suite->addTestSuite('Zend_Log_Formatter_XmlTest');
-
- return $suite;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Formatter_AllTests::main') {
- Zend_Log_Formatter_AllTests::main();
-}
diff --git a/tests/Zend/Log/Formatter/FirebugTest.php b/tests/Zend/Log/Formatter/FirebugTest.php
deleted file mode 100644
index 8545c249c..000000000
--- a/tests/Zend/Log/Formatter/FirebugTest.php
+++ /dev/null
@@ -1,73 +0,0 @@
- date('c'),
- 'message' => 'tottakai',
- 'priority' => 2,
- 'priorityName' => 'CRIT'
- );
- $formatter = new Zend_Log_Formatter_Firebug();
- $output = $formatter->format($event);
-
- $this->assertEquals('tottakai', $output);
- }
-
- /**
- * @group ZF-9176
- */
- public function testFactory()
- {
- $options = array();
- $formatter = Zend_Log_Formatter_Firebug::factory($options);
- $this->assertTrue($formatter instanceof Zend_Log_Formatter_Firebug);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Formatter_FirebugTest::main') {
- Zend_Log_Formatter_FirebugTest::main();
-}
diff --git a/tests/Zend/Log/Formatter/SimpleTest.php b/tests/Zend/Log/Formatter/SimpleTest.php
deleted file mode 100644
index 4381a83e7..000000000
--- a/tests/Zend/Log/Formatter/SimpleTest.php
+++ /dev/null
@@ -1,141 +0,0 @@
-fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/must be a string/i', $e->getMessage());
- }
- }
-
- public function testDefaultFormat()
- {
- $fields = array('timestamp' => 0,
- 'message' => 'foo',
- 'priority' => 42,
- 'priorityName' => 'bar');
-
- $f = new Zend_Log_Formatter_Simple();
- $line = $f->format($fields);
-
- $this->assertContains((string)$fields['timestamp'], $line);
- $this->assertContains($fields['message'], $line);
- $this->assertContains($fields['priorityName'], $line);
- $this->assertContains((string)$fields['priority'], $line);
- }
-
- function testComplexValues()
- {
- $fields = array('timestamp' => 0,
- 'priority' => 42,
- 'priorityName' => 'bar');
-
- $f = new Zend_Log_Formatter_Simple();
-
- $fields['message'] = 'Foo';
- $line = $f->format($fields);
- $this->assertContains($fields['message'], $line);
-
- $fields['message'] = 10;
- $line = $f->format($fields);
- $this->assertContains((string)$fields['message'], $line);
-
- $fields['message'] = 10.5;
- $line = $f->format($fields);
- $this->assertContains((string)$fields['message'], $line);
-
- $fields['message'] = true;
- $line = $f->format($fields);
- $this->assertContains('1', $line);
-
- $fields['message'] = fopen('php://stdout', 'w');
- $line = $f->format($fields);
- $this->assertContains('Resource id ', $line);
- fclose($fields['message']);
-
- $fields['message'] = range(1,10);
- $line = $f->format($fields);
- $this->assertContains('array', $line);
-
- $fields['message'] = new Zend_Log_Formatter_SimpleTest_TestObject1();
- $line = $f->format($fields);
- $this->assertContains($fields['message']->__toString(), $line);
-
- $fields['message'] = new Zend_Log_Formatter_SimpleTest_TestObject2();
- $line = $f->format($fields);
- $this->assertContains('object', $line);
- }
-
- /**
- * @group ZF-9176
- */
- public function testFactory()
- {
- $options = array(
- 'format' => '%timestamp% [%priority%]: %message% -- %info%'
- );
- $formatter = Zend_Log_Formatter_Simple::factory($options);
- $this->assertTrue($formatter instanceof Zend_Log_Formatter_Simple);
- }
-}
-
-class Zend_Log_Formatter_SimpleTest_TestObject1 {
-
- public function __toString()
- {
- return 'Hello World';
- }
-}
-
-class Zend_Log_Formatter_SimpleTest_TestObject2 {
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Formatter_SimpleTest::main') {
- Zend_Log_Formatter_SimpleTest::main();
-}
diff --git a/tests/Zend/Log/Formatter/XmlTest.php b/tests/Zend/Log/Formatter/XmlTest.php
deleted file mode 100644
index 21597952b..000000000
--- a/tests/Zend/Log/Formatter/XmlTest.php
+++ /dev/null
@@ -1,194 +0,0 @@
-format(array('message' => 'foo', 'priority' => 42));
-
- $this->assertContains('foo', $line);
- $this->assertContains((string)42, $line);
- }
-
- public function testConfiguringElementMapping()
- {
- $f = new Zend_Log_Formatter_Xml('log', array('foo' => 'bar'));
- $line = $f->format(array('bar' => 'baz'));
- $this->assertContains('baz', $line);
- }
-
- public function testXmlDeclarationIsStripped()
- {
- $f = new Zend_Log_Formatter_Xml();
- $line = $f->format(array('message' => 'foo', 'priority' => 42));
-
- $this->assertNotContains('<\?xml version=', $line);
- }
-
- public function testXmlValidates()
- {
- $f = new Zend_Log_Formatter_Xml();
- $line = $f->format(array('message' => 'foo', 'priority' => 42));
-
- $sxml = @simplexml_load_string($line);
- $this->assertTrue($sxml instanceof SimpleXMLElement, 'Formatted XML is invalid');
- }
-
- /**
- * @group ZF-2062
- * @group ZF-4190
- */
- public function testHtmlSpecialCharsInMessageGetEscapedForValidXml()
- {
- $f = new Zend_Log_Formatter_Xml();
- $line = $f->format(array('message' => '&key1=value1&key2=value2', 'priority' => 42));
-
- $this->assertContains("&", $line);
- $this->assertTrue(substr_count($line, "&") == 2);
- }
-
- /**
- * @group ZF-2062
- * @group ZF-4190
- */
- public function testFixingBrokenCharsSoXmlIsValid()
- {
- $f = new Zend_Log_Formatter_Xml();
- $line = $f->format(array('message' => '&', 'priority' => 42));
-
- $this->assertContains('&', $line);
- }
-
- public function testConstructorWithArray()
- {
- $options = array(
- 'rootElement' => 'log',
- 'elementMap' => array(
- 'word' => 'message',
- 'priority' => 'priority'
- )
- );
- $event = array(
- 'message' => 'tottakai',
- 'priority' => 4
- );
- $expected = 'tottakai4';
-
- $formatter = new Zend_Log_Formatter_Xml($options);
- $output = $formatter->format($event);
- $this->assertContains($expected, $output);
- $this->assertEquals('UTF-8', $formatter->getEncoding());
- }
-
- /**
- * @group ZF-9176
- */
- public function testFactory()
- {
- $options = array(
- 'rootElement' => 'log',
- 'elementMap' => array(
- 'timestamp' => 'timestamp',
- 'response' => 'message'
- )
- );
- $formatter = Zend_Log_Formatter_Xml::factory($options);
- $this->assertTrue($formatter instanceof Zend_Log_Formatter_Xml);
- }
-
- /**
- * @group ZF-11161
- */
- public function testNonScalarValuesAreExcludedFromFormattedString()
- {
- $options = array(
- 'rootElement' => 'log'
- );
- $event = array(
- 'message' => 'tottakai',
- 'priority' => 4,
- 'context' => array('test'=>'one'),
- 'reference' => new Zend_Log_Formatter_Xml()
- );
- $expected = 'tottakai4';
-
- $formatter = new Zend_Log_Formatter_Xml($options);
- $output = $formatter->format($event);
- $this->assertContains($expected, $output);
- }
-
- /**
- * @group ZF-11161
- */
- public function testObjectsWithStringSerializationAreIncludedInFormattedString()
- {
- $options = array(
- 'rootElement' => 'log'
- );
- $event = array(
- 'message' => 'tottakai',
- 'priority' => 4,
- 'context' => array('test'=>'one'),
- 'reference' => new Zend_Log_Formatter_XmlTest_SerializableObject()
- );
- $expected = 'tottakai4Zend_Log_Formatter_XmlTest_SerializableObject';
-
- $formatter = new Zend_Log_Formatter_Xml($options);
- $output = $formatter->format($event);
- $this->assertContains($expected, $output);
- }
-}
-
-class Zend_Log_Formatter_XmlTest_SerializableObject
-{
- public function __toString()
- {
- return __CLASS__;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Formatter_XmlTest::main') {
- Zend_Log_Formatter_XmlTest::main();
-}
diff --git a/tests/Zend/Log/LogTest.php b/tests/Zend/Log/LogTest.php
deleted file mode 100644
index 5646b3885..000000000
--- a/tests/Zend/Log/LogTest.php
+++ /dev/null
@@ -1,614 +0,0 @@
-log = fopen('php://memory', 'w+');
- $this->writer = new Zend_Log_Writer_Stream($this->log);
- }
-
- // Writers
-
- public function testWriterCanBeAddedWithConstructor()
- {
- $logger = new Zend_Log($this->writer);
- $logger->log($message = 'message-to-log', Zend_Log::INFO);
-
- rewind($this->log);
- $this->assertContains($message, stream_get_contents($this->log));
- }
-
- public function testAddWriter()
- {
- $logger = new Zend_Log();
- $logger->addWriter($this->writer);
- $logger->log($message = 'message-to-log', Zend_Log::INFO);
-
- rewind($this->log);
- $this->assertContains($message, stream_get_contents($this->log));
- }
-
- public function testAddWriterAddsMultipleWriters()
- {
- $logger = new Zend_Log();
-
- // create writers for two separate streams of temporary memory
- $log1 = fopen('php://memory', 'w+');
- $writer1 = new Zend_Log_Writer_Stream($log1);
- $log2 = fopen('php://memory', 'w+');
- $writer2 = new Zend_Log_Writer_Stream($log2);
-
- // add the writers
- $logger->addWriter($writer1);
- $logger->addWriter($writer2);
-
- // log to both writers
- $logger->log($message = 'message-sent-to-both-logs', Zend_Log::INFO);
-
- // verify both writers were called by the logger
- rewind($log1);
- $this->assertContains($message, stream_get_contents($log1));
- rewind($log2);
- $this->assertContains($message, stream_get_contents($log2));
-
- // prove the two memory streams are different
- // and both writers were indeed called
- fwrite($log1, 'foo');
- $this->assertNotEquals(ftell($log1), ftell($log2));
- }
-
- public function testLoggerThrowsWhenNoWriters()
- {
- $logger = new Zend_Log();
- try {
- $logger->log('message', Zend_Log::INFO);
- $this->fail();
- } catch (Zend_Log_Exception $e) {
- $this->assertRegexp('/no writer/i', $e->getMessage());
- }
- }
-
- public function testDestructorCallsShutdownOnEachWriter()
- {
- $writer1 = new Zend_Log_Writer_Mock();
- $writer2 = new Zend_Log_Writer_Mock();
-
- $logger = new Zend_Log();
- $logger->addWriter($writer1);
- $logger->addWriter($writer2);
-
- $this->assertFalse($writer1->shutdown);
- $this->assertFalse($writer2->shutdown);
-
- $logger = null;
-
- $this->assertTrue($writer1->shutdown);
- $this->assertTrue($writer2->shutdown);
- }
-
- // Priorities
-
- public function testLogThrowsOnBadLogPriority()
- {
- $logger = new Zend_Log($this->writer);
- try {
- $logger->log('foo', 42);
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/bad log priority/i', $e->getMessage());
- }
- }
-
- public function testLogThrough__callThrowsOnBadLogPriority()
- {
- $logger = new Zend_Log($this->writer);
- try {
- $logger->nonexistantPriority('');
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/bad log priority/i', $e->getMessage());
- }
- }
-
- public function testAddingPriorityThrowsWhenOverridingBuiltinLogPriority()
- {
- try {
- $logger = new Zend_Log($this->writer);
- $logger->addPriority('BOB', 0);
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/existing priorities/i', $e->getMessage());
- }
-
- }
-
- public function testAddLogPriority()
- {
- $logger = new Zend_Log($this->writer);
- $logger->addPriority('EIGHT', $priority = 8);
-
- $logger->eight($message = 'eight message');
-
- rewind($this->log);
- $logdata = stream_get_contents($this->log);
- $this->assertContains((string)$priority, $logdata);
- $this->assertContains($message, $logdata);
- }
-
- // Fields
-
- public function testLogWritesStandardFields() {
- $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock);
- $logger->info('foo');
-
- $this->assertEquals(1, count($mock->events));
- $event = array_shift($mock->events);
-
- $standardFields = array_flip(array('timestamp', 'priority', 'priorityName', 'message'));
- $this->assertEquals(array(), array_diff_key($event, $standardFields));
- }
-
- public function testLogWritesAndOverwritesExtraFields() {
- $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock);
- $logger->setEventItem('foo', 42);
- $logger->setEventItem($field = 'bar', $value = 43);
- $logger->info('foo');
-
- $this->assertEquals(1, count($mock->events));
- $event = array_shift($mock->events);
-
- $this->assertTrue(array_key_exists($field, $event));
- $this->assertEquals($value, $event[$field]);
- }
-
- /**
- * @group ZF-8491
- */
- public function testLogAcceptsExtrasParameterAsArrayAndPushesIntoEvent()
- {
- $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock);
- $logger->info('foo', array('content' => 'nonesuch'));
- $event = array_shift($mock->events);
- $this->assertContains('content', array_keys($event));
- $this->assertEquals('nonesuch', $event['content']);
- }
-
- /**
- * @group ZF-8491
- */
- public function testLogNumericKeysInExtrasArrayArePassedToInfoKeyOfEvent()
- {
- $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock);
- $logger->info('foo', array('content' => 'nonesuch', 'bar'));
- $event = array_shift($mock->events);
- $this->assertContains('content', array_keys($event));
- $this->assertContains('info', array_keys($event));
- $this->assertContains('bar', $event['info']);
- }
-
- /**
- * @group ZF-8491
- */
- public function testLogAcceptsExtrasParameterAsScalarAndAddsAsInfoKeyToEvent()
- {
- $logger = new Zend_Log($mock = new Zend_Log_Writer_Mock);
- $logger->info('foo', 'nonesuch');
- $event = array_shift($mock->events);
- $this->assertContains('info', array_keys($event));
- $info = $event['info'];
- $this->assertContains('nonesuch', $info);
- }
-
- // Factory
-
- public function testLogConstructFromConfigStream()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Stream",
- 'writerNamespace' => "Zend_Log_Writer",
- 'writerParams' => array(
- 'stream' => "php://memory"
- )
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- public function testLogConstructFromConfigStreamAndFilter()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Stream",
- 'writerNamespace' => "Zend_Log_Writer",
- 'writerParams' => array(
- 'stream' => "php://memory"
- ),
- 'filterName' => "Priority",
- 'filterParams' => array(
- 'priority' => "Zend_Log::CRIT",
- 'operator' => "<="
- ),
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- public function testFactoryUsesNameAndNamespaceWithoutModifications()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "ZendMonitor",
- 'writerNamespace' => "Zend_Log_Writer",
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- /**
- * @group ZF-9192
- */
- public function testUsingWithErrorHandler()
- {
- $writer = new Zend_Log_Writer_Mock();
-
- $logger = new Zend_Log();
- $logger->addWriter($writer);
- $this->errWriter = $writer;
-
-
- $oldErrorLevel = error_reporting();
-
- $this->expectingLogging = true;
- error_reporting(E_ALL | E_STRICT);
-
- $oldHandler = set_error_handler(array($this, 'verifyHandlerData'));
- $logger->registerErrorHandler();
-
- trigger_error("Testing notice shows up in logs", E_USER_NOTICE);
- trigger_error("Testing warning shows up in logs", E_USER_WARNING);
- trigger_error("Testing error shows up in logs", E_USER_ERROR);
-
- $this->expectingLogging = false;
- error_reporting(0);
-
- trigger_error("Testing notice misses logs", E_USER_NOTICE);
- trigger_error("Testing warning misses logs", E_USER_WARNING);
- trigger_error("Testing error misses logs", E_USER_ERROR);
-
- restore_error_handler(); // Pop off the Logger
- restore_error_handler(); // Pop off the verifyHandlerData
- error_reporting($oldErrorLevel); // Restore original reporting level
- unset($this->errWriter);
- }
-
- /**
- * @group ZF-9192
- * Used by testUsingWithErrorHandler -
- * verifies that the data written to the original logger is the same as the data written in Zend_Log
- */
- public function verifyHandlerData($errno, $errstr, $errfile, $errline, $errcontext)
- {
- if ($this->expectingLogging) {
- $this->assertFalse(empty($this->errWriter->events));
- $event = array_shift($this->errWriter->events);
- $this->assertEquals($errstr, $event['message']);
- $this->assertEquals($errno, $event['errno']);
- $this->assertEquals($errfile, $event['file']);
- $this->assertEquals($errline, $event['line']);
- } else {
- $this->assertTrue(empty($this->errWriter->events));
- }
- }
-
- /**
- * @group ZF-9870
- */
- public function testSetAndGetTimestampFormat()
- {
- $logger = new Zend_Log($this->writer);
- $this->assertEquals('c', $logger->getTimestampFormat());
- $this->assertSame($logger, $logger->setTimestampFormat('Y-m-d H:i:s'));
- $this->assertEquals('Y-m-d H:i:s', $logger->getTimestampFormat());
- }
-
- /**
- * @group ZF-9870
- */
- public function testLogWritesWithModifiedTimestampFormat()
- {
- $logger = new Zend_Log($this->writer);
- $logger->setTimestampFormat('Y-m-d');
- $logger->debug('ZF-9870');
- rewind($this->log);
- $message = stream_get_contents($this->log);
- $this->assertEquals(date('Y-m-d'), substr($message, 0, 10));
- }
-
- /**
- * @group ZF-9955
- */
- public function testExceptionConstructWriterFromConfig()
- {
- try {
- $logger = new Zend_Log();
- $writer = array('writerName' => 'NotExtendedWriterAbstract');
- $logger->addWriter($writer);
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('#^(Zend_Log_Writer_NotExtendedWriterAbstract|The\sspecified\swriter)#', $e->getMessage());
- }
- }
-
- /**
- * @group ZF-9956
- */
- public function testExceptionConstructFilterFromConfig()
- {
- try {
- $logger = new Zend_Log();
- $filter = array('filterName' => 'NotImplementsFilterInterface');
- $logger->addFilter($filter);
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('#^(Zend_Log_Filter_NotImplementsFilterInterface|The\sspecified\sfilter)#', $e->getMessage());
- }
- }
-
- /**
- * @group ZF-8953
- */
- public function testFluentInterface()
- {
- $logger = new Zend_Log();
- $instance = $logger->addPriority('all', 8)
- ->addFilter(1)
- ->addWriter(array('writerName' => 'Null'))
- ->setEventItem('os', PHP_OS);
-
- $this->assertTrue($instance instanceof Zend_Log);
- }
-
- /**
- * @group ZF-10170
- */
- public function testPriorityDuplicates()
- {
- $logger = new Zend_Log();
- $mock = new Zend_Log_Writer_Mock();
- $logger->addWriter($mock);
- try {
- $logger->addPriority('emerg', 8);
- $this->fail();
- } catch(Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertEquals('Existing priorities cannot be overwritten', $e->getMessage());
- }
-
- try {
- $logger->log('zf10170', 0);
- $logger->log('clone zf10170', 8);
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertEquals('Bad log priority', $e->getMessage());
- }
- $this->assertEquals(0, $mock->events[0]['priority']);
- $this->assertEquals('EMERG', $mock->events[0]['priorityName']);
- $this->assertFalse(array_key_exists(1, $mock->events));
- }
-
- /**
- * @group ZF-9176
- */
- public function testLogConstructFromConfigFormatter()
- {
- $config = array(
- 'log' => array(
- 'test' => array(
- 'writerName' => 'Mock',
- 'formatterName' => 'Simple',
- 'formatterParams' => array(
- 'format' => '%timestamp% (%priorityName%): %message%'
- )
- )
- )
- );
-
- $logger = Zend_Log::factory($config['log']);
- $logger->log('custom message', Zend_Log::INFO);
- }
-
- /**
- * @group ZF-9176
- */
- public function testLogConstructFromConfigCustomFormatter()
- {
- $config = array(
- 'log' => array(
- 'test' => array(
- 'writerName' => 'Mock',
- 'formatterName' => 'Mock',
- 'formatterNamespace' => 'Custom_Formatter'
- )
- )
- );
-
- $logger = Zend_Log::factory($config['log']);
- $logger->log('custom message', Zend_Log::INFO);
- }
-
- /**
- * @group ZF-10990
- */
- public function testFactoryShouldSetTimestampFormat()
- {
- $config = array(
- 'timestampFormat' => 'Y-m-d',
- 'mock' => array(
- 'writerName' => 'Mock'
- )
- );
- $logger = Zend_Log::factory($config);
-
- $this->assertEquals('Y-m-d', $logger->getTimestampFormat());
- }
-
- /**
- * @group ZF-10990
- */
- public function testFactoryShouldKeepDefaultTimestampFormat()
- {
- $config = array(
- 'timestampFormat' => '',
- 'mock' => array(
- 'writerName' => 'Mock'
- )
- );
- $logger = Zend_Log::factory($config);
-
- $this->assertEquals('c', $logger->getTimestampFormat());
- }
-
- public function testFactorySupportsPHP53Namespaces()
- {
- // preload namespaced class from custom path
- Zend_Loader::loadClass('\Zfns\Writer', array(dirname(__FILE__) . '/_files'));
-
- try {
- $config = array(
- 'mine' => array(
- 'writerName' => 'Writer',
- 'writerNamespace' => '\Zfns\\',
- )
- );
-
- $logger = Zend_log::factory($config);
- $logger->info('this is a test');
-
- } catch (Zend_Log_Exception $e) {
- $this->fail('Unable to load namespaced class');
- }
- }
-
- /**
- * @group #85
- */
- public function testZendLogCanBeExtendedWhenUsingFactory()
- {
- $writer = new Zend_Log_Writer_Null();
- $log = ZLTest_My_Log::factory(
- array(
- 'writerName' => $writer,
- 'className' => 'ZLTest_My_Log'
- )
- );
- $this->assertTrue($log instanceof ZLTest_My_Log);
- }
-
- /**
- * @expectedException Zend_Log_Exception
- */
- public function testZendLogThrowsAnExceptionWhenPassingIncorrectClassToFactory()
- {
- $writer = new Zend_Log_Writer_Null();
- ZLTest_My_Log::factory(
- array(
- 'writerName' => $writer,
- 'className' => 'ZLTest_My_LogNotExtending'
- )
- );
- }
-}
-
-class Zend_Log_Writer_NotExtendedWriterAbstract implements Zend_Log_FactoryInterface
-{
- public static function factory($config)
- {
- }
-}
-
-class Zend_Log_Filter_NotImplementsFilterInterface implements Zend_Log_FactoryInterface
-{
- public static function factory($config)
- {
- }
-}
-
-class Custom_Formatter_Mock extends Zend_Log_Formatter_Abstract
-{
- public static function factory($config)
- {
- return new self;
- }
-
- public function format($event)
- {
- }
-}
-
-/**
- * Helper classes for testZendLogCanBeExtendedWhenUsingFactory()
- *
- * @group #85
- */
-class ZLTest_My_Log extends Zend_Log {}
-class ZLTest_My_LogNotExtending {}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_LogTest::main') {
- Zend_Log_LogTest::main();
-}
diff --git a/tests/Zend/Log/Writer/AbstractTest.php b/tests/Zend/Log/Writer/AbstractTest.php
deleted file mode 100644
index 670100f06..000000000
--- a/tests/Zend/Log/Writer/AbstractTest.php
+++ /dev/null
@@ -1,106 +0,0 @@
-_writer = new Zend_Log_Writer_AbstractTest_Concrete();
- }
-
- /**
- * @group ZF-6085
- */
- public function testSetFormatter()
- {
- if (PHP_VERSION_ID >= 70000) {
- $this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+');
- }
-
- // require_once 'Zend/Log/Formatter/Simple.php';
- $this->_writer->setFormatter(new Zend_Log_Formatter_Simple());
- $this->setExpectedException('PHPUnit_Framework_Error');
- $this->_writer->setFormatter(new StdClass());
- }
-
- public function testAddFilter()
- {
- $this->_writer->addFilter(1);
- // require_once 'Zend/Log/Filter/Message.php';
- $this->_writer->addFilter(new Zend_Log_Filter_Message('/mess/'));
- $this->setExpectedException('Zend_Log_Exception');
- $this->_writer->addFilter(new StdClass());
- }
-
- /**
- * @group ZF-8953
- */
- public function testFluentInterface()
- {
- // require_once 'Zend/Log/Formatter/Simple.php';
- $instance = $this->_writer->addFilter(1)
- ->setFormatter(new Zend_Log_Formatter_Simple());
-
- $this->assertTrue($instance instanceof Zend_Log_Writer_AbstractTest_Concrete);
- }
-}
-
-class Zend_Log_Writer_AbstractTest_Concrete extends Zend_Log_Writer_Abstract
-{
- protected function _write($event)
- {
- }
-
- static public function factory($config)
- {
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_AbstractTest::main') {
- Zend_Log_Writer_AbstractTest::main();
-}
diff --git a/tests/Zend/Log/Writer/AllTests.php b/tests/Zend/Log/Writer/AllTests.php
deleted file mode 100644
index 42772e37f..000000000
--- a/tests/Zend/Log/Writer/AllTests.php
+++ /dev/null
@@ -1,77 +0,0 @@
-addTestSuite('Zend_Log_Writer_AbstractTest');
- $suite->addTestSuite('Zend_Log_Writer_DbTest');
- if (PHP_OS != 'AIX') {
- $suite->addTestSuite('Zend_Log_Writer_FirebugTest');
- }
- $suite->addTestSuite('Zend_Log_Writer_MailTest');
- $suite->addTestSuite('Zend_Log_Writer_MockTest');
- $suite->addTestSuite('Zend_Log_Writer_NullTest');
- $suite->addTestSuite('Zend_Log_Writer_StreamTest');
- $suite->addTestSuite('Zend_Log_Writer_SyslogTest');
- $suite->addTestSuite('Zend_Log_Writer_ZendMonitorTest');
-
- return $suite;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_AllTests::main') {
- Zend_Log_Writer_AllTests::main();
-}
diff --git a/tests/Zend/Log/Writer/DbTest.php b/tests/Zend/Log/Writer/DbTest.php
deleted file mode 100644
index 843351bfd..000000000
--- a/tests/Zend/Log/Writer/DbTest.php
+++ /dev/null
@@ -1,243 +0,0 @@
-tableName = 'db-table-name';
-
- $this->db = new Zend_Log_Writer_DbTest_MockDbAdapter();
- $this->writer = new Zend_Log_Writer_Db($this->db, $this->tableName);
- }
-
- public function testFormattingIsNotSupported()
- {
- try {
- // require_once 'Zend/Log/Formatter/Simple.php';
- $this->writer->setFormatter(new Zend_Log_Formatter_Simple());
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/does not support formatting/i', $e->getMessage());
- }
- }
-
- public function testWriteWithDefaults()
- {
- // log to the mock db adapter
- $fields = array('message' => 'foo',
- 'priority' => 42);
-
- $this->writer->write($fields);
-
- // insert should be called once...
- $this->assertContains('insert', array_keys($this->db->calls));
- $this->assertEquals(1, count($this->db->calls['insert']));
-
- // ...with the correct table and binds for the database
- $binds = array('message' => $fields['message'],
- 'priority' => $fields['priority']);
- $this->assertEquals(array($this->tableName, $binds),
- $this->db->calls['insert'][0]);
- }
-
- public function testWriteUsesOptionalCustomColumnNames()
- {
- $this->writer = new Zend_Log_Writer_Db($this->db, $this->tableName,
- array('new-message-field' => 'message',
- 'new-message-field' => 'priority'));
-
- // log to the mock db adapter
- $message = 'message-to-log';
- $priority = 2;
- $this->writer->write(array('message' => $message, 'priority' => $priority));
-
- // insert should be called once...
- $this->assertContains('insert', array_keys($this->db->calls));
- $this->assertEquals(1, count($this->db->calls['insert']));
-
- // ...with the correct table and binds for the database
- $binds = array('new-message-field' => $message,
- 'new-message-field' => $priority);
- $this->assertEquals(array($this->tableName, $binds),
- $this->db->calls['insert'][0]);
- }
-
- public function testShutdownRemovesReferenceToDatabaseInstance()
- {
- $this->writer->write(array('message' => 'this should not fail'));
- $this->writer->shutdown();
-
- try {
- $this->writer->write(array('message' => 'this should fail'));
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertEquals('Database adapter is null', $e->getMessage());
- }
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Db",
- 'writerParams' => array(
- 'db' => $this->db,
- 'table' => $this->tableName,
- ),
- )));
-
- // require_once 'Zend/Log.php';
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- /**
- * @group ZF-10089
- */
- public function testThrowStrictSetFormatter()
- {
- if (PHP_VERSION_ID >= 70000) {
- $this->markTestSkipped('Invalid typehinting is PHP Fatal error in PHP7+');
- }
-
- try {
- $this->writer->setFormatter(new StdClass());
- } catch (Exception $e) {
- $this->assertTrue($e instanceof PHPUnit_Framework_Error);
- $this->assertContains('must implement interface', $e->getMessage());
- }
- }
-
- /**
- * @group ZF-12514
- */
- public function testWriteWithExtraInfos()
- {
- // Init writer
- $this->writer = new Zend_Log_Writer_Db(
- $this->db, $this->tableName,
- array(
- 'message-field' => 'message',
- 'priority-field' => 'priority',
- 'info-field' => 'info',
- )
- );
-
- // Log
- $message = 'message-to-log';
- $priority = 2;
- $info = 'extra-info';
- $this->writer->write(
- array(
- 'message' => $message,
- 'priority' => $priority,
- 'info' => $info,
- )
- );
-
- // Test
- $binds = array(
- 'message-field' => $message,
- 'priority-field' => $priority,
- 'info-field' => $info,
- );
- $this->assertEquals(
- array($this->tableName, $binds),
- $this->db->calls['insert'][0]
- );
- }
-
- /**
- * @group ZF-12514
- */
- public function testWriteWithoutExtraInfos()
- {
- // Init writer
- $this->writer = new Zend_Log_Writer_Db(
- $this->db, $this->tableName,
- array(
- 'message-field' => 'message',
- 'priority-field' => 'priority',
- 'info-field' => 'info',
- )
- );
-
- // Log
- $message = 'message-to-log';
- $priority = 2;
- $this->writer->write(
- array(
- 'message' => $message,
- 'priority' => $priority,
- )
- );
-
- // Test
- $binds = array(
- 'message-field' => $message,
- 'priority-field' => $priority,
- );
- $this->assertEquals(
- array($this->tableName, $binds),
- $this->db->calls['insert'][0]
- );
- }
-}
-
-
-class Zend_Log_Writer_DbTest_MockDbAdapter
-{
- public $calls = array();
-
- public function __call($method, $params)
- {
- $this->calls[$method][] = $params;
- }
-
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_DbTest::main') {
- Zend_Log_Writer_DbTest::main();
-}
diff --git a/tests/Zend/Log/Writer/FirebugTest.php b/tests/Zend/Log/Writer/FirebugTest.php
deleted file mode 100644
index fb5e628bd..000000000
--- a/tests/Zend/Log/Writer/FirebugTest.php
+++ /dev/null
@@ -1,421 +0,0 @@
-resetInstance();
-
- $this->_request = new Zend_Log_Writer_FirebugTest_Request();
- $this->_response = new Zend_Log_Writer_FirebugTest_Response();
-
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $channel->setRequest($this->_request);
- $channel->setResponse($this->_response);
-
- $this->_writer = new Zend_Log_Writer_Firebug();
-
- // Explicitly enable writer as it is disabled by default
- // when running from the command line.
- $this->_writer->setEnabled(true);
-
- $this->_logger = new Zend_Log($this->_writer);
-
- Zend_Wildfire_Plugin_FirePhp::getInstance()->setOption('includeLineNumbers', false);
- }
-
- public function tearDown()
- {
- Zend_Wildfire_Channel_HttpHeaders::destroyInstance();
- Zend_Wildfire_Plugin_FirePhp::destroyInstance();
- }
-
-
- /**
- * Test for ZF-3960
- *
- * Zend_Log_Writer_Firebug should be automatically disabled when
- * run from the command line
- */
- public function testZf3960()
- {
- Zend_Wildfire_Channel_HttpHeaders::destroyInstance();
- Zend_Wildfire_Plugin_FirePhp::destroyInstance();
-
- $log = new Zend_Log();
- $writerFirebug = new Zend_Log_Writer_Firebug();
- $log->addWriter($writerFirebug);
- $log->log('hi', 2);
- }
-
- /**
- * @group ZF-4952
- */
- public function testSetFormatter()
- {
- $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance();
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $this->_logger->log('Test Message 1', Zend_Log::INFO);
-
- $formatter = new Zend_Log_Writer_FirebugTest_Formatter();
- $this->_writer->setFormatter($formatter);
-
- $this->_logger->setEventItem('testLabel','Test Label');
-
- $this->_logger->log('Test Message 2', Zend_Log::INFO);
-
- $messages = $protocol->getMessages();
-
- $message = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE]
- [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI]
- [0];
-
- $this->assertEquals($message,
- '[{"Type":"INFO"},"Test Message 1"]');
-
- $message = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE]
- [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI]
- [1];
-
- $this->assertEquals($message,
- '[{"Type":"INFO"},"Test Label : Test Message 2"]');
- }
-
- /**
- * @group ZF-4952
- */
- public function testEventItemLabel()
- {
- $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance();
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
-
- $this->_logger->log('Test Message 1', Zend_Log::INFO);
-
- $this->_logger->setEventItem('firebugLabel','Test Label');
-
- $this->_logger->log('Test Message 2', Zend_Log::INFO);
-
- $messages = $protocol->getMessages();
-
- $message = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE]
- [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI]
- [0];
-
- $this->assertEquals($message,
- '[{"Type":"INFO"},"Test Message 1"]');
-
- $message = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE]
- [Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI]
- [1];
-
- $this->assertEquals($message,
- '[{"Type":"INFO","Label":"Test Label"},"Test Message 2"]');
- }
-
- public function testLogStyling()
- {
- $this->assertEquals($this->_writer->getDefaultPriorityStyle(),
- Zend_Wildfire_Plugin_FirePhp::LOG);
- $this->assertEquals($this->_writer->setDefaultPriorityStyle(Zend_Wildfire_Plugin_FirePhp::WARN),
- Zend_Wildfire_Plugin_FirePhp::LOG);
- $this->assertEquals($this->_writer->getDefaultPriorityStyle(),
- Zend_Wildfire_Plugin_FirePhp::WARN);
-
- $this->assertEquals($this->_writer->getPriorityStyle(9),
- false);
- $this->assertEquals($this->_writer->setPriorityStyle(9,Zend_Wildfire_Plugin_FirePhp::WARN),
- true);
- $this->assertEquals($this->_writer->getPriorityStyle(9),
- Zend_Wildfire_Plugin_FirePhp::WARN);
- $this->assertEquals($this->_writer->setPriorityStyle(9,Zend_Wildfire_Plugin_FirePhp::LOG),
- Zend_Wildfire_Plugin_FirePhp::WARN);
- }
-
- public function testBasicLogging()
- {
- $message = 'This is a log message!';
-
- $this->_logger->log($message, Zend_Log::INFO);
-
- Zend_Wildfire_Channel_HttpHeaders::getInstance()->flush();
-
- $headers = array();
- $headers['X-Wf-Protocol-1'] = 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2';
- $headers['X-Wf-1-Structure-1'] = 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1';
- $headers['X-Wf-1-Plugin-1'] = 'http://meta.firephp.org/Wildfire/Plugin/ZendFramework/FirePHP/1.6.2';
- $headers['X-Wf-1-1-1-1'] = '42|[{"Type":"INFO"},"This is a log message!"]|';
-
- $this->assertTrue($this->_response->verifyHeaders($headers));
- }
-
-
- /**
- * @group ZF-4934
- */
- public function testAdvancedLogging()
- {
- Zend_Wildfire_Plugin_FirePhp::getInstance()->setOption('maxTraceDepth',0);
-
- $message = 'This is a log message!';
- $label = 'Test Label';
- $table = array('Summary line for the table',
- array(
- array('Column 1', 'Column 2'),
- array('Row 1 c 1',' Row 1 c 2'),
- array('Row 2 c 1',' Row 2 c 2')
- )
- );
-
-
- $this->_logger->addPriority('TRACE', 8);
- $this->_logger->addPriority('TABLE', 9);
- $this->_writer->setPriorityStyle(8, 'TRACE');
- $this->_writer->setPriorityStyle(9, 'TABLE');
-
- $this->_logger->trace($message);
- $this->_logger->table($table);
-
- try {
- throw new Exception('Test Exception');
- } catch (Exception $e) {
- $this->_logger->err($e);
- }
-
- try {
- Zend_Wildfire_Plugin_FirePhp::send($message, $label, 'UNKNOWN');
- $this->fail('Should not be able to log with undefined log style');
- } catch (Exception $e) {
- // success
- }
-
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
-
- $messages = array(Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE=>
- array(Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI=>
- array(1=>'[{"Type":"TABLE"},["Summary line for the table",[["Column 1","Column 2"],["Row 1 c 1"," Row 1 c 2"],["Row 2 c 1"," Row 2 c 2"]]]]')));
-
- $qued_messages = $protocol->getMessages();
-
- unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][0]);
- unset($qued_messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI][2]);
-
- $this->assertEquals(serialize($qued_messages),
- serialize($messages));
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Firebug"
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- /**
- * @group ZF-10537
- */
- public function testFileLineOffsets()
- {
- $firephp = Zend_Wildfire_Plugin_FirePhp::getInstance();
- $channel = Zend_Wildfire_Channel_HttpHeaders::getInstance();
- $protocol = $channel->getProtocol(Zend_Wildfire_Plugin_FirePhp::PROTOCOL_URI);
- $firephp->setOption('includeLineNumbers', true);
- $firephp->setOption('maxTraceDepth', 0);
-
- $lines = array();
- // NOTE: Do NOT separate the following pairs otherwise the line numbers will not match for the test
-
- // Message number: 1
- $lines[] = __LINE__+1;
- $this->_logger->log('Hello World', Zend_Log::INFO);
-
- // Message number: 2
- $this->_logger->addPriority('TRACE', 8);
- $this->_writer->setPriorityStyle(8, 'TRACE');
- $lines[] = __LINE__+1;
- $this->_logger->trace('Trace to here');
-
- // Message number: 3
- $this->_logger->addPriority('TABLE', 9);
- $this->_writer->setPriorityStyle(9, 'TABLE');
- $table = array('Summary line for the table',
- array(
- array('Column 1', 'Column 2'),
- array('Row 1 c 1',' Row 1 c 2'),
- array('Row 2 c 1',' Row 2 c 2')
- )
- );
- $lines[] = __LINE__+1;
- $this->_logger->table($table);
-
- // Message number: 4
- $lines[] = __LINE__+1;
- $this->_logger->info('Hello World');
-
- $messages = $protocol->getMessages();
- $messages = $messages[Zend_Wildfire_Plugin_FirePhp::STRUCTURE_URI_FIREBUGCONSOLE][Zend_Wildfire_Plugin_FirePhp::PLUGIN_URI];
-
- for( $i=0 ; $ifail("File and line does not match for message number: " . ($i+1));
- }
-
- }
- }
-}
-
-class Zend_Log_Writer_FirebugTest_Formatter extends Zend_Log_Formatter_Firebug
-{
- public function format($event)
- {
- return $event['testLabel'].' : '.$event['message'];
- }
-}
-
-
-class Zend_Log_Writer_FirebugTest_Request extends Zend_Controller_Request_Http
-{
- public function getHeader($header)
- {
- if ($header == 'User-Agent') {
- return 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.14) Gecko/20080404 Firefox/2.0.0.14 FirePHP/0.1.0';
- }
- }
-}
-
-
-class Zend_Log_Writer_FirebugTest_Response extends Zend_Controller_Response_Http
-{
-
- public function canSendHeaders($throw = false)
- {
- return true;
- }
-
- public function verifyHeaders($headers)
- {
-
- $response_headers = $this->getHeaders();
- if (!$response_headers) {
- return false;
- }
-
- $keys1 = array_keys($headers);
- sort($keys1);
- $keys1 = serialize($keys1);
-
- $keys2 = array();
- foreach ($response_headers as $header ) {
- $keys2[] = $header['name'];
- }
- sort($keys2);
- $keys2 = serialize($keys2);
-
- if ($keys1 != $keys2) {
- return false;
- }
-
- $values1 = array_values($headers);
- sort($values1);
- $values1 = serialize($values1);
-
- $values2 = array();
- foreach ($response_headers as $header ) {
- $values2[] = $header['value'];
- }
- sort($values2);
- $values2 = serialize($values2);
-
- if ($values1 != $values2) {
- return false;
- }
-
- return true;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_FirebugTest::main') {
- Zend_Log_Writer_FirebugTest::main();
-}
diff --git a/tests/Zend/Log/Writer/MailTest.php b/tests/Zend/Log/Writer/MailTest.php
deleted file mode 100644
index 937d53967..000000000
--- a/tests/Zend/Log/Writer/MailTest.php
+++ /dev/null
@@ -1,528 +0,0 @@
-_transport = $this->getMockForAbstractClass(
- 'Zend_Mail_Transport_Abstract',
- array()
- );
- Zend_Mail::setDefaultTransport($this->_transport);
- }
-
- protected function tearDown()
- {
- Zend_Mail::clearDefaultTransport();
- }
-
- /**
- * Tests normal logging, but with multiple messages for a level.
- *
- * @return void
- */
- public function testNormalLoggingMultiplePerLevel()
- {
- list(, , $log) = $this->_getSimpleLogger();
- $log->info('an info message');
- $log->info('a second info message');
- }
-
- /**
- * Tests normal logging without use of Zend_Layout.
- *
- * @return void
- */
- public function testNormalLoggingNoLayout()
- {
- list(, , $log) = $this->_getSimpleLogger();
- $log->info('an info message');
- $log->warn('a warning message');
- }
-
- /**
- * Tests normal logging with Zend_Layout usage.
- *
- * @return void
- */
- public function testNormalLoggingWithLayout()
- {
- list(, , $log) = $this->_getSimpleLogger(true);
- $log->info('an info message');
- $log->warn('a warning message');
- }
-
- /**
- * Tests normal logging with Zend_Layout and a custom formatter for it.
- *
- * @return void
- */
- public function testNormalLoggingWithLayoutAndItsFormatter()
- {
- list(, $writer, $log) = $this->_getSimpleLogger(true);
-
- // Since I'm using Zend_Layout, I should be able to set a formatter
- // for it.
- $writer->setLayoutFormatter(new Zend_Log_Formatter_Simple());
-
- // Log some messages to cover those cases.
- $log->info('an info message');
- $log->warn('a warning message');
- }
-
- /**
- * Tests normal logging with use of Zend_Layout, a custom formatter, and
- * subject prepend text.
- *
- * @return void
- */
- public function testNormalLoggingWithLayoutFormatterAndSubjectPrependText()
- {
- list(, $writer, $log) = $this->_getSimpleLogger(true);
- $writer->setLayoutFormatter(new Zend_Log_Formatter_Simple());
- $return = $writer->setSubjectPrependText('foo');
-
- $this->assertSame($writer, $return);
-
- // Log some messages to cover those cases.
- $log->info('an info message');
- $log->warn('a warning message');
- }
-
- /**
- * Tests setting of subject prepend text.
- *
- * @return void
- */
- public function testSetSubjectPrependTextNormal()
- {
- list($mail, $writer, $log) = $this->_getSimpleLogger();
-
- $return = $writer->setSubjectPrependText('foo');
-
- // Ensure that fluent interface is present.
- $this->assertSame($writer, $return);
- }
-
- /**
- * Tests that the subject prepend text can't be set if the Zend_Mail
- * object already has a subject line set.
- *
- * @return void
- */
- public function testSetSubjectPrependTextPreExisting()
- {
- list($mail, $writer, $log) = $this->_getSimpleLogger();
-
- // Expect a Zend_Log_Exception because the subject prepend text cannot
- // be set of the Zend_Mail object already has a subject line set.
- $this->setExpectedException('Zend_Log_Exception');
-
- // Set a subject line so the setSubjectPrependText() call triggers an
- // exception.
- $mail->setSubject('a pre-existing subject line');
-
- $writer->setSubjectPrependText('foo');
- }
-
- /**
- * Tests basic fluent interface for setting layout formatter.
- *
- * @return void
- */
- public function testSetLayoutFormatter()
- {
- list(, $writer) = $this->_getSimpleLogger(true);
- $return = $writer->setLayoutFormatter(new Zend_Log_Formatter_Simple());
- $this->assertSame($writer, $return);
- }
-
- /**
- * Tests that the layout formatter can be set and retrieved.
- *
- * @return void
- */
- public function testGetLayoutFormatter()
- {
- list(, $writer) = $this->_getSimpleLogger(true);
- $formatter = new Zend_Log_Formatter_Simple();
-
- // Ensure that fluent interface is present.
- $returnedWriter = $writer->setLayoutFormatter($formatter);
- $this->assertSame($writer, $returnedWriter);
-
- // Ensure that the getter returns the same formatter.
- $returnedFormatter = $writer->getLayoutFormatter();
- $this->assertSame($formatter, $returnedFormatter);
- }
-
- /**
- * Tests setting of the layout formatter when Zend_Layout is not being
- * used.
- *
- * @return void
- */
- public function testSetLayoutFormatterWithoutLayout()
- {
- list(, $writer) = $this->_getSimpleLogger();
-
- // If Zend_Layout is not being used, a formatter cannot be set for it.
- $this->setExpectedException('Zend_Log_Exception');
- $writer->setLayoutFormatter(new Zend_Log_Formatter_Simple());
- }
-
- /**
- * Tests destruction of the Zend_Log instance when an error message entry
- * is in place, but the mail can't be sent. Should result in a warning,
- * which we test for here.
- *
- * @return void
- */
- public function testDestructorMailError()
- {
- list($mail, $writer, $log) = $this->_getSimpleLogger(false);
-
- // Force the send() method to throw the same exception that would be
- // thrown if, say, the SMTP server couldn't be contacted.
- $mail->expects($this->any())
- ->method('send')
- ->will($this->throwException(new Zend_Mail_Transport_Exception()));
-
- // Log an error message so that there's something to send via email.
- $log->err('a bogus error message to force mail sending');
-
- try {
- unset($log);
- } catch (Exception $e) {
- $this->assertTrue($e instanceof PHPUnit_Framework_Error);
- }
- }
-
- /**
- * Tests destruction of the Zend_Log instance when an error message entry
- * is in place, but the layout can't be rendered. Should result in a
- * notice, which we test for here.
- *
- * @return void
- */
- public function testDestructorLayoutError()
- {
- list($mail, $writer, $log, $layout) = $this->_getSimpleLogger(true);
-
- // Force the render() method to throw the same exception that would
- // be thrown if, say, the layout template file couldn't be found.
- $layout->expects($this->any())
- ->method('render')
- ->will($this->throwException(new Zend_View_Exception('bogus message')));
-
- // Log an error message so that there's something to send via email.
- $log->err('a bogus error message to force mail sending');
-
- try {
- unset($log);
- } catch (Exception $e) {
- $this->assertTrue($e instanceof PHPUnit_Framework_Error);
- }
- }
-
- /**
- * @group ZF-8953
- */
- public function testFluentInterface()
- {
- // require_once 'Zend/Log/Formatter/Simple.php';
- list(, $writer) = $this->_getSimpleLogger(true);
- $instance = $writer->setLayoutFormatter(new Zend_Log_Formatter_Simple())
- ->setSubjectPrependText('subject');
-
- $this->assertTrue($instance instanceof Zend_Log_Writer_Mail);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactory()
- {
- $config = array(
- 'from' => array(
- 'email' => 'log@test.framework.zend.com'
- ),
- 'to' => 'admin@domain.com',
- 'subject' => '[error] exceptions on my application'
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $this->assertTrue($writer instanceof Zend_Log_Writer_Mail);
-
- $writer->write($this->_getEvent());
- $writer->shutdown();
-
- $this->assertEquals('admin@domain.com', $this->_transport->recipients);
- $this->assertContains('an info message', $this->_transport->body);
- $this->assertContains('From: log@test.framework.zend.com', $this->_transport->header);
- $this->assertContains('To: admin@domain.com', $this->_transport->header);
- $this->assertContains('Subject: [error] exceptions on my application', $this->_transport->header);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryShouldSetSubjectPrependText()
- {
- $config = array(
- 'subjectPrependText' => '[error] exceptions on my application'
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $writer->write($this->_getEvent());
- $writer->shutdown();
-
- $this->assertContains('Subject: [error] exceptions on my application (INFO=1)', $this->_transport->header);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryShouldAcceptCustomMailClass()
- {
- $this->getMock('Zend_Mail', array(), array(), 'Zend_Stub_Mail_Custom');
- $config = array(
- 'class' => 'Zend_Stub_Mail_Custom'
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $this->assertTrue($writer instanceof Zend_Log_Writer_Mail);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryShouldSetCharsetForMail()
- {
- $config = array(
- 'charset' => 'UTF-8'
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $writer->write($this->_getEvent());
- $writer->shutdown();
-
- $this->assertContains('Content-Type: text/plain; charset=UTF-8', $this->_transport->header);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryShouldAllowToSetMultipleRecipientsInArray()
- {
- $config = array(
- 'to' => array(
- 'John Doe' => 'admin1@domain.com',
- 'admin2@domain.com'
- ),
- 'cc' => array(
- 'bug@domain.com',
- 'project' => 'projectname@domain.com'
- )
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $writer->write($this->_getEvent());
- $writer->shutdown();
-
- $this->assertContains('admin1@domain.com', $this->_transport->recipients);
- $this->assertContains('admin2@domain.com', $this->_transport->recipients);
- $this->assertContains('bug@domain.com', $this->_transport->recipients);
- $this->assertContains('projectname@domain.com', $this->_transport->recipients);
- $this->assertContains('To: John Doe ', $this->_transport->header);
- $this->assertContains('admin2@domain.com', $this->_transport->header);
- $this->assertContains('Cc: bug@domain.com', $this->_transport->header);
- $this->assertContains('project ', $this->_transport->header);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryWithLayout()
- {
- $config = array(
- 'layoutOptions' => array(
- 'layoutPath' => dirname(__FILE__) . '/_files'
- )
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $writer->write($this->_getEvent());
- $writer->shutdown();
-
- $this->assertFalse(empty($this->_transport->boundary));
- $this->assertContains('Content-Type: multipart/', $this->_transport->header);
- $this->assertContains('boundary=', $this->_transport->header);
- $this->assertContains('Content-Type: text/plain', $this->_transport->body);
- $this->assertContains('Content-Type: text/html', $this->_transport->body);
- $this->assertContains($this->_transport->boundary, $this->_transport->body);
- $this->assertEquals(2, substr_count($this->_transport->body, 'an info message'));
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryShouldSetLayoutFormatter()
- {
- $config = array(
- 'layoutOptions' => array(
- 'layoutPath' => '/path/to/layout/scripts'
- ),
- 'layoutFormatter' => 'Zend_Log_Formatter_Simple'
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $this->assertTrue($writer->getLayoutFormatter() instanceof Zend_Log_Formatter_Simple);
- }
-
- /**
- * @group ZF-9990
- */
- public function testFactoryWithCustomLayoutClass()
- {
- $this->getMock('Zend_Layout', null, array(), 'Zend_Stub_Layout_Custom');
- $config = array(
- 'layout' => 'Zend_Stub_Layout_Custom'
- );
-
- $writer = Zend_Log_Writer_Mail::factory($config);
- $this->assertTrue($writer instanceof Zend_Log_Writer_Mail);
- }
-
- /**
- * Returns an array of the Zend_Mail mock object, Zend_Log_Writer_Mail
- * object, and Zend_Log objects.
- *
- * This is just a helper function for the various test methods above.
- *
- * @return array Numerically indexed array of Zend_Mail,
- * Zend_Log_Writer_Mail, Zend_Log, and Zend_Layout objects,
- * in that order.
- */
- protected function _getSimpleLogger($useLayout = false)
- {
- // Get a mock object for Zend_Mail so that no emails are actually
- // sent.
- $mail = $this->getMock('Zend_Mail', array('send'));
-
- // The send() method can be called any number of times.
- $mail->expects($this->any())
- ->method('send');
-
- $mail->addTo('zend_log_writer_mail_test@example.org');
- $mail->setFrom('zend_log_writer_mail_test@example.org');
-
- // Setup a mock object for Zend_Layout because we can't rely on any
- // layout files being in place.
- if ($useLayout) {
- $layout = $this->getMock('Zend_Layout', array('render'));
- $writer = new Zend_Log_Writer_Mail($mail, $layout);
- } else {
- $writer = new Zend_Log_Writer_Mail($mail);
- $layout = null;
- }
-
- $log = new Zend_Log();
- $log->addWriter($writer);
-
- return array($mail, $writer, $log, $layout);
- }
-
- /**
- * Returns a sample of an event
- *
- * @return array
- */
- protected function _getEvent()
- {
- return array(
- 'timestamp' => date('c'),
- 'message' => 'an info message',
- 'priority' => 6,
- 'priorityName' => 'INFO'
- );
- }
-}
-
-// Call Zend_Log_Writer_MailTest::main() if this source file is executed directly.
-if (PHPUnit_MAIN_METHOD == "Zend_Log_Writer_MailTest::main") {
- Zend_Log_Writer_MailTest::main();
-}
diff --git a/tests/Zend/Log/Writer/MockTest.php b/tests/Zend/Log/Writer/MockTest.php
deleted file mode 100644
index 9119529e3..000000000
--- a/tests/Zend/Log/Writer/MockTest.php
+++ /dev/null
@@ -1,70 +0,0 @@
-assertSame(array(), $writer->events);
-
- $fields = array('foo' => 'bar');
- $writer->write($fields);
- $this->assertSame(array($fields), $writer->events);
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Mock"
- )));
-
- // require_once 'Zend/Log.php';
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_MockTest::main') {
- Zend_Log_Writer_MockTest::main();
-}
diff --git a/tests/Zend/Log/Writer/NullTest.php b/tests/Zend/Log/Writer/NullTest.php
deleted file mode 100644
index 0d7b5218e..000000000
--- a/tests/Zend/Log/Writer/NullTest.php
+++ /dev/null
@@ -1,66 +0,0 @@
-write(array('message' => 'foo', 'priority' => 42));
- }
-
- public function testFactory()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Null"
- )));
-
- // require_once 'Zend/Log.php';
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_NullTest::main') {
- Zend_Log_Writer_NullTest::main();
-}
diff --git a/tests/Zend/Log/Writer/StreamTest.php b/tests/Zend/Log/Writer/StreamTest.php
deleted file mode 100644
index c623195bd..000000000
--- a/tests/Zend/Log/Writer/StreamTest.php
+++ /dev/null
@@ -1,190 +0,0 @@
-fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/not a stream/i', $e->getMessage());
- }
- xml_parser_free($resource);
- }
-
- public function testConstructorWithValidStream()
- {
- $stream = fopen('php://memory', 'w+');
- new Zend_Log_Writer_Stream($stream);
- }
-
- public function testConstructorWithValidUrl()
- {
- new Zend_Log_Writer_Stream('php://memory');
- }
-
- public function testConstructorThrowsWhenModeSpecifiedForExistingStream()
- {
- $stream = fopen('php://memory', 'w+');
- try {
- new Zend_Log_Writer_Stream($stream, 'w+');
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/existing stream/i', $e->getMessage());
- }
- }
-
- public function testConstructorThrowsWhenStreamCannotBeOpened()
- {
- try {
- new Zend_Log_Writer_Stream('');
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/cannot be opened/i', $e->getMessage());
- }
- }
-
- public function testWrite()
- {
- $stream = fopen('php://memory', 'w+');
- $fields = array('message' => 'message-to-log');
-
- $writer = new Zend_Log_Writer_Stream($stream);
- $writer->write($fields);
-
- rewind($stream);
- $contents = stream_get_contents($stream);
- fclose($stream);
-
- $this->assertContains($fields['message'], $contents);
- }
-
- public function testWriteThrowsWhenStreamWriteFails()
- {
- $stream = fopen('php://memory', 'w+');
- $writer = new Zend_Log_Writer_Stream($stream);
- fclose($stream);
-
- try {
- $writer->write(array('message' => 'foo'));
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/unable to write/i', $e->getMessage());
- }
- }
-
- public function testShutdownClosesStreamResource()
- {
- $writer = new Zend_Log_Writer_Stream('php://memory', 'w+');
- $writer->write(array('message' => 'this write should succeed'));
-
- $writer->shutdown();
-
- try {
- $writer->write(array('message' => 'this write should fail'));
- $this->fail();
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertRegExp('/unable to write/i', $e->getMessage());
- }
- }
-
- public function testSettingNewFormatter()
- {
- $stream = fopen('php://memory', 'w+');
- $writer = new Zend_Log_Writer_Stream($stream);
- $expected = 'foo';
-
- $formatter = new Zend_Log_Formatter_Simple($expected);
- $writer->setFormatter($formatter);
-
- $writer->write(array('bar'=>'baz'));
- rewind($stream);
- $contents = stream_get_contents($stream);
- fclose($stream);
-
- $this->assertContains($expected, $contents);
- }
-
- public function testFactoryStream()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Mock",
- 'writerParams' => array(
- 'stream' => 'php://memory',
- 'mode' => 'a'
- )
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-
- public function testFactoryUrl()
- {
- $cfg = array('log' => array('memory' => array(
- 'writerName' => "Mock",
- 'writerParams' => array(
- 'url' => 'http://localhost',
- 'mode' => 'a'
- )
- )));
-
- $logger = Zend_Log::factory($cfg['log']);
- $this->assertTrue($logger instanceof Zend_Log);
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_StreamTest::main') {
- Zend_Log_Writer_StreamTest::main();
-}
diff --git a/tests/Zend/Log/Writer/SyslogTest.php b/tests/Zend/Log/Writer/SyslogTest.php
deleted file mode 100644
index 107912ce6..000000000
--- a/tests/Zend/Log/Writer/SyslogTest.php
+++ /dev/null
@@ -1,145 +0,0 @@
- 'foo', 'priority' => LOG_NOTICE);
- $writer = new Zend_Log_Writer_Syslog();
- $writer->write($fields);
- }
-
- public function testFactory()
- {
- $cfg = array(
- 'application' => 'my app',
- 'facility' => LOG_USER
- );
-
- $writer = Zend_Log_Writer_Syslog::factory($cfg);
- $this->assertTrue($writer instanceof Zend_Log_Writer_Syslog);
- }
-
- /**
- * @group ZF-7603
- */
- public function testThrowExceptionValueNotPresentInFacilities()
- {
- try {
- $writer = new Zend_Log_Writer_Syslog();
- $writer->setFacility(LOG_USER * 1000);
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertContains('Invalid log facility provided', $e->getMessage());
- }
- }
-
- /**
- * @group ZF-7603
- */
- public function testThrowExceptionIfFacilityInvalidInWindows()
- {
- if ('WIN' != strtoupper(substr(PHP_OS, 0, 3))) {
- $this->markTestSkipped('Run only in windows');
- }
- try {
- $writer = new Zend_Log_Writer_Syslog();
- $writer->setFacility(LOG_AUTH);
- } catch (Exception $e) {
- $this->assertTrue($e instanceof Zend_Log_Exception);
- $this->assertContains('Only LOG_USER is a valid', $e->getMessage());
- }
- }
-
- /**
- * @group ZF-8953
- */
- public function testFluentInterface()
- {
- $writer = new Zend_Log_Writer_Syslog();
- $instance = $writer->setFacility(LOG_USER)
- ->setApplicationName('my_app');
-
- $this->assertTrue($instance instanceof Zend_Log_Writer_Syslog);
- }
-
- /**
- * @group ZF-10769
- */
- public function testPastFacilityViaConstructor()
- {
- $writer = new WriterSyslogCustom(array('facility' => LOG_USER));
- $this->assertEquals(LOG_USER, $writer->getFacility());
- }
-
- /**
- * @group ZF-8382
- */
- public function testWriteWithFormatter()
- {
- $event = array(
- 'message' => 'tottakai',
- 'priority' => Zend_Log::ERR
- );
-
- $writer = Zend_Log_Writer_Syslog::factory(array());
- // require_once 'Zend/Log/Formatter/Simple.php';
- $formatter = new Zend_Log_Formatter_Simple('%message% (this is a test)');
- $writer->setFormatter($formatter);
-
- $writer->write($event);
- }
-}
-
-class WriterSyslogCustom extends Zend_Log_Writer_Syslog
-{
- public function getFacility()
- {
- return $this->_facility;
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_SyslogTest::main') {
- Zend_Log_Writer_SyslogTest::main();
-}
diff --git a/tests/Zend/Log/Writer/ZendMonitorTest.php b/tests/Zend/Log/Writer/ZendMonitorTest.php
deleted file mode 100644
index 84ea6a6c8..000000000
--- a/tests/Zend/Log/Writer/ZendMonitorTest.php
+++ /dev/null
@@ -1,72 +0,0 @@
-write(array('message' => 'my mess', 'priority' => 1));
- }
-
- public function testFactory()
- {
- $cfg = array();
-
- $writer = Zend_Log_Writer_ZendMonitor::factory($cfg);
- $this->assertTrue($writer instanceof Zend_Log_Writer_ZendMonitor);
- }
-
- public function testIsEnabled()
- {
- $writer = new Zend_Log_Writer_ZendMonitor();
- $this->assertTrue(is_bool($writer->isEnabled()));
- }
-}
-
-if (PHPUnit_MAIN_METHOD == 'Zend_Log_Writer_ZendMonitorTest::main') {
- Zend_Log_Writer_ZendMonitorTest::main();
-}
diff --git a/tests/Zend/Log/Writer/_files/layout.phtml b/tests/Zend/Log/Writer/_files/layout.phtml
deleted file mode 100644
index b1ebac07a..000000000
--- a/tests/Zend/Log/Writer/_files/layout.phtml
+++ /dev/null
@@ -1 +0,0 @@
-layout()->events;
\ No newline at end of file
diff --git a/tests/Zend/Log/_files/Zfns/Writer.php b/tests/Zend/Log/_files/Zfns/Writer.php
deleted file mode 100644
index 63f9d0ca1..000000000
--- a/tests/Zend/Log/_files/Zfns/Writer.php
+++ /dev/null
@@ -1,28 +0,0 @@
-getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(''), '', false);
$select = new Zend_Db_Select($dbAdapter);
$select->from('ZF_6989');
-
+
$paginatorAdapter = new Zend_Paginator_Adapter_DbSelect($select);
$paginatorAdapter->setRowCount(6989);
-
+
$paginator = new Zend_Paginator_TestCache($paginatorAdapter);
$expectedCacheId = md5($paginator->getCacheInternalId() . '_itemCount');
-
+
$cache = $this->getMock('Zend_Cache_Core', array('load'), array(), '', false);
$cache->expects($this->once())
->method('load')
->with($expectedCacheId)
->will($this->returnValue(6989));
-
+
$paginator->setCacheEnabled(true)
->setCache($cache);
-
+
$this->assertSame(6989, $paginator->getTotalItemCount(), 'Total item count incorrect!');
}
-
+
/**
* @group ZF-6989
*/
@@ -1089,11 +1088,11 @@ public function testPaginatorGeneratesSameCacheIdentifierForDbSelectAdaptersWith
$paginatorOne = new Zend_Paginator_TestCache($paginatorAdapterOne);
- $dbAdapterTwo = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(''),
+ $dbAdapterTwo = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(''),
__FUNCTION__ . 'DbAdapterTwo', false);
$selectTwo = new Zend_Db_Select($dbAdapterTwo);
$selectTwo->from('ZF_6989');
-
+
$paginatorAdapterTwo = new Zend_Paginator_Adapter_DbSelect($selectTwo);
$paginatorAdapterTwo->setRowCount(6989);
@@ -1102,7 +1101,7 @@ public function testPaginatorGeneratesSameCacheIdentifierForDbSelectAdaptersWith
$this->assertSame($paginatorOne->getCacheInternalId(), $paginatorTwo->getCacheInternalId(),
'DbSelect adapters with identical select statements should have the same cache internal IDs!');
}
-
+
/**
* @group ZF-6989
*/
@@ -1112,22 +1111,22 @@ public function testPaginatorGeneratesSameCacheIdentifierForDbTableSelectAdapter
__FUNCTION__ . 'DbAdapterOne', false);
$selectOne = new Zend_Db_Select($dbAdapterOne);
$selectOne->from('ZF_6989');
-
+
$paginatorAdapterOne = new Zend_Paginator_Adapter_DbSelect($selectOne);
$paginatorAdapterOne->setRowCount(6989);
-
+
$paginatorOne = new Zend_Paginator_TestCache($paginatorAdapterOne);
-
- $dbAdapterTwo = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(''),
+
+ $dbAdapterTwo = $this->getMockForAbstractClass('Zend_Db_Adapter_Abstract', array(''),
__FUNCTION__ . 'DbAdapterTwo', false);
$selectTwo = new Zend_Db_Select($dbAdapterTwo);
$selectTwo->from('ZF_6989');
-
+
$paginatorAdapterTwo = new Zend_Paginator_Adapter_DbSelect($selectTwo);
$paginatorAdapterTwo->setRowCount(6989);
-
+
$paginatorTwo = new Zend_Paginator_TestCache($paginatorAdapterTwo);
-
+
$this->assertSame($paginatorOne->getCacheInternalId(), $paginatorTwo->getCacheInternalId(),
'DbSelect adapters with identical select statements should have the same cache internal IDs!');
}
@@ -1142,7 +1141,7 @@ public function getPaginatorAdapter()
}
/**
- * Wrapper around Zend_Paginator to provide access to cache internal ID method
+ * Wrapper around Zend_Paginator to provide access to cache internal ID method
* for testing purposes.
*/
class Zend_Paginator_TestCache extends Zend_Paginator