Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

DB tests are enabled for Travis and fixed to be passing #320

Merged
merged 13 commits into from

4 participants

@mhujer

This is a summarizing PR for #261 #272 #273 #274 where you can find more detailed description of individual changes.

@froschdesign froschdesign added this to the 1.12.6 milestone
mhujer and others added some commits
@mhujer mhujer More tests run on Travis - enabled MySQL, PostgreSQL, SQLite, Memcach…
…e(d)
bb2a39b
@mhujer mhujer Fixed docblock
(cherry picked from commit a4d723e)
f6e0122
@mhujer mhujer #261: SQLite does not need different tests since 5.3
(cherry picked from commit f770905)
3f92c50
@mhujer mhujer #261: Table is cleared completely to prevent Sqlite "PRIMARY KEY must…
… be unique" error

(cherry picked from commit 9cd8315)
dfe4a91
@mhujer mhujer #261: SQLite test fixed: testAdapterOptionFetchMode
(cherry picked from commit be28b74)
a090630
@mhujer mhujer #261: SQLite test fixed: testAdapterAlternateStatement
(cherry picked from commit 544f701)
5d09e62
@OndraM OndraM Drop test tables only if exists, to prevent errors on clean database
(cherry picked from commit 56b225f)
2480524
@OndraM OndraM Define NULL in test seed using Zend_Db_Expr, so it won't get quoted
(cherry picked from commit 5f0dc97)
47146ca
@OndraM OndraM Get current locale properly
(cherry picked from commit 39539aa)
2dcc687
@OndraM OndraM Remove redundant from() causing errors on postgres
(cherry picked from commit a7e2eb0)
3424806
@OndraM OndraM Do empty-PK detection before we try to obtain nextSequenceId, so it w…
…orks properly also for the values considered empty

(cherry picked from commit 0d79c0e)
2274fdb
@OndraM OndraM Properly remove previously created row with PK 0 to not fail on uniqu…
…e PK constrains

(cherry picked from commit 03cbdca)

Conflicts:
	tests/Zend/Db/Table/TestCommon.php
dcea309
@OndraM OndraM Provide table and PK name to make test compatible with RDBMS using se…
…quences

(cherry picked from commit d452916)
4f7338e
@mhujer mhujer changed the title from DB tests are enabled for Travis and fixed to be passing [Work-In-Progress] to DB tests are enabled for Travis and fixed to be passing
@mhujer

@akrabat @froschdesign it's ready-for-review

@froschdesign froschdesign merged commit 6fb5c4b into zendframework:master

1 check passed

Details continuous-integration/travis-ci The Travis CI build passed
@mhujer mhujer deleted the mhujer:db-tests branch
@froschdesign
Collaborator

@mhujer & @OndraM
Thanks! :+1:

@akrabat
Collaborator

Yeah, Great work!

@mhujer

I'm glad to have this merged :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 3, 2014
  1. @mhujer
  2. @mhujer

    Fixed docblock

    mhujer authored
    (cherry picked from commit a4d723e)
  3. @mhujer

    #261: SQLite does not need different tests since 5.3

    mhujer authored
    (cherry picked from commit f770905)
  4. @mhujer

    #261: Table is cleared completely to prevent Sqlite "PRIMARY KEY must…

    mhujer authored
    … be unique" error
    
    (cherry picked from commit 9cd8315)
  5. @mhujer

    #261: SQLite test fixed: testAdapterOptionFetchMode

    mhujer authored
    (cherry picked from commit be28b74)
  6. @mhujer

    #261: SQLite test fixed: testAdapterAlternateStatement

    mhujer authored
    (cherry picked from commit 544f701)
  7. @OndraM @mhujer

    Drop test tables only if exists, to prevent errors on clean database

    OndraM authored mhujer committed
    (cherry picked from commit 56b225f)
  8. @OndraM @mhujer

    Define NULL in test seed using Zend_Db_Expr, so it won't get quoted

    OndraM authored mhujer committed
    (cherry picked from commit 5f0dc97)
  9. @OndraM @mhujer

    Get current locale properly

    OndraM authored mhujer committed
    (cherry picked from commit 39539aa)
  10. @OndraM @mhujer

    Remove redundant from() causing errors on postgres

    OndraM authored mhujer committed
    (cherry picked from commit a7e2eb0)
  11. @OndraM @mhujer

    Do empty-PK detection before we try to obtain nextSequenceId, so it w…

    OndraM authored mhujer committed
    …orks properly also for the values considered empty
    
    (cherry picked from commit 0d79c0e)
  12. @OndraM @mhujer

    Properly remove previously created row with PK 0 to not fail on uniqu…

    OndraM authored mhujer committed
    …e PK constrains
    
    (cherry picked from commit 03cbdca)
    
    Conflicts:
    	tests/Zend/Db/Table/TestCommon.php
  13. @OndraM @mhujer

    Provide table and PK name to make test compatible with RDBMS using se…

    OndraM authored mhujer committed
    …quences
    
    (cherry picked from commit d452916)
