Commit ae358bd9 authored by Benjamin Eberlei's avatar Benjamin Eberlei

Merge remote branch 'origin/2.1.x' into 2.1.x

parents 79079d39 d3847864
language: php
php:
- 5.3
- 5.4
env:
- DB=mysql
- DB=pgsql
- DB=sqlite
before_script:
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS doctrine_tests;' -U postgres; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'DROP DATABASE IF EXISTS doctrine_tests_tmp;' -U postgres; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database doctrine_tests;' -U postgres; fi"
- sh -c "if [ '$DB' = 'pgsql' ]; then psql -c 'create database doctrine_tests_tmp;' -U postgres; fi"
- sh -c "if [ '$DB' = 'mysql' ]; then mysql -e 'create database IF NOT EXISTS doctrine_tests_tmp;create database IF NOT EXISTS doctrine_tests;'; fi"
- git submodule update --init
script: phpunit --configuration tests/travis/$DB.travis.xml
\ No newline at end of file
{
"name": "doctrine/dbal",
"type": "library",
"description": "Database Abstraction Layer",
"keywords": ["dbal", "database", "persistence", "queryobject"],
"homepage": "http://www.doctrine-project.org",
"license": "LGPL",
"authors": [
{"name": "Guilherme Blanco", "email": "guilhermeblanco@gmail.com"},
{"name": "Roman Borschel", "email": "roman@code-factory.org"},
{"name": "Benjamin Eberlei", "email": "kontakt@beberlei.de"},
{"name": "Jonathan Wage", "email": "jonwage@gmail.com"}
],
"require": {
"php": ">=5.3.2",
"doctrine/common": "2.*"
},
"autoload": {
"psr-0": { "Doctrine\\DBAL": "lib/" }
}
}
......@@ -747,8 +747,10 @@ LEFT JOIN all_cons_columns r_cols
'long' => 'string',
'clob' => 'text',
'nclob' => 'text',
'raw' => 'text',
'long raw' => 'text',
'rowid' => 'string',
'urowid' => 'string'
'urowid' => 'string',
);
}
......
......@@ -210,8 +210,7 @@ class PostgreSqlPlatform extends AbstractPlatform
(
SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE " .$this->getTableWhereClause($table) ."
AND n.oid = c.relnamespace
WHERE " .$this->getTableWhereClause($table) ." AND n.oid = c.relnamespace
)
AND r.contype = 'f'";
}
......@@ -259,15 +258,22 @@ class PostgreSqlPlatform extends AbstractPlatform
) AND pg_index.indexrelid = oid";
}
/**
* @param string $table
* @param string $classAlias
* @param string $namespaceAlias
* @return string
*/
private function getTableWhereClause($table, $classAlias = 'c', $namespaceAlias = 'n')
{
$whereClause = "";
$whereClause = $namespaceAlias.".nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') AND ";
if (strpos($table, ".") !== false) {
list($schema, $table) = explode(".", $table);
$whereClause = "$classAlias.relname = '" . $table . "' AND $namespaceAlias.nspname = '" . $schema . "'";
$whereClause .= "$classAlias.relname = '" . $table . "' AND $namespaceAlias.nspname = '" . $schema . "'";
} else {
$whereClause = "$classAlias.relname = '" . $table . "'";
$whereClause .= "$classAlias.relname = '" . $table . "'";
}
return $whereClause;
}
......
......@@ -455,35 +455,36 @@ class SqlitePlatform extends AbstractPlatform
protected function initializeDoctrineTypeMappings()
{
$this->doctrineTypeMapping = array(
'boolean' => 'boolean',
'tinyint' => 'boolean',
'smallint' => 'smallint',
'mediumint' => 'integer',
'int' => 'integer',
'integer' => 'integer',
'serial' => 'integer',
'bigint' => 'bigint',
'bigserial' => 'bigint',
'clob' => 'text',
'tinytext' => 'text',
'mediumtext' => 'text',
'longtext' => 'text',
'text' => 'text',
'varchar' => 'string',
'varchar2' => 'string',
'nvarchar' => 'string',
'image' => 'string',
'ntext' => 'string',
'char' => 'string',
'date' => 'date',
'datetime' => 'datetime',
'timestamp' => 'datetime',
'time' => 'time',
'float' => 'float',
'double' => 'float',
'real' => 'float',
'decimal' => 'decimal',
'numeric' => 'decimal',
'boolean' => 'boolean',
'tinyint' => 'boolean',
'smallint' => 'smallint',
'mediumint' => 'integer',
'int' => 'integer',
'integer' => 'integer',
'serial' => 'integer',
'bigint' => 'bigint',
'bigserial' => 'bigint',
'clob' => 'text',
'tinytext' => 'text',
'mediumtext' => 'text',
'longtext' => 'text',
'text' => 'text',
'varchar' => 'string',
'varchar2' => 'string',
'nvarchar' => 'string',
'image' => 'string',
'ntext' => 'string',
'char' => 'string',
'date' => 'date',
'datetime' => 'datetime',
'timestamp' => 'datetime',
'time' => 'time',
'float' => 'float',
'double' => 'float',
'double precision' => 'float',
'real' => 'float',
'decimal' => 'decimal',
'numeric' => 'decimal',
);
}
......
......@@ -24,10 +24,10 @@ use Doctrine\DBAL\Query\Expression\CompositeExpression,
/**
* QueryBuilder class is responsible to dynamically create SQL queries.
*
*
* Important: Verify that every feature you use will work with your database vendor.
* SQL Query Builder does not attempt to validate the generated SQL at all.
*
*
* The query builder does no validation whatsoever if certain features even work with the
* underlying database vendor. Limit queries and joins are NOT applied to UPDATE and DELETE statements
* even if some vendors such as MySQL support it.
......@@ -102,10 +102,10 @@ class QueryBuilder
* @var integer The maximum number of results to retrieve.
*/
private $maxResults = null;
/**
* The counter of bound parameters used with {@see bindValue)
*
*
* @var int
*/
private $boundCounter = 0;
......@@ -170,14 +170,14 @@ class QueryBuilder
{
return $this->state;
}
/**
* Execute this query using the bound parameters and their types.
*
*
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements.
*
* @return mixed
*
* @return mixed
*/
public function execute()
{
......@@ -390,7 +390,7 @@ class QueryBuilder
}
$this->sqlParts[$sqlPartName] = $sqlPart;
return $this;
}
......@@ -604,7 +604,7 @@ class QueryBuilder
)
), true);
}
/**
* Creates and adds a right join to the query.
*
......@@ -939,69 +939,76 @@ class QueryBuilder
return $this;
}
/**
* Converts this instance into a SELECT string in SQL.
*
*
* @return string
*/
private function getSQLForSelect()
{
$query = 'SELECT ' . implode(', ', $this->sqlParts['select']) . ' FROM ';
$fromClauses = array();
// Loop through all FROM clauses
foreach ($this->sqlParts['from'] as $from) {
$fromClause = $from['table'] . ' ' . $from['alias'];
if (isset($this->sqlParts['join'][$from['alias']])) {
foreach ($this->sqlParts['join'][$from['alias']] as $join) {
$fromClause .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
$fromClause .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
. ' ON ' . ((string) $join['joinCondition']);
}
}
$fromClauses[] = $fromClause;
$fromClauses[$from['alias']] = $fromClause;
}
$query .= implode(', ', $fromClauses)
// loop through all JOIN clasues for validation purpose
foreach ($this->sqlParts['join'] as $fromAlias => $joins) {
if ( ! isset($fromClauses[$fromAlias]) ) {
throw QueryException::unknownFromAlias($fromAlias, array_keys($fromClauses));
}
}
$query .= implode(', ', $fromClauses)
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '')
. ($this->sqlParts['groupBy'] ? ' GROUP BY ' . implode(', ', $this->sqlParts['groupBy']) : '')
. ($this->sqlParts['having'] !== null ? ' HAVING ' . ((string) $this->sqlParts['having']) : '')
. ($this->sqlParts['orderBy'] ? ' ORDER BY ' . implode(', ', $this->sqlParts['orderBy']) : '');
return ($this->maxResults === null && $this->firstResult == null)
return ($this->maxResults === null && $this->firstResult == null)
? $query
: $this->connection->getDatabasePlatform()->modifyLimitQuery($query, $this->maxResults, $this->firstResult);
}
/**
* Converts this instance into an UPDATE string in SQL.
*
*
* @return string
*/
private function getSQLForUpdate()
{
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
$query = 'UPDATE ' . $table
$query = 'UPDATE ' . $table
. ' SET ' . implode(", ", $this->sqlParts['set'])
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
return $query;
}
/**
* Converts this instance into a DELETE string in SQL.
*
*
* @return string
*/
private function getSQLForDelete()
{
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
$query = 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
return $query;
}
......@@ -1015,7 +1022,7 @@ class QueryBuilder
{
return $this->getSQL();
}
/**
* Create a new named parameter and bind the value $value to it.
*
......@@ -1053,15 +1060,15 @@ class QueryBuilder
return $placeHolder;
}
/**
* Create a new positional parameter and bind the given value to it.
*
*
* Attention: If you are using positional parameters with the query builder you have
* to be very careful to bind all parameters in the order they appear in the SQL
* statement , otherwise they get bound in the wrong order which can lead to serious
* bugs in your code.
*
*
* Example:
* <code>
* $qb = $conn->createQueryBuilder();
......@@ -1070,7 +1077,7 @@ class QueryBuilder
* ->where('u.username = ' . $qb->createPositionalParameter('Foo', PDO::PARAM_STR))
* ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', PDO::PARAM_STR))
* </code>
*
*
* @param mixed $value
* @param mixed $type
* @return string
......
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL\Query;
use Doctrine\DBAL\DBALException;
/**
* Driver interface.
* Interface that all DBAL drivers must implement.
*
* @since 2.1.4
*/
class QueryException extends DBALException
{
static public function unknownFromAlias($alias, $registeredAliases)
{
return new self("The given alias '" . $alias . "' is not part of " .
"any FROM clause table. The currently registered FROM-clause " .
"aliases are: " . implode(", ", $registeredAliases) . ". Join clauses " .
"are bound to from clauses to provide support for mixing of multiple " .
"from and join clauses.");
}
}
\ No newline at end of file
......@@ -61,7 +61,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
}
$tableIndexes[$k] = $v;
}
return parent::_getPortableTableIndexesList($tableIndexes, $tableName);
}
......@@ -74,12 +74,12 @@ class MySqlSchemaManager extends AbstractSchemaManager
{
return $database['Database'];
}
/**
* Gets a portable column definition.
*
*
* The database type is mapped to a corresponding Doctrine mapping type.
*
*
* @param $tableColumn
* @return array
*/
......@@ -102,10 +102,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
if ( ! isset($tableColumn['name'])) {
$tableColumn['name'] = '';
}
$scale = null;
$precision = null;
$type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
......@@ -154,7 +154,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
'length' => $length,
'unsigned' => (bool)$unsigned,
'fixed' => (bool)$fixed,
'default' => $tableColumn['default'],
'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null,
'notnull' => (bool) ($tableColumn['null'] != 'YES'),
'scale' => null,
'precision' => null,
......@@ -180,7 +180,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if (!isset($tableForeignKey['update_rule']) || $tableForeignKey['update_rule'] == "RESTRICT") {
$tableForeignKey['update_rule'] = null;
}
return new ForeignKeyConstraint(
(array)$tableForeignKey['column_name'],
$tableForeignKey['referenced_table_name'],
......
......@@ -88,11 +88,11 @@ class Table extends AbstractAsset
$this->_setName($tableName);
$this->_idGeneratorType = $idGeneratorType;
foreach ($columns AS $column) {
$this->_addColumn($column);
}
foreach ($indexes AS $idx) {
$this->_addIndex($idx);
}
......@@ -252,7 +252,7 @@ class Table extends AbstractAsset
/**
* Change Column Details
*
*
* @param string $columnName
* @param array $options
* @return Table
......@@ -266,7 +266,7 @@ class Table extends AbstractAsset
/**
* Drop Column from Table
*
*
* @param string $columnName
* @return Table
*/
......@@ -344,7 +344,7 @@ class Table extends AbstractAsset
throw SchemaException::columnDoesNotExist($columnName, $this->_name);
}
}
$constraint = new ForeignKeyConstraint(
$localColumnNames, $foreignTableName, $foreignColumnNames, $name, $options
);
......@@ -381,7 +381,7 @@ class Table extends AbstractAsset
/**
* Add index to table
*
*
* @param Index $indexCandidate
* @return Table
*/
......@@ -422,7 +422,7 @@ class Table extends AbstractAsset
protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
{
$constraint->setLocalTable($this);
if(strlen($constraint->getName())) {
$name = $constraint->getName();
} else {
......@@ -475,7 +475,7 @@ class Table extends AbstractAsset
$pkCols = array();
$fkCols = array();
if ($this->hasIndex($this->_primaryKeyName)) {
if ($this->hasPrimaryKey()) {
$pkCols = $this->getPrimaryKey()->getColumns();
}
foreach ($this->getForeignKeys() AS $fk) {
......@@ -505,7 +505,7 @@ class Table extends AbstractAsset
/**
* Get a column instance
*
*
* @param string $columnName
* @return Column
*/
......@@ -520,10 +520,13 @@ class Table extends AbstractAsset
}
/**
* @return Index
* @return Index|null
*/
public function getPrimaryKey()
{
if (!$this->hasPrimaryKey()) {
return null;
}
return $this->getIndex($this->_primaryKeyName);
}
......
......@@ -36,38 +36,38 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org
* @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class DropSchemaSqlCollector implements Visitor
{
/**
* @var array
* @var \SplObjectStorage
*/
private $_constraints = array();
private $constraints;
/**
* @var array
* @var \SplObjectStorage
*/
private $_sequences = array();
private $sequences;
/**
* @var array
* @var \SplObjectStorage
*/
private $_tables = array();
private $tables;
/**
*
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
private $platform;
/**
* @param AbstractPlatform $platform
*/
public function __construct(AbstractPlatform $platform)
{
$this->_platform = $platform;
$this->platform = $platform;
$this->clearQueries();
}
/**
......@@ -75,7 +75,7 @@ class DropSchemaSqlCollector implements Visitor
*/
public function acceptSchema(Schema $schema)
{
}
/**
......@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor
*/
public function acceptTable(Table $table)
{
$this->_tables[] = $this->_platform->getDropTableSQL($table->getQuotedName($this->_platform));
$this->tables->attach($table);
}
/**
......@@ -91,7 +91,7 @@ class DropSchemaSqlCollector implements Visitor
*/
public function acceptColumn(Table $table, Column $column)
{
}
/**
......@@ -104,7 +104,8 @@ class DropSchemaSqlCollector implements Visitor
throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint);
}
$this->_constraints[] = $this->_platform->getDropForeignKeySQL($fkConstraint->getQuotedName($this->_platform), $localTable->getQuotedName($this->_platform));
$this->constraints->attach($fkConstraint);
$this->constraints[$fkConstraint] = $localTable;
}
/**
......@@ -113,7 +114,7 @@ class DropSchemaSqlCollector implements Visitor
*/
public function acceptIndex(Table $table, Index $index)
{
}
/**
......@@ -121,15 +122,17 @@ class DropSchemaSqlCollector implements Visitor
*/
public function acceptSequence(Sequence $sequence)
{
$this->_sequences[] = $this->_platform->getDropSequenceSQL($sequence->getQuotedName($this->_platform));
$this->sequences->attach($sequence);
}
/**
* @return array
* @return void
*/
public function clearQueries()
{
$this->_constraints = $this->_sequences = $this->_tables = array();
$this->constraints = new \SplObjectStorage();
$this->sequences = new \SplObjectStorage();
$this->tables = new \SplObjectStorage();
}
/**
......@@ -137,6 +140,20 @@ class DropSchemaSqlCollector implements Visitor
*/
public function getQueries()
{
return array_merge($this->_constraints, $this->_sequences, $this->_tables);
$sql = array();
foreach ($this->constraints AS $fkConstraint) {
$localTable = $this->constraints[$fkConstraint];
$sql[] = $this->platform->getDropForeignKeySQL($fkConstraint->getQuotedName($this->platform), $localTable->getQuotedName($this->platform));
}
foreach ($this->sequences AS $sequence) {
$sql[] = $this->platform->getDropSequenceSQL($sequence->getQuotedName($this->platform));
}
foreach ($this->tables AS $table) {
$sql[] = $this->platform->getDropTableSQL($table->getQuotedName($this->platform));
}
return $sql;
}
}
......@@ -35,7 +35,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptColumn(Table $table, Column $column)
{
}
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
......@@ -53,7 +53,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptIndex(Table $table, Index $index)
{
}
public function acceptSchema(Schema $schema)
......@@ -68,7 +68,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptSequence(Sequence $sequence)
{
}
public function acceptTable(Table $table)
......@@ -99,7 +99,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
$label .= '<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">' . $columnLabel . '</FONT>';
$label .= '</TD><TD BORDER="0" ALIGN="LEFT" BGCOLOR="#eeeeec"><FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="10">' . strtolower($column->getType()) . '</FONT></TD>';
$label .= '<TD BORDER="0" ALIGN="RIGHT" BGCOLOR="#eeeeec" PORT="col'.$column->getName().'">';
if (in_array($column->getName(), $table->getPrimaryKey()->getColumns())) {
if ($table->hasPrimaryKey() && in_array($column->getName(), $table->getPrimaryKey()->getColumns())) {
$label .= "\xe2\x9c\xb7";
}
$label .= '</TD></TR>';
......@@ -139,7 +139,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
* You have to convert the output into a viewable format. For example use "neato" on linux systems
* and execute:
*
* neato -Tpng -o er.png er.dot
* neato -Tpng -o er.png er.dot
*
* @param string $filename
* @return void
......
......@@ -39,9 +39,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10);
$this->_sm->createSequence($sequence);
$sequences = $this->_sm->listSequences();
$this->assertInternalType('array', $sequences, 'listSequences() should return an array.');
$foundSequence = null;
......@@ -67,7 +67,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$databases = $this->_sm->listDatabases();
$databases = \array_map('strtolower', $databases);
$this->assertEquals(true, \in_array('test_create_database', $databases));
}
......@@ -163,7 +163,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(true, $columns['baz2']->getnotnull());
$this->assertEquals(null, $columns['baz2']->getdefault());
$this->assertInternalType('array', $columns['baz2']->getPlatformOptions());
$this->assertEquals('baz3', strtolower($columns['baz3']->getname()));
$this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime'));
$this->assertEquals(true, $columns['baz3']->getnotnull());
......@@ -250,7 +250,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key.");
$fkConstraint = current($fkConstraints);
$this->assertType('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint);
$this->assertInstanceOf('\Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkConstraint);
$this->assertEquals('test_foreign', strtolower($fkConstraint->getForeignTableName()));
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns()));
......@@ -276,7 +276,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
$this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key.");
$this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
......@@ -399,7 +399,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertTrue($inferredTable->hasColumn('id'));
$this->assertTrue($inferredTable->getColumn('id')->getAutoincrement());
}
/**
* @group DDC-887
*/
......@@ -408,11 +408,11 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
}
$table = new \Doctrine\DBAL\Schema\Table('test_fk_base');
$table->addColumn('id', 'integer');
$table->setPrimaryKey(array('id'));
$tableFK = new \Doctrine\DBAL\Schema\Table('test_fk_rename');
$tableFK->setSchemaConfig($this->_sm->createSchemaConfig());
$tableFK->addColumn('id', 'integer');
......@@ -420,10 +420,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$tableFK->setPrimaryKey(array('id'));
$tableFK->addIndex(array('fk_id'), 'fk_idx');
$tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id'));
$this->_sm->createTable($table);
$this->_sm->createTable($tableFK);
$tableFKNew = new \Doctrine\DBAL\Schema\Table('test_fk_rename');
$tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig());
$tableFKNew->addColumn('id', 'integer');
......@@ -431,10 +431,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$tableFKNew->setPrimaryKey(array('id'));
$tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx');
$tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id'));
$c = new \Doctrine\DBAL\Schema\Comparator();
$tableDiff = $c->diffTable($tableFK, $tableFKNew);
$this->_sm->alterTable($tableDiff);
}
......
......@@ -5,13 +5,13 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
/**
* SQLITE does not support databases.
*
* @expectedException \Exception
*
* @expectedException Doctrine\DBAL\DBALException
*/
public function testListDatabases()
{
......@@ -29,29 +29,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
}
/**
* @expectedException \Exception
*/
// This test is not correct. createSequence expects an object.
// PHPUnit wrapping the PHP error in an exception hides this but it shows up
// when the tests are run in the build (phing).
/*public function testCreateSequence()
{
$this->_sm->createSequence('seqname', 1, 1);
}*/
/**
* @expectedException \Exception
*/
// This test is not correct. createForeignKey expects an object.
// PHPUnit wrapping the PHP error in an exception hides this but it shows up
// when the tests are run in the build (phing).
/*public function testCreateForeignKey()
{
$this->_sm->createForeignKey('table', array());
}*/
/**
* @expectedException \Exception
* @expectedException Doctrine\DBAL\DBALException
*/
public function testRenameTable()
{
......
<?php
namespace Doctrine\Tests\DBAL\Functional\Ticket;
/**
* @group DBAL-168
*/
class DBAL168Test extends \Doctrine\Tests\DbalFunctionalTestCase
{
public function testDomainsTable()
{
if ($this->_conn->getDatabasePlatform()->getName() != "postgresql") {
$this->markTestSkipped('PostgreSQL only test');
}
$table = new \Doctrine\DBAL\Schema\Table("domains");
$table->addColumn('id', 'integer');
$table->addColumn('parent_id', 'integer');
$table->setPrimaryKey(array('id'));
$table->addForeignKeyConstraint('domains', array('parent_id'), array('id'));
$this->_conn->getSchemaManager()->createTable($table);
$table = $this->_conn->getSchemaManager()->listTableDetails('domains');
$this->assertEquals('domains', $table->getName());
}
}
\ No newline at end of file
......@@ -81,7 +81,11 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter;
$actualDbValue = $typeInstance->convertToPHPValue($this->_conn->fetchColumn($sql), $this->_conn->getDatabasePlatform());
$this->assertType($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType);
if ($originalValue instanceof \DateTime) {
$this->assertInstanceOf($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType);
} else {
$this->assertInternalType($expectedPhpType, $actualDbValue, "The expected type from the conversion to and back from the database should be " . $expectedPhpType);
}
if ($type !== "datetimetz") {
$this->assertEquals($originalValue, $actualDbValue, "Conversion between values should produce the same out as in value, but doesnt!");
......
......@@ -156,7 +156,7 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
public function testModifyLimitQueryWithOffset()
{
$sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5);
$this->assertEquals('WITH outer_tbl AS (SELECT ROW_NUMBER() OVER (ORDER BY username DESC) AS "doctrine_rownum", * FROM (SELECT * FROM user) AS inner_tbl) SELECT * FROM outer_tbl WHERE "doctrine_rownum" BETWEEN 6 AND 15', $sql);
$this->assertEquals('SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY username DESC) AS "doctrine_rownum", * FROM user) AS doctrine_tbl WHERE "doctrine_rownum" BETWEEN 6 AND 15', $sql);
}
public function testModifyLimitQueryWithAscOrderBy()
......
......@@ -13,539 +13,560 @@ require_once __DIR__ . '/../../TestInit.php';
class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
{
protected $conn;
public function setUp()
{
$this->conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
$expressionBuilder = new ExpressionBuilder($this->conn);
$this->conn->expects($this->any())
->method('getExpressionBuilder')
->will($this->returnValue($expressionBuilder));
}
public function testSimpleSelect()
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.id')
->from('users', 'u');
$this->assertEquals('SELECT u.id FROM users u', (string) $qb);
}
public function testSelectWithSimpleWhere()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$expr = $qb->expr();
$qb->select('u.id')
->from('users', 'u')
->where($expr->andX($expr->eq('u.nickname', '?')));
$this->assertEquals("SELECT u.id FROM users u WHERE u.nickname = ?", (string) $qb);
}
public function testSelectWithLeftJoin()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->leftJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM users u LEFT JOIN phones p ON p.user_id = u.id', (string) $qb);
}
public function testSelectWithJoin()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->Join('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
}
public function testSelectWithInnerJoin()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->innerJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM users u INNER JOIN phones p ON p.user_id = u.id', (string) $qb);
}
public function testSelectWithRightJoin()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->rightJoin('u', 'phones', 'p', $expr->eq('p.user_id', 'u.id'));
$this->assertEquals('SELECT u.*, p.* FROM users u RIGHT JOIN phones p ON p.user_id = u.id', (string) $qb);
}
public function testSelectWithAndWhereConditions()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->where('u.username = ?')
->andWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) AND (u.name = ?)', (string) $qb);
}
public function testSelectWithOrWhereConditions()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->where('u.username = ?')
->orWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
}
public function testSelectWithOrOrWhereConditions()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->orWhere('u.username = ?')
->orWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u WHERE (u.username = ?) OR (u.name = ?)', (string) $qb);
}
public function testSelectWithAndOrWhereConditions()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->where('u.username = ?')
->andWhere('u.username = ?')
->orWhere('u.name = ?')
->andWhere('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u WHERE (((u.username = ?) AND (u.username = ?)) OR (u.name = ?)) AND (u.name = ?)', (string) $qb);
}
public function testSelectGroupBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id', (string) $qb);
}
public function testSelectEmptyGroupBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->groupBy(array())
->from('users', 'u');
$this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
}
public function testSelectEmptyAddGroupBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->addGroupBy(array())
->from('users', 'u');
$this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
}
public function testSelectAddGroupBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->addGroupBy('u.foo');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo', (string) $qb);
}
public function testSelectAddGroupBys()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->addGroupBy('u.foo', 'u.bar');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id, u.foo, u.bar', (string) $qb);
}
public function testSelectHaving()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->having('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
}
public function testSelectAndHaving()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->andHaving('u.name = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING u.name = ?', (string) $qb);
}
public function testSelectHavingAndHaving()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->having('u.name = ?')
->andHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) AND (u.username = ?)', (string) $qb);
}
public function testSelectHavingOrHaving()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->having('u.name = ?')
->orHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb);
}
public function testSelectOrHavingOrHaving()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->orHaving('u.name = ?')
->orHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING (u.name = ?) OR (u.username = ?)', (string) $qb);
}
public function testSelectHavingAndOrHaving()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->groupBy('u.id')
->having('u.name = ?')
->orHaving('u.username = ?')
->andHaving('u.username = ?');
$this->assertEquals('SELECT u.*, p.* FROM users u GROUP BY u.id HAVING ((u.name = ?) OR (u.username = ?)) AND (u.username = ?)', (string) $qb);
}
public function testSelectOrderBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->orderBy('u.name');
$this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC', (string) $qb);
}
public function testSelectAddOrderBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->orderBy('u.name')
->addOrderBy('u.username', 'DESC');
$this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
}
public function testSelectAddAddOrderBy()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*', 'p.*')
->from('users', 'u')
->addOrderBy('u.name')
->addOrderBy('u.username', 'DESC');
$this->assertEquals('SELECT u.*, p.* FROM users u ORDER BY u.name ASC, u.username DESC', (string) $qb);
}
public function testEmptySelect()
{
$qb = new QueryBuilder($this->conn);
$qb2 = $qb->select();
$this->assertSame($qb, $qb2);
$this->assertEquals(QueryBuilder::SELECT, $qb->getType());
}
public function testSelectAddSelect()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*')
->addSelect('p.*')
->from('users', 'u');
$this->assertEquals('SELECT u.*, p.* FROM users u', (string) $qb);
}
public function testEmptyAddSelect()
{
$qb = new QueryBuilder($this->conn);
$qb2 = $qb->addSelect();
$this->assertSame($qb, $qb2);
$this->assertEquals(QueryBuilder::SELECT, $qb->getType());
}
public function testSelectMultipleFrom()
{
$qb = new QueryBuilder($this->conn);
$expr = $qb->expr();
$qb->select('u.*')
->addSelect('p.*')
->from('users', 'u')
->from('phonenumbers', 'p');
$this->assertEquals('SELECT u.*, p.* FROM users u, phonenumbers p', (string) $qb);
}
public function testUpdate()
{
$qb = new QueryBuilder($this->conn);
$qb->update('users', 'u')
->set('u.foo', '?')
->set('u.bar', '?');
$this->assertEquals(QueryBuilder::UPDATE, $qb->getType());
$this->assertEquals('UPDATE users u SET u.foo = ?, u.bar = ?', (string) $qb);
}
public function testUpdateWithoutAlias()
{
$qb = new QueryBuilder($this->conn);
$qb->update('users')
->set('foo', '?')
->set('bar', '?');
$this->assertEquals('UPDATE users SET foo = ?, bar = ?', (string) $qb);
}
public function testUpdateWhere()
{
$qb = new QueryBuilder($this->conn);
$qb->update('users', 'u')
->set('u.foo', '?')
->where('u.foo = ?');
$this->assertEquals('UPDATE users u SET u.foo = ? WHERE u.foo = ?', (string) $qb);
}
public function testEmptyUpdate()
{
$qb = new QueryBuilder($this->conn);
$qb2 = $qb->update();
$this->assertEquals(QueryBuilder::UPDATE, $qb->getType());
$this->assertSame($qb2, $qb);
}
public function testDelete()
{
$qb = new QueryBuilder($this->conn);
$qb->delete('users', 'u');
$this->assertEquals(QueryBuilder::DELETE, $qb->getType());
$this->assertEquals('DELETE FROM users u', (string) $qb);
}
public function testDeleteWithoutAlias()
{
$qb = new QueryBuilder($this->conn);
$qb->delete('users');
$this->assertEquals(QueryBuilder::DELETE, $qb->getType());
$this->assertEquals('DELETE FROM users', (string) $qb);
}
public function testDeleteWhere()
{
$qb = new QueryBuilder($this->conn);
$qb->delete('users', 'u')
->where('u.foo = ?');
$this->assertEquals('DELETE FROM users u WHERE u.foo = ?', (string) $qb);
}
public function testEmptyDelete()
{
$qb = new QueryBuilder($this->conn);
$qb2 = $qb->delete();
$this->assertEquals(QueryBuilder::DELETE, $qb->getType());
$this->assertSame($qb2, $qb);
}
public function testGetConnection()
{
$qb = new QueryBuilder($this->conn);
$this->assertSame($this->conn, $qb->getConnection());
}
public function testGetState()
{
$qb = new QueryBuilder($this->conn);
$this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
$qb->select('u.*')->from('users', 'u');
$this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
$sql1 = $qb->getSQL();
$this->assertEquals(QueryBuilder::STATE_CLEAN, $qb->getState());
$this->assertEquals($sql1, $qb->getSQL());
}
public function testSetMaxResults()
{
$qb = new QueryBuilder($this->conn);
$qb->setMaxResults(10);
$this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
$this->assertEQuals(10, $qb->getMaxResults());
}
public function testSetFirstResult()
{
$qb = new QueryBuilder($this->conn);
$qb->setFirstResult(10);
$this->assertEquals(QueryBuilder::STATE_DIRTY, $qb->getState());
$this->assertEQuals(10, $qb->getFirstResult());
}
public function testResetQueryPart()
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where('u.name = ?');
$this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
$qb->resetQueryPart('where');
$this->assertEquals('SELECT u.* FROM users u', (string)$qb);
}
public function testResetQueryParts()
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where('u.name = ?')->orderBy('u.name');
$this->assertEquals('SELECT u.* FROM users u WHERE u.name = ? ORDER BY u.name ASC', (string)$qb);
$qb->resetQueryParts(array('where', 'orderBy'));
$this->assertEquals('SELECT u.* FROM users u', (string)$qb);
}
public function testCreateNamedParameter()
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where(
$qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT))
);
$this->assertEquals('SELECT u.* FROM users u WHERE u.name = :dcValue1', (string)$qb);
$this->assertEquals(10, $qb->getParameter('dcValue1'));
}
public function testCreateNamedParameterCustomPlaceholder()
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where(
$qb->expr()->eq('u.name', $qb->createNamedParameter(10, \PDO::PARAM_INT, ':test'))
);
$this->assertEquals('SELECT u.* FROM users u WHERE u.name = :test', (string)$qb);
$this->assertEquals(10, $qb->getParameter('test'));
}
public function testCreatePositionalParameter()
{
$qb = new QueryBuilder($this->conn);
$qb->select('u.*')->from('users', 'u')->where(
$qb->expr()->eq('u.name', $qb->createPositionalParameter(10, \PDO::PARAM_INT))
);
$this->assertEquals('SELECT u.* FROM users u WHERE u.name = ?', (string)$qb);
$this->assertEquals(10, $qb->getParameter(1));
}
/**
* @group DBAL-172
*/
public function testReferenceJoinFromJoin()
{
$qb = new QueryBuilder($this->conn);
$qb->select("l.id", "mdsh.xcode", "mdso.xcode")
->from("location_tree", "l")
->join("l", "location_tree_pos", "p", "l.id = p.tree_id")
->rightJoin("l", "hotel", "h", "h.location_id = l.id")
->leftJoin("l", "offer_location", "ol", "l.id=ol.location_id")
->leftJoin("ol", "mds_offer", "mdso", "ol.offer_id = mdso.offer_id")
->leftJoin("h", "mds_hotel", "mdsh", "h.id = mdsh.hotel_id")
->where("p.parent_id IN (:ids)")
->andWhere("(mdso.xcode IS NOT NULL OR mdsh.xcode IS NOT NULL)");
$this->setExpectedException('Doctrine\DBAL\Query\QueryException', "The given alias 'ol' is not part of any FROM clause table. The currently registered FROM-clause aliases are: l");
$this->assertEquals('', $qb->getSQL());
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class DateTimeTest extends \Doctrine\Tests\DbalTestCase
{
protected
......@@ -24,7 +24,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString());
$actual = is_string($this->_type->convertToDatabaseValue($date, $this->_platform));
$actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
$this->assertEquals($expected, $actual);
}
......
......@@ -24,7 +24,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString());
$actual = is_string($this->_type->convertToDatabaseValue($date, $this->_platform));
$actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
$this->assertEquals($expected, $actual);
}
......@@ -36,7 +36,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
$this->assertInstanceOf('DateTime', $date);
$this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
}
public function testInvalidDateFormatConversion()
{
$this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
......
......@@ -27,7 +27,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString());
$actual = is_string($this->_type->convertToDatabaseValue($date, $this->_platform));
$actual = $this->_type->convertToDatabaseValue($date, $this->_platform);
$this->assertEquals($expected, $actual);
}
......
<?xml version="1.0" encoding="utf-8"?>
<phpunit>
<php>
<var name="db_type" value="pdo_mysql"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="travis" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="3306"/>
<var name="tmpdb_type" value="pdo_mysql"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="travis" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_name" value="doctrine_tests_tmp" />
<var name="tmpdb_port" value="3306"/>
</php>
<testsuites>
<testsuite name="Doctrine Test Suite">
<directory>./../Doctrine/Tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>
</phpunit>
<?xml version="1.0" encoding="utf-8"?>
<phpunit>
<php>
<var name="db_type" value="pdo_pgsql"/>
<var name="db_host" value="localhost" />
<var name="db_username" value="postgres" />
<var name="db_password" value="" />
<var name="db_name" value="doctrine_tests" />
<var name="db_port" value="5432"/>
<var name="tmpdb_type" value="pdo_pgsql"/>
<var name="tmpdb_host" value="localhost" />
<var name="tmpdb_username" value="postgres" />
<var name="tmpdb_password" value="" />
<var name="tmpdb_name" value="doctrine_tests_tmp" />
<var name="tmpdb_port" value="5432"/>
</php>
<testsuites>
<testsuite name="Doctrine Test Suite">
<directory>./../Doctrine/Tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>
</phpunit>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<phpunit>
<testsuites>
<testsuite name="Doctrine Test Suite">
<directory>./../Doctrine/Tests</directory>
</testsuite>
</testsuites>
<groups>
<exclude>
<group>performance</group>
<group>locking_functional</group>
</exclude>
</groups>
</phpunit>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment