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 ...@@ -747,8 +747,10 @@ LEFT JOIN all_cons_columns r_cols
'long' => 'string', 'long' => 'string',
'clob' => 'text', 'clob' => 'text',
'nclob' => 'text', 'nclob' => 'text',
'raw' => 'text',
'long raw' => 'text',
'rowid' => 'string', 'rowid' => 'string',
'urowid' => 'string' 'urowid' => 'string',
); );
} }
......
...@@ -210,8 +210,7 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -210,8 +210,7 @@ class PostgreSqlPlatform extends AbstractPlatform
( (
SELECT c.oid SELECT c.oid
FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n FROM pg_catalog.pg_class c, pg_catalog.pg_namespace n
WHERE " .$this->getTableWhereClause($table) ." WHERE " .$this->getTableWhereClause($table) ." AND n.oid = c.relnamespace
AND n.oid = c.relnamespace
) )
AND r.contype = 'f'"; AND r.contype = 'f'";
} }
...@@ -259,15 +258,22 @@ class PostgreSqlPlatform extends AbstractPlatform ...@@ -259,15 +258,22 @@ class PostgreSqlPlatform extends AbstractPlatform
) AND pg_index.indexrelid = oid"; ) AND pg_index.indexrelid = oid";
} }
/**
* @param string $table
* @param string $classAlias
* @param string $namespaceAlias
* @return string
*/
private function getTableWhereClause($table, $classAlias = 'c', $namespaceAlias = 'n') 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) { if (strpos($table, ".") !== false) {
list($schema, $table) = explode(".", $table); list($schema, $table) = explode(".", $table);
$whereClause = "$classAlias.relname = '" . $table . "' AND $namespaceAlias.nspname = '" . $schema . "'"; $whereClause .= "$classAlias.relname = '" . $table . "' AND $namespaceAlias.nspname = '" . $schema . "'";
} else { } else {
$whereClause = "$classAlias.relname = '" . $table . "'"; $whereClause .= "$classAlias.relname = '" . $table . "'";
} }
return $whereClause; return $whereClause;
} }
......
...@@ -455,35 +455,36 @@ class SqlitePlatform extends AbstractPlatform ...@@ -455,35 +455,36 @@ class SqlitePlatform extends AbstractPlatform
protected function initializeDoctrineTypeMappings() protected function initializeDoctrineTypeMappings()
{ {
$this->doctrineTypeMapping = array( $this->doctrineTypeMapping = array(
'boolean' => 'boolean', 'boolean' => 'boolean',
'tinyint' => 'boolean', 'tinyint' => 'boolean',
'smallint' => 'smallint', 'smallint' => 'smallint',
'mediumint' => 'integer', 'mediumint' => 'integer',
'int' => 'integer', 'int' => 'integer',
'integer' => 'integer', 'integer' => 'integer',
'serial' => 'integer', 'serial' => 'integer',
'bigint' => 'bigint', 'bigint' => 'bigint',
'bigserial' => 'bigint', 'bigserial' => 'bigint',
'clob' => 'text', 'clob' => 'text',
'tinytext' => 'text', 'tinytext' => 'text',
'mediumtext' => 'text', 'mediumtext' => 'text',
'longtext' => 'text', 'longtext' => 'text',
'text' => 'text', 'text' => 'text',
'varchar' => 'string', 'varchar' => 'string',
'varchar2' => 'string', 'varchar2' => 'string',
'nvarchar' => 'string', 'nvarchar' => 'string',
'image' => 'string', 'image' => 'string',
'ntext' => 'string', 'ntext' => 'string',
'char' => 'string', 'char' => 'string',
'date' => 'date', 'date' => 'date',
'datetime' => 'datetime', 'datetime' => 'datetime',
'timestamp' => 'datetime', 'timestamp' => 'datetime',
'time' => 'time', 'time' => 'time',
'float' => 'float', 'float' => 'float',
'double' => 'float', 'double' => 'float',
'real' => 'float', 'double precision' => 'float',
'decimal' => 'decimal', 'real' => 'float',
'numeric' => 'decimal', 'decimal' => 'decimal',
'numeric' => 'decimal',
); );
} }
......
...@@ -24,10 +24,10 @@ use Doctrine\DBAL\Query\Expression\CompositeExpression, ...@@ -24,10 +24,10 @@ use Doctrine\DBAL\Query\Expression\CompositeExpression,
/** /**
* QueryBuilder class is responsible to dynamically create SQL queries. * QueryBuilder class is responsible to dynamically create SQL queries.
* *
* Important: Verify that every feature you use will work with your database vendor. * 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. * 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 * 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 * underlying database vendor. Limit queries and joins are NOT applied to UPDATE and DELETE statements
* even if some vendors such as MySQL support it. * even if some vendors such as MySQL support it.
...@@ -102,10 +102,10 @@ class QueryBuilder ...@@ -102,10 +102,10 @@ class QueryBuilder
* @var integer The maximum number of results to retrieve. * @var integer The maximum number of results to retrieve.
*/ */
private $maxResults = null; private $maxResults = null;
/** /**
* The counter of bound parameters used with {@see bindValue) * The counter of bound parameters used with {@see bindValue)
* *
* @var int * @var int
*/ */
private $boundCounter = 0; private $boundCounter = 0;
...@@ -170,14 +170,14 @@ class QueryBuilder ...@@ -170,14 +170,14 @@ class QueryBuilder
{ {
return $this->state; return $this->state;
} }
/** /**
* Execute this query using the bound parameters and their types. * Execute this query using the bound parameters and their types.
* *
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate} * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements. * for insert, update and delete statements.
* *
* @return mixed * @return mixed
*/ */
public function execute() public function execute()
{ {
...@@ -390,7 +390,7 @@ class QueryBuilder ...@@ -390,7 +390,7 @@ class QueryBuilder
} }
$this->sqlParts[$sqlPartName] = $sqlPart; $this->sqlParts[$sqlPartName] = $sqlPart;
return $this; return $this;
} }
...@@ -604,7 +604,7 @@ class QueryBuilder ...@@ -604,7 +604,7 @@ class QueryBuilder
) )
), true); ), true);
} }
/** /**
* Creates and adds a right join to the query. * Creates and adds a right join to the query.
* *
...@@ -939,69 +939,76 @@ class QueryBuilder ...@@ -939,69 +939,76 @@ class QueryBuilder
return $this; return $this;
} }
/** /**
* Converts this instance into a SELECT string in SQL. * Converts this instance into a SELECT string in SQL.
* *
* @return string * @return string
*/ */
private function getSQLForSelect() private function getSQLForSelect()
{ {
$query = 'SELECT ' . implode(', ', $this->sqlParts['select']) . ' FROM '; $query = 'SELECT ' . implode(', ', $this->sqlParts['select']) . ' FROM ';
$fromClauses = array(); $fromClauses = array();
// Loop through all FROM clauses // Loop through all FROM clauses
foreach ($this->sqlParts['from'] as $from) { foreach ($this->sqlParts['from'] as $from) {
$fromClause = $from['table'] . ' ' . $from['alias']; $fromClause = $from['table'] . ' ' . $from['alias'];
if (isset($this->sqlParts['join'][$from['alias']])) { if (isset($this->sqlParts['join'][$from['alias']])) {
foreach ($this->sqlParts['join'][$from['alias']] as $join) { foreach ($this->sqlParts['join'][$from['alias']] as $join) {
$fromClause .= ' ' . strtoupper($join['joinType']) $fromClause .= ' ' . strtoupper($join['joinType'])
. ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias'] . ' JOIN ' . $join['joinTable'] . ' ' . $join['joinAlias']
. ' ON ' . ((string) $join['joinCondition']); . ' 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['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '')
. ($this->sqlParts['groupBy'] ? ' GROUP BY ' . implode(', ', $this->sqlParts['groupBy']) : '') . ($this->sqlParts['groupBy'] ? ' GROUP BY ' . implode(', ', $this->sqlParts['groupBy']) : '')
. ($this->sqlParts['having'] !== null ? ' HAVING ' . ((string) $this->sqlParts['having']) : '') . ($this->sqlParts['having'] !== null ? ' HAVING ' . ((string) $this->sqlParts['having']) : '')
. ($this->sqlParts['orderBy'] ? ' ORDER BY ' . implode(', ', $this->sqlParts['orderBy']) : ''); . ($this->sqlParts['orderBy'] ? ' ORDER BY ' . implode(', ', $this->sqlParts['orderBy']) : '');
return ($this->maxResults === null && $this->firstResult == null) return ($this->maxResults === null && $this->firstResult == null)
? $query ? $query
: $this->connection->getDatabasePlatform()->modifyLimitQuery($query, $this->maxResults, $this->firstResult); : $this->connection->getDatabasePlatform()->modifyLimitQuery($query, $this->maxResults, $this->firstResult);
} }
/** /**
* Converts this instance into an UPDATE string in SQL. * Converts this instance into an UPDATE string in SQL.
* *
* @return string * @return string
*/ */
private function getSQLForUpdate() private function getSQLForUpdate()
{ {
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : ''); $table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : '');
$query = 'UPDATE ' . $table $query = 'UPDATE ' . $table
. ' SET ' . implode(", ", $this->sqlParts['set']) . ' SET ' . implode(", ", $this->sqlParts['set'])
. ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : ''); . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
return $query; return $query;
} }
/** /**
* Converts this instance into a DELETE string in SQL. * Converts this instance into a DELETE string in SQL.
* *
* @return string * @return string
*/ */
private function getSQLForDelete() private function getSQLForDelete()
{ {
$table = $this->sqlParts['from']['table'] . ($this->sqlParts['from']['alias'] ? ' ' . $this->sqlParts['from']['alias'] : ''); $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']) : ''); $query = 'DELETE FROM ' . $table . ($this->sqlParts['where'] !== null ? ' WHERE ' . ((string) $this->sqlParts['where']) : '');
return $query; return $query;
} }
...@@ -1015,7 +1022,7 @@ class QueryBuilder ...@@ -1015,7 +1022,7 @@ class QueryBuilder
{ {
return $this->getSQL(); return $this->getSQL();
} }
/** /**
* Create a new named parameter and bind the value $value to it. * Create a new named parameter and bind the value $value to it.
* *
...@@ -1053,15 +1060,15 @@ class QueryBuilder ...@@ -1053,15 +1060,15 @@ class QueryBuilder
return $placeHolder; return $placeHolder;
} }
/** /**
* Create a new positional parameter and bind the given value to it. * 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 * 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 * 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 * statement , otherwise they get bound in the wrong order which can lead to serious
* bugs in your code. * bugs in your code.
* *
* Example: * Example:
* <code> * <code>
* $qb = $conn->createQueryBuilder(); * $qb = $conn->createQueryBuilder();
...@@ -1070,7 +1077,7 @@ class QueryBuilder ...@@ -1070,7 +1077,7 @@ class QueryBuilder
* ->where('u.username = ' . $qb->createPositionalParameter('Foo', PDO::PARAM_STR)) * ->where('u.username = ' . $qb->createPositionalParameter('Foo', PDO::PARAM_STR))
* ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', PDO::PARAM_STR)) * ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', PDO::PARAM_STR))
* </code> * </code>
* *
* @param mixed $value * @param mixed $value
* @param mixed $type * @param mixed $type
* @return string * @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 ...@@ -61,7 +61,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
} }
$tableIndexes[$k] = $v; $tableIndexes[$k] = $v;
} }
return parent::_getPortableTableIndexesList($tableIndexes, $tableName); return parent::_getPortableTableIndexesList($tableIndexes, $tableName);
} }
...@@ -74,12 +74,12 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -74,12 +74,12 @@ class MySqlSchemaManager extends AbstractSchemaManager
{ {
return $database['Database']; return $database['Database'];
} }
/** /**
* Gets a portable column definition. * Gets a portable column definition.
* *
* The database type is mapped to a corresponding Doctrine mapping type. * The database type is mapped to a corresponding Doctrine mapping type.
* *
* @param $tableColumn * @param $tableColumn
* @return array * @return array
*/ */
...@@ -102,10 +102,10 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -102,10 +102,10 @@ class MySqlSchemaManager extends AbstractSchemaManager
if ( ! isset($tableColumn['name'])) { if ( ! isset($tableColumn['name'])) {
$tableColumn['name'] = ''; $tableColumn['name'] = '';
} }
$scale = null; $scale = null;
$precision = null; $precision = null;
$type = $this->_platform->getDoctrineTypeMapping($dbType); $type = $this->_platform->getDoctrineTypeMapping($dbType);
$type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type); $type = $this->extractDoctrineTypeFromComment($tableColumn['comment'], $type);
$tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type); $tableColumn['comment'] = $this->removeDoctrineTypeFromComment($tableColumn['comment'], $type);
...@@ -154,7 +154,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -154,7 +154,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
'length' => $length, 'length' => $length,
'unsigned' => (bool)$unsigned, 'unsigned' => (bool)$unsigned,
'fixed' => (bool)$fixed, 'fixed' => (bool)$fixed,
'default' => $tableColumn['default'], 'default' => isset($tableColumn['default']) ? $tableColumn['default'] : null,
'notnull' => (bool) ($tableColumn['null'] != 'YES'), 'notnull' => (bool) ($tableColumn['null'] != 'YES'),
'scale' => null, 'scale' => null,
'precision' => null, 'precision' => null,
...@@ -180,7 +180,7 @@ class MySqlSchemaManager extends AbstractSchemaManager ...@@ -180,7 +180,7 @@ class MySqlSchemaManager extends AbstractSchemaManager
if (!isset($tableForeignKey['update_rule']) || $tableForeignKey['update_rule'] == "RESTRICT") { if (!isset($tableForeignKey['update_rule']) || $tableForeignKey['update_rule'] == "RESTRICT") {
$tableForeignKey['update_rule'] = null; $tableForeignKey['update_rule'] = null;
} }
return new ForeignKeyConstraint( return new ForeignKeyConstraint(
(array)$tableForeignKey['column_name'], (array)$tableForeignKey['column_name'],
$tableForeignKey['referenced_table_name'], $tableForeignKey['referenced_table_name'],
......
...@@ -88,11 +88,11 @@ class Table extends AbstractAsset ...@@ -88,11 +88,11 @@ class Table extends AbstractAsset
$this->_setName($tableName); $this->_setName($tableName);
$this->_idGeneratorType = $idGeneratorType; $this->_idGeneratorType = $idGeneratorType;
foreach ($columns AS $column) { foreach ($columns AS $column) {
$this->_addColumn($column); $this->_addColumn($column);
} }
foreach ($indexes AS $idx) { foreach ($indexes AS $idx) {
$this->_addIndex($idx); $this->_addIndex($idx);
} }
...@@ -252,7 +252,7 @@ class Table extends AbstractAsset ...@@ -252,7 +252,7 @@ class Table extends AbstractAsset
/** /**
* Change Column Details * Change Column Details
* *
* @param string $columnName * @param string $columnName
* @param array $options * @param array $options
* @return Table * @return Table
...@@ -266,7 +266,7 @@ class Table extends AbstractAsset ...@@ -266,7 +266,7 @@ class Table extends AbstractAsset
/** /**
* Drop Column from Table * Drop Column from Table
* *
* @param string $columnName * @param string $columnName
* @return Table * @return Table
*/ */
...@@ -344,7 +344,7 @@ class Table extends AbstractAsset ...@@ -344,7 +344,7 @@ class Table extends AbstractAsset
throw SchemaException::columnDoesNotExist($columnName, $this->_name); throw SchemaException::columnDoesNotExist($columnName, $this->_name);
} }
} }
$constraint = new ForeignKeyConstraint( $constraint = new ForeignKeyConstraint(
$localColumnNames, $foreignTableName, $foreignColumnNames, $name, $options $localColumnNames, $foreignTableName, $foreignColumnNames, $name, $options
); );
...@@ -381,7 +381,7 @@ class Table extends AbstractAsset ...@@ -381,7 +381,7 @@ class Table extends AbstractAsset
/** /**
* Add index to table * Add index to table
* *
* @param Index $indexCandidate * @param Index $indexCandidate
* @return Table * @return Table
*/ */
...@@ -422,7 +422,7 @@ class Table extends AbstractAsset ...@@ -422,7 +422,7 @@ class Table extends AbstractAsset
protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint) protected function _addForeignKeyConstraint(ForeignKeyConstraint $constraint)
{ {
$constraint->setLocalTable($this); $constraint->setLocalTable($this);
if(strlen($constraint->getName())) { if(strlen($constraint->getName())) {
$name = $constraint->getName(); $name = $constraint->getName();
} else { } else {
...@@ -475,7 +475,7 @@ class Table extends AbstractAsset ...@@ -475,7 +475,7 @@ class Table extends AbstractAsset
$pkCols = array(); $pkCols = array();
$fkCols = array(); $fkCols = array();
if ($this->hasIndex($this->_primaryKeyName)) { if ($this->hasPrimaryKey()) {
$pkCols = $this->getPrimaryKey()->getColumns(); $pkCols = $this->getPrimaryKey()->getColumns();
} }
foreach ($this->getForeignKeys() AS $fk) { foreach ($this->getForeignKeys() AS $fk) {
...@@ -505,7 +505,7 @@ class Table extends AbstractAsset ...@@ -505,7 +505,7 @@ class Table extends AbstractAsset
/** /**
* Get a column instance * Get a column instance
* *
* @param string $columnName * @param string $columnName
* @return Column * @return Column
*/ */
...@@ -520,10 +520,13 @@ class Table extends AbstractAsset ...@@ -520,10 +520,13 @@ class Table extends AbstractAsset
} }
/** /**
* @return Index * @return Index|null
*/ */
public function getPrimaryKey() public function getPrimaryKey()
{ {
if (!$this->hasPrimaryKey()) {
return null;
}
return $this->getIndex($this->_primaryKeyName); return $this->getIndex($this->_primaryKeyName);
} }
......
...@@ -36,38 +36,38 @@ use Doctrine\DBAL\Platforms\AbstractPlatform, ...@@ -36,38 +36,38 @@ use Doctrine\DBAL\Platforms\AbstractPlatform,
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.org * @link www.doctrine-project.org
* @since 2.0 * @since 2.0
* @version $Revision$
* @author Benjamin Eberlei <kontakt@beberlei.de> * @author Benjamin Eberlei <kontakt@beberlei.de>
*/ */
class DropSchemaSqlCollector implements Visitor 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 * @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/ */
private $_platform = null; private $platform;
/** /**
* @param AbstractPlatform $platform * @param AbstractPlatform $platform
*/ */
public function __construct(AbstractPlatform $platform) public function __construct(AbstractPlatform $platform)
{ {
$this->_platform = $platform; $this->platform = $platform;
$this->clearQueries();
} }
/** /**
...@@ -75,7 +75,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -75,7 +75,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema)
{ {
} }
/** /**
...@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor ...@@ -83,7 +83,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptTable(Table $table) 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 ...@@ -91,7 +91,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptColumn(Table $table, Column $column) public function acceptColumn(Table $table, Column $column)
{ {
} }
/** /**
...@@ -104,7 +104,8 @@ class DropSchemaSqlCollector implements Visitor ...@@ -104,7 +104,8 @@ class DropSchemaSqlCollector implements Visitor
throw SchemaException::namedForeignKeyRequired($localTable, $fkConstraint); 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 ...@@ -113,7 +114,7 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptIndex(Table $table, Index $index) public function acceptIndex(Table $table, Index $index)
{ {
} }
/** /**
...@@ -121,15 +122,17 @@ class DropSchemaSqlCollector implements Visitor ...@@ -121,15 +122,17 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function acceptSequence(Sequence $sequence) 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() 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 ...@@ -137,6 +140,20 @@ class DropSchemaSqlCollector implements Visitor
*/ */
public function getQueries() 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 ...@@ -35,7 +35,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptColumn(Table $table, Column $column) public function acceptColumn(Table $table, Column $column)
{ {
} }
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint) public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
...@@ -53,7 +53,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -53,7 +53,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptIndex(Table $table, Index $index) public function acceptIndex(Table $table, Index $index)
{ {
} }
public function acceptSchema(Schema $schema) public function acceptSchema(Schema $schema)
...@@ -68,7 +68,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -68,7 +68,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
public function acceptSequence(Sequence $sequence) public function acceptSequence(Sequence $sequence)
{ {
} }
public function acceptTable(Table $table) public function acceptTable(Table $table)
...@@ -99,7 +99,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -99,7 +99,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor
$label .= '<FONT COLOR="#2e3436" FACE="Helvetica" POINT-SIZE="12">' . $columnLabel . '</FONT>'; $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><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().'">'; $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 .= "\xe2\x9c\xb7";
} }
$label .= '</TD></TR>'; $label .= '</TD></TR>';
...@@ -139,7 +139,7 @@ class Graphviz implements \Doctrine\DBAL\Schema\Visitor\Visitor ...@@ -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 * You have to convert the output into a viewable format. For example use "neato" on linux systems
* and execute: * and execute:
* *
* neato -Tpng -o er.png er.dot * neato -Tpng -o er.png er.dot
* *
* @param string $filename * @param string $filename
* @return void * @return void
......
...@@ -39,9 +39,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -39,9 +39,9 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10); $sequence = new \Doctrine\DBAL\Schema\Sequence('list_sequences_test_seq', 20, 10);
$this->_sm->createSequence($sequence); $this->_sm->createSequence($sequence);
$sequences = $this->_sm->listSequences(); $sequences = $this->_sm->listSequences();
$this->assertInternalType('array', $sequences, 'listSequences() should return an array.'); $this->assertInternalType('array', $sequences, 'listSequences() should return an array.');
$foundSequence = null; $foundSequence = null;
...@@ -67,7 +67,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -67,7 +67,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$databases = $this->_sm->listDatabases(); $databases = $this->_sm->listDatabases();
$databases = \array_map('strtolower', $databases); $databases = \array_map('strtolower', $databases);
$this->assertEquals(true, \in_array('test_create_database', $databases)); $this->assertEquals(true, \in_array('test_create_database', $databases));
} }
...@@ -163,7 +163,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -163,7 +163,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertEquals(true, $columns['baz2']->getnotnull()); $this->assertEquals(true, $columns['baz2']->getnotnull());
$this->assertEquals(null, $columns['baz2']->getdefault()); $this->assertEquals(null, $columns['baz2']->getdefault());
$this->assertInternalType('array', $columns['baz2']->getPlatformOptions()); $this->assertInternalType('array', $columns['baz2']->getPlatformOptions());
$this->assertEquals('baz3', strtolower($columns['baz3']->getname())); $this->assertEquals('baz3', strtolower($columns['baz3']->getname()));
$this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime')); $this->assertContains($columns['baz2']->gettype()->getName(), array('time', 'date', 'datetime'));
$this->assertEquals(true, $columns['baz3']->getnotnull()); $this->assertEquals(true, $columns['baz3']->getnotnull());
...@@ -250,7 +250,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -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."); $this->assertEquals(1, count($fkConstraints), "Table 'test_create_fk1' has to have one foreign key.");
$fkConstraint = current($fkConstraints); $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('test_foreign', strtolower($fkConstraint->getForeignTableName()));
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns())); $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkConstraint->getColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns())); $this->assertEquals(array('id'), array_map('strtolower', $fkConstraint->getForeignColumns()));
...@@ -276,7 +276,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -276,7 +276,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$fkeys = $this->_sm->listTableForeignKeys('test_create_fk1'); $fkeys = $this->_sm->listTableForeignKeys('test_create_fk1');
$this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key."); $this->assertEquals(1, count($fkeys), "Table 'test_create_fk1' has to have one foreign key.");
$this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]); $this->assertInstanceOf('Doctrine\DBAL\Schema\ForeignKeyConstraint', $fkeys[0]);
$this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns())); $this->assertEquals(array('foreign_key_test'), array_map('strtolower', $fkeys[0]->getLocalColumns()));
$this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns())); $this->assertEquals(array('id'), array_map('strtolower', $fkeys[0]->getForeignColumns()));
...@@ -399,7 +399,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -399,7 +399,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this->assertTrue($inferredTable->hasColumn('id')); $this->assertTrue($inferredTable->hasColumn('id'));
$this->assertTrue($inferredTable->getColumn('id')->getAutoincrement()); $this->assertTrue($inferredTable->getColumn('id')->getAutoincrement());
} }
/** /**
* @group DDC-887 * @group DDC-887
*/ */
...@@ -408,11 +408,11 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -408,11 +408,11 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) { if (!$this->_sm->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('This test is only supported on platforms that have foreign keys.'); $this->markTestSkipped('This test is only supported on platforms that have foreign keys.');
} }
$table = new \Doctrine\DBAL\Schema\Table('test_fk_base'); $table = new \Doctrine\DBAL\Schema\Table('test_fk_base');
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(array('id'));
$tableFK = new \Doctrine\DBAL\Schema\Table('test_fk_rename'); $tableFK = new \Doctrine\DBAL\Schema\Table('test_fk_rename');
$tableFK->setSchemaConfig($this->_sm->createSchemaConfig()); $tableFK->setSchemaConfig($this->_sm->createSchemaConfig());
$tableFK->addColumn('id', 'integer'); $tableFK->addColumn('id', 'integer');
...@@ -420,10 +420,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -420,10 +420,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$tableFK->setPrimaryKey(array('id')); $tableFK->setPrimaryKey(array('id'));
$tableFK->addIndex(array('fk_id'), 'fk_idx'); $tableFK->addIndex(array('fk_id'), 'fk_idx');
$tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id')); $tableFK->addForeignKeyConstraint('test_fk_base', array('fk_id'), array('id'));
$this->_sm->createTable($table); $this->_sm->createTable($table);
$this->_sm->createTable($tableFK); $this->_sm->createTable($tableFK);
$tableFKNew = new \Doctrine\DBAL\Schema\Table('test_fk_rename'); $tableFKNew = new \Doctrine\DBAL\Schema\Table('test_fk_rename');
$tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig()); $tableFKNew->setSchemaConfig($this->_sm->createSchemaConfig());
$tableFKNew->addColumn('id', 'integer'); $tableFKNew->addColumn('id', 'integer');
...@@ -431,10 +431,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest ...@@ -431,10 +431,10 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$tableFKNew->setPrimaryKey(array('id')); $tableFKNew->setPrimaryKey(array('id'));
$tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx'); $tableFKNew->addIndex(array('rename_fk_id'), 'fk_idx');
$tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id')); $tableFKNew->addForeignKeyConstraint('test_fk_base', array('rename_fk_id'), array('id'));
$c = new \Doctrine\DBAL\Schema\Comparator(); $c = new \Doctrine\DBAL\Schema\Comparator();
$tableDiff = $c->diffTable($tableFK, $tableFKNew); $tableDiff = $c->diffTable($tableFK, $tableFKNew);
$this->_sm->alterTable($tableDiff); $this->_sm->alterTable($tableDiff);
} }
......
...@@ -5,13 +5,13 @@ namespace Doctrine\Tests\DBAL\Functional\Schema; ...@@ -5,13 +5,13 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema; use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php'; require_once __DIR__ . '/../../../TestInit.php';
class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
/** /**
* SQLITE does not support databases. * SQLITE does not support databases.
* *
* @expectedException \Exception * @expectedException Doctrine\DBAL\DBALException
*/ */
public function testListDatabases() public function testListDatabases()
{ {
...@@ -29,29 +29,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -29,29 +29,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
} }
/** /**
* @expectedException \Exception * @expectedException Doctrine\DBAL\DBALException
*/
// 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
*/ */
public function testRenameTable() 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 ...@@ -81,7 +81,11 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter; $sql = "SELECT " . $columnName . " FROM type_conversion WHERE id = " . self::$typeCounter;
$actualDbValue = $typeInstance->convertToPHPValue($this->_conn->fetchColumn($sql), $this->_conn->getDatabasePlatform()); $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") { if ($type !== "datetimetz") {
$this->assertEquals($originalValue, $actualDbValue, "Conversion between values should produce the same out as in value, but doesnt!"); $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 ...@@ -156,7 +156,7 @@ class MsSqlPlatformTest extends AbstractPlatformTestCase
public function testModifyLimitQueryWithOffset() public function testModifyLimitQueryWithOffset()
{ {
$sql = $this->_platform->modifyLimitQuery('SELECT * FROM user ORDER BY username DESC', 10, 5); $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() public function testModifyLimitQueryWithAscOrderBy()
......
...@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type; ...@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks; use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php'; require_once __DIR__ . '/../../TestInit.php';
class DateTimeTest extends \Doctrine\Tests\DbalTestCase class DateTimeTest extends \Doctrine\Tests\DbalTestCase
{ {
protected protected
...@@ -24,7 +24,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase ...@@ -24,7 +24,7 @@ class DateTimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10'); $date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString()); $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); $this->assertEquals($expected, $actual);
} }
......
...@@ -24,7 +24,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase ...@@ -24,7 +24,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10'); $date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString()); $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); $this->assertEquals($expected, $actual);
} }
...@@ -36,7 +36,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase ...@@ -36,7 +36,7 @@ class DateTimeTzTest extends \Doctrine\Tests\DbalTestCase
$this->assertInstanceOf('DateTime', $date); $this->assertInstanceOf('DateTime', $date);
$this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s')); $this->assertEquals('1985-09-01 00:00:00', $date->format('Y-m-d H:i:s'));
} }
public function testInvalidDateFormatConversion() public function testInvalidDateFormatConversion()
{ {
$this->setExpectedException('Doctrine\DBAL\Types\ConversionException'); $this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
......
...@@ -27,7 +27,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase ...@@ -27,7 +27,7 @@ class VarDateTimeTest extends \Doctrine\Tests\DbalTestCase
$date = new \DateTime('1985-09-01 10:10:10'); $date = new \DateTime('1985-09-01 10:10:10');
$expected = $date->format($this->_platform->getDateTimeTzFormatString()); $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); $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