This page is out of date. Refresh to see the latest.
View
10 .travis.yml
@@ -14,6 +14,16 @@ install:
- sh ./tests/install_dependencies.sh
- phpenv rehash
+services:
+ - memcached
+
+before_script:
+ - mysql -e 'create database zftest;'
+ - psql -c 'create database zftest;' -U postgres
+ - echo "extension = memcache.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+ - echo "extension = memcached.so" >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini
+ - cp ./tests/TestConfiguration.travis.php ./tests/TestConfiguration.php
+
script:
- cd tests/
- php runalltests.php
View
40 library/Zend/Db/Table/Abstract.php
@@ -1041,16 +1041,6 @@ public function insert(array $data)
$primary = (array) $this->_primary;
$pkIdentity = $primary[(int)$this->_identity];
- /**
- * If this table uses a database sequence object and the data does not
- * specify a value, then get the next ID from the sequence and add it
- * to the row. We assume that only the first column in a compound
- * primary key takes a value from a sequence.
- */
- if (is_string($this->_sequence) && !isset($data[$pkIdentity])) {
- $data[$pkIdentity] = $this->_db->nextSequenceId($this->_sequence);
- $pkSuppliedBySequence = true;
- }
/**
* If the primary key can be generated automatically, and no value was
@@ -1060,7 +1050,7 @@ public function insert(array $data)
* position of the data. The following values are considered empty:
* null, false, true, '', array()
*/
- if (!isset($pkSuppliedBySequence) && array_key_exists($pkIdentity, $data)) {
+ if (array_key_exists($pkIdentity, $data)) {
if ($data[$pkIdentity] === null // null
|| $data[$pkIdentity] === '' // empty string
|| is_bool($data[$pkIdentity]) // boolean
@@ -1070,6 +1060,16 @@ public function insert(array $data)
}
/**
+ * If this table uses a database sequence object and the data does not
+ * specify a value, then get the next ID from the sequence and add it
+ * to the row. We assume that only the first column in a compound
+ * primary key takes a value from a sequence.
+ */
+ if (is_string($this->_sequence) && !isset($data[$pkIdentity])) {
+ $data[$pkIdentity] = $this->_db->nextSequenceId($this->_sequence);
+ }
+
+ /**
* INSERT the new row.
*/
$tableSpec = ($this->_schema ? $this->_schema . '.' : '') . $this->_name;
@@ -1212,20 +1212,20 @@ public function _cascadeDelete($parentTableClassname, array $primaryKey)
{
// setup metadata
$this->_setupMetadata();
-
+
// get this class name
$thisClass = get_class($this);
if ($thisClass === 'Zend_Db_Table') {
$thisClass = $this->_definitionConfigName;
}
-
+
$rowsAffected = 0;
-
+
foreach ($this->_getReferenceMapNormalized() as $map) {
if ($map[self::REF_TABLE_CLASS] == $parentTableClassname && isset($map[self::ON_DELETE])) {
-
+
$where = array();
-
+
// CASCADE or CASCADE_RECURSE
if (in_array($map[self::ON_DELETE], array(self::CASCADE, self::CASCADE_RECURSE))) {
for ($i = 0; $i < count($map[self::COLUMNS]); ++$i) {
@@ -1237,10 +1237,10 @@ public function _cascadeDelete($parentTableClassname, array $primaryKey)
$primaryKey[$refCol], $type);
}
}
-
+
// CASCADE_RECURSE
if ($map[self::ON_DELETE] == self::CASCADE_RECURSE) {
-
+
/**
* Execute cascading deletes against dependent tables
*/
@@ -1259,7 +1259,7 @@ public function _cascadeDelete($parentTableClassname, array $primaryKey)
if (in_array($map[self::ON_DELETE], array(self::CASCADE, self::CASCADE_RECURSE))) {
$rowsAffected += $this->delete($where);
}
-
+
}
}
return $rowsAffected;
@@ -1610,5 +1610,5 @@ public static function getTableFromString($tableName, Zend_Db_Table_Abstract $re
return new $tableName($options);
}
-
+
}
View
85 tests/TestConfiguration.travis.php
@@ -0,0 +1,85 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package UnitTests
+ * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * This file defines configuration for running the unit tests for the Zend
+ * Framework. Some tests have dependencies to PHP extensions or databases
+ * which may not necessary installed on the target system. For these cases,
+ * the ability to disable or configure testing is provided below. Tests for
+ * components which should run universally are always run by the master
+ * suite and cannot be disabled.
+ *
+ * Do not edit this file. Instead, copy this file to TestConfiguration.php,
+ * and edit the new file. Never commit plaintext passwords to the source
+ * code repository.
+ */
+
+ /**
+ * Zend_Auth_Adapter_DbTable tests
+ */
+defined('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED') || define('TESTS_ZEND_AUTH_ADAPTER_DBTABLE_PDO_SQLITE_ENABLED', true);
+
+/**
+ * Zend_Cache
+ *
+ * TESTS_ZEND_CACHE_SQLITE_ENABLED => sqlite extension has to be enabled
+ * TESTS_ZEND_CACHE_APC_ENABLED => apc extension has to be enabled
+ * TESTS_ZEND_CACHE_WINCACHE_ENABLED => wincache extension has to be enabled
+ * TESTS_ZEND_CACHE_MEMCACHED_ENABLED => memcache extension has to be enabled and
+ * a memcached server has to be available
+ * TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED => memcached extension has to be enabled and
+ * a memcached server has to be available
+ * TESTS_ZEND_CACHE_XCACHE_ENABLED => xcache extension has to be enabled
+ */
+defined('TESTS_ZEND_CACHE_SQLITE_ENABLED') || define('TESTS_ZEND_CACHE_SQLITE_ENABLED', true);
+defined('TESTS_ZEND_CACHE_MEMCACHED_ENABLED') || define('TESTS_ZEND_CACHE_MEMCACHED_ENABLED', true);
+defined('TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED') || define('TESTS_ZEND_CACHE_LIBMEMCACHED_ENABLED', true);
+
+/**
+ * Zend_Db_Adapter_Pdo_Mysql and Zend_Db_Adapter_Mysqli
+ *
+ * There are separate properties to enable tests for the PDO_MYSQL adapter and
+ * the native Mysqli adapters, but the other properties are shared between the
+ * two MySQL-related Zend_Db adapters.
+ */
+defined('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_MYSQL_ENABLED', true);
+defined('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_MYSQLI_ENABLED', true);
+defined('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_USERNAME', 'travis');
+defined('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_PASSWORD', '');
+defined('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_MYSQL_DATABASE', 'zftest');
+
+/**
+ * Zend_Db_Adapter_Pdo_Sqlite
+ *
+ * Username and password are irrelevant for SQLite.
+ */
+defined('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_SQLITE_ENABLED', true);
+
+/**
+ * Zend_Db_Adapter_Pdo_Pgsql
+ */
+defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_ENABLED', true);
+defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_USERNAME', 'postgres');
+defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_PASSWORD', '');
+defined('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE') || define('TESTS_ZEND_DB_ADAPTER_PDO_PGSQL_DATABASE', 'zftest');
+
+
+require_once dirname(__FILE__) . '/TestConfiguration.php.dist';
View
47 tests/Zend/Db/Adapter/Pdo/SqliteTest.php
@@ -200,4 +200,51 @@ 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));
+ }
}
View
24 tests/Zend/Db/Select/Pdo/SqliteTest.php
@@ -57,6 +57,10 @@ public function testSelectJoinRight()
public function testSelectGroupBy()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectGroupBy();
+ }
$select = $this->_selectGroupBy();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -74,6 +78,10 @@ public function testSelectGroupBy()
public function testSelectGroupByQualified()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectGroupByQualified();
+ }
$select = $this->_selectGroupByQualified();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -91,6 +99,10 @@ public function testSelectGroupByQualified()
public function testSelectHaving()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHaving();
+ }
$select = $this->_selectHaving();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -104,6 +116,10 @@ public function testSelectHaving()
public function testSelectHavingWithParameter()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHavingWithParameter();
+ }
$select = $this->_selectHavingWithParameter();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -117,6 +133,10 @@ public function testSelectHavingWithParameter()
public function testSelectHavingOr()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHavingOr();
+ }
$select = $this->_selectHavingOr();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -132,6 +152,10 @@ public function testSelectHavingOr()
public function testSelectHavingOrWithParameter()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHavingOrWithParameter();
+ }
$select = $this->_selectHavingOrWithParameter();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
View
18 tests/Zend/Db/Select/TestCommon.php
@@ -858,7 +858,7 @@ protected function _selectWhereWithTypeFloat()
public function testSelectWhereWithTypeFloat()
{
- $locale = setlocale(LC_ALL, null);
+ $locale = setlocale(LC_ALL, 0);
$select = $this->_selectWhereWithTypeFloat();
$stmt = $this->_db->query($select);
@@ -1697,7 +1697,7 @@ public function testSerializeSelect()
$serialize = serialize($this->_select());
$this->assertTrue(is_string($serialize));
}
-
+
/**
* @group ZF-3792
*/
@@ -1706,7 +1706,7 @@ public function testJoinUsingActuallyGeneratesAnInnerJoinOnForCompatibilityReaso
$table_A = $this->_db->quoteTableAs('A');
$table_B = $this->_db->quoteTableAs('B');
$colname = $this->_db->quoteIdentifier('colname');
-
+
$s = $this->_db->select()->from('A')->joinUsing('B', $colname);
$this->assertContains("JOIN {$table_B} ON {$table_B}.{$colname} = {$table_A}.{$colname}", $s->assemble());
}
@@ -1720,7 +1720,7 @@ public function testJoinUsingAllowsSpecifyingMultipleColumnsViaAnArray()
$table_B = $this->_db->quoteTableAs('B');
$colOne = $this->_db->quoteIdentifier('colOne');
$colTwo = $this->_db->quoteIdentifier('colTwo');
-
+
$s = $this->_db->select()->from('A')->joinUsing('B', array($colOne,$colTwo));
$this->assertContains(
"JOIN {$table_B} ON {$table_B}.{$colOne} = {$table_A}.{$colOne}"
@@ -1737,12 +1737,12 @@ public function testJoinUsingUsesTableNameOfTableBeingJoinedWhenAliasNotDefined(
$table1 = $this->_db->quoteTableAs('table1');
$table2 = $this->_db->quoteTableAs('table2');
$colname = $this->_db->quoteIdentifier('column1');
-
+
$select = $this->_db->select();
$select->from('table1')->joinUsing('table2', $colname);
$this->assertRegexp("/ON {$table2}.{$colname}/s", $select->assemble());
}
-
+
/**
* @group ZF-3309
*/
@@ -1751,10 +1751,10 @@ public function testJoinUsingUsesAliasOfTableBeingJoinedWhenAliasIsDefined()
$table1 = $this->_db->quoteTableAs('table1');
$table2_alias = $this->_db->quoteTableAs('t2');
$colname = $this->_db->quoteIdentifier('column1');
-
+
$select = $this->_db->select();
$select->from('table1')->joinUsing(array('t2'=>'table2'), $colname);
$this->assertRegexp("/ON {$table2_alias}.{$colname}/s", $select->assemble());
- }
-
+ }
+
}
View
3  tests/Zend/Db/Table/Rowset/TestCommon.php
@@ -386,7 +386,7 @@ public function testConnectedRowObjectsAreCreatedByRowsetAfterSetTableIsCalled()
$this->assertTrue($row->isConnected());
$this->assertTrue($row->getTable() instanceof Zend_Db_Table_Abstract);
}
-
+
/**
* @group GH-172
*/
@@ -415,7 +415,6 @@ public function testFixForRowsetContainsDisconnectedRowObjectsWhenDeserializedDo
$tableClass = get_class($table);
$select = $table->select(Zend_Db_Table::SELECT_WITH_FROM_PART)->setIntegrityCheck(false);
- $select->from('zfbugs', array('bug_id'));
$select->join('zfaccounts', 'zfaccounts.account_name = zfbugs.reported_by', 'account_name');
$select->where('zfaccounts.account_name = ?', 'Bob');
View
24 tests/Zend/Db/Table/Select/Pdo/SqliteTest.php
@@ -61,6 +61,10 @@ public function testSelectJoinRight()
public function testSelectGroupBy()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectGroupBy();
+ }
$select = $this->_selectGroupBy();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -78,6 +82,10 @@ public function testSelectGroupBy()
public function testSelectGroupByQualified()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectGroupByQualified();
+ }
$select = $this->_selectGroupByQualified();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -95,6 +103,10 @@ public function testSelectGroupByQualified()
public function testSelectHaving()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHaving();
+ }
$select = $this->_selectHaving();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -108,6 +120,10 @@ public function testSelectHaving()
public function testSelectHavingWithParameter()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHavingWithParameter();
+ }
$select = $this->_selectHavingWithParameter();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -121,6 +137,10 @@ public function testSelectHavingWithParameter()
public function testSelectHavingOr()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHavingOr();
+ }
$select = $this->_selectHavingOr();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
@@ -136,6 +156,10 @@ public function testSelectHavingOr()
public function testSelectHavingOrWithParameter()
{
+ //SQLite doesn't need different test from 5.3
+ if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
+ return parent::testSelectHavingOrWithParameter();
+ }
$select = $this->_selectHavingOrWithParameter();
$stmt = $this->_db->query($select);
$result = $stmt->fetchAll();
View
16 tests/Zend/Db/Table/TestCommon.php
@@ -675,7 +675,7 @@ public function testTableInsert()
$this->assertEquals($insertResult, $lastInsertId);
$this->assertEquals(5, $lastInsertId);
}
-
+
/**
* @group ZF-3837
*/
@@ -693,7 +693,7 @@ public function testTableInsertWhenAutoIncrementFieldIsAnEmptyStringShouldProduc
'verified_by' => 'dduck'
);
$insertResult = $table->insert($row);
- $lastInsertId = $this->_db->lastInsertId();
+ $lastInsertId = $this->_db->lastInsertId('zfbugs', 'bug_id');
$this->assertEquals($insertResult, $lastInsertId);
$this->assertEquals(5, $lastInsertId);
}
@@ -836,7 +836,7 @@ public function testTableInsertWithHighMemoryUsage()
$mem_delta = $mem2-$mem1;
$this->assertThat($mem_delta, $this->lessThan(513));
}
-
+
/**
* @group ZF-2953
*/
@@ -852,12 +852,12 @@ public function testTableInsertWithEmptyValueAsPrimaryKey()
'assigned_to' => 'goofy',
'verified_by' => 'dduck'
);
-
+
// empty string
$row['bug_id'] = '';
$insertResult = $table->insert($row);
$this->assertTrue(is_numeric($insertResult), 'Empty string did not return assigned primary key');
-
+
// false (bool)
$row['bug_id'] = false;
$insertResult = $table->insert($row);
@@ -867,16 +867,16 @@ public function testTableInsertWithEmptyValueAsPrimaryKey()
$row['bug_id'] = array();
$insertResult = $table->insert($row);
$this->assertTrue(is_numeric($insertResult), 'Empty array did not return assigned primary key');
-
+
// zero '0'
$row['bug_id'] = '0';
$table->delete('bug_id > 0'); // clear table
$insertResult = $table->insert($row);
$this->assertEquals('0', $insertResult, 'Zero string did not return assigned primary key');
-
+
// zero 0
$row['bug_id'] = 0;
- $table->delete('bug_id > 0'); // clear table
+ $table->delete('bug_id = 0'); // clear table
$insertResult = $table->insert($row);
$this->assertEquals('0', $insertResult, 'Zero int did not return assigned primary key');
}
View
2  tests/Zend/Db/TestSetup.php
@@ -42,7 +42,7 @@
abstract class Zend_Db_TestSetup extends PHPUnit_Framework_TestCase
{
/**
- * @var Zend_Db_TestUtil
+ * @var Zend_Db_TestUtil_Common
*/
protected $_util = null;
View
4 tests/Zend/Db/TestUtil/Common.php
@@ -421,12 +421,12 @@ protected function _getDataPrice()
protected function _getDataCascadeRecursive()
{
return array(
- array('item_id' => '1', 'item_parent' => NULL, 'item_data' => '1'),
+ array('item_id' => '1', 'item_parent' => new Zend_Db_Expr('NULL'), 'item_data' => '1'),
array('item_id' => '2', 'item_parent' => '1', 'item_data' => '1.2'),
array('item_id' => '3', 'item_parent' => '1', 'item_data' => '1.3'),
array('item_id' => '4', 'item_parent' => '3', 'item_data' => '1.3.4'),
array('item_id' => '5', 'item_parent' => '3', 'item_data' => '1.3.5'),
- array('item_id' => '6', 'item_parent' => NULL, 'item_data' => '6')
+ array('item_id' => '6', 'item_parent' => new Zend_Db_Expr('NULL'), 'item_data' => '6')
);
}
View
4 tests/Zend/Test/PHPUnit/Db/Integration/MysqlIntegrationTest.php
@@ -57,8 +57,8 @@ public function setUp()
);
$this->dbAdapter = Zend_Db::factory('pdo_mysql', $params);
- $this->dbAdapter->query("DROP TABLE foo");
- $this->dbAdapter->query("DROP TABLE bar");
+ $this->dbAdapter->query("DROP TABLE IF EXISTS foo");
+ $this->dbAdapter->query("DROP TABLE IF EXISTS bar");
$this->dbAdapter->query(
'CREATE TABLE foo (id INT(10) AUTO_INCREMENT PRIMARY KEY, foo VARCHAR(255), bar VARCHAR(255), baz VARCHAR(255)) AUTO_INCREMENT=1'
);
Something went wrong with that request. Please try again.