Commit b066e54f authored by Benjamin Eberlei's avatar Benjamin Eberlei

Remove all trailing whitespaces

parent 2e02241c
......@@ -84,7 +84,7 @@ class QueryCacheProfile
/**
* Generate the real cache key from query, params and types.
*
*
* @param string $query
* @param array $params
* @param array $types
......
......@@ -68,7 +68,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
/**
* Did we reach the end of the statement?
*
*
* @var bool
*/
private $emptied = false;
......@@ -179,7 +179,7 @@ class ResultCacheStatement implements \IteratorAggregate, ResultStatement
$row = $this->statement->fetch(PDO::FETCH_ASSOC);
if ($row) {
$this->data[] = $row;
if ($fetchStyle == PDO::FETCH_ASSOC) {
return $row;
} else if ($fetchStyle == PDO::FETCH_NUM) {
......
<?php
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
......@@ -54,7 +54,7 @@ class Configuration
/**
* Gets the SQL logger that is used.
*
*
* @return SQLLogger
*/
public function getSQLLogger()
......
......@@ -36,7 +36,7 @@ class ConnectionException extends DBALException
{
return new self("Transaction commit failed because the transaction has been marked for rollback only.");
}
public static function noActiveTransaction()
{
return new self("There is no active transaction.");
......
......@@ -24,7 +24,7 @@ namespace Doctrine\DBAL\Driver;
* Driver connections must implement this interface.
*
* This resembles (a subset of) the PDO interface.
*
*
* @since 2.0
*/
interface Connection
......
......@@ -42,7 +42,7 @@ class DB2Driver implements Driver
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
if ( !isset($params['schema']) ) {
}
if ($params['host'] !== 'localhost' && $params['host'] != '127.0.0.1') {
......
......@@ -23,5 +23,5 @@ namespace Doctrine\DBAL\Driver\IBMDB2;
class DB2Exception extends \Exception
{
}
\ No newline at end of file
......@@ -179,7 +179,7 @@ class MysqliStatement implements \IteratorAggregate, Statement
/**
* Bind a array of values to bound parameters
*
*
* @param array $values
* @return boolean
*/
......
......@@ -32,7 +32,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
/**
* Create a Connection to an Oracle Database using oci8 extension.
*
*
* @param string $username
* @param string $password
* @param string $db
......@@ -51,7 +51,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
/**
* Create a non-executed prepared statement.
*
*
* @param string $prepareString
* @return OCI8Statement
*/
......@@ -78,7 +78,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
* Quote input value.
*
* @param mixed $input
* @param int $type PDO::PARAM*
* @param int $type PDO::PARAM*
* @return mixed
*/
public function quote($value, $type=\PDO::PARAM_STR)
......@@ -101,7 +101,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
$stmt->execute();
return $stmt->rowCount();
}
public function lastInsertId($name = null)
{
//TODO: throw exception or support sequences?
......@@ -147,7 +147,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
$this->_executeMode = OCI_COMMIT_ON_SUCCESS;
return true;
}
public function errorCode()
{
$error = oci_error($this->_dbh);
......@@ -156,7 +156,7 @@ class OCI8Connection implements \Doctrine\DBAL\Driver\Connection
}
return $error;
}
public function errorInfo()
{
return oci_error($this->_dbh);
......
......@@ -80,7 +80,7 @@ class Driver implements \Doctrine\DBAL\Driver
} else if (isset($params['memory'])) {
$dsn .= ':memory:';
}
return $dsn;
}
......
......@@ -34,12 +34,12 @@ class Connection extends \Doctrine\DBAL\Driver\PDOConnection implements \Doctrin
public function quote($value, $type=\PDO::PARAM_STR)
{
$val = parent::quote($value, $type);
// Fix for a driver version terminating all values with null byte
if (strpos($val, "\0") !== false) {
$val = substr($val, 0, -1);
}
return $val;
}
}
\ No newline at end of file
......@@ -29,7 +29,7 @@ namespace Doctrine\DBAL\Driver\PDOSqlsrv;
class Driver implements \Doctrine\DBAL\Driver
{
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
{
return new Connection(
$this->_constructPdoDsn($params),
$username,
......@@ -46,19 +46,19 @@ class Driver implements \Doctrine\DBAL\Driver
private function _constructPdoDsn(array $params)
{
$dsn = 'sqlsrv:server=';
if (isset($params['host'])) {
$dsn .= $params['host'];
}
if (isset($params['port']) && !empty($params['port'])) {
$dsn .= ',' . $params['port'];
}
if (isset($params['dbname'])) {
$dsn .= ';Database=' . $params['dbname'];
}
return $dsn;
}
......
......@@ -24,9 +24,9 @@ use \PDO;
/**
* Statement interface.
* Drivers must implement this interface.
*
*
* This resembles (a subset of) the PDOStatement interface.
*
*
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Roman Borschel <roman@code-factory.org>
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
......@@ -51,13 +51,13 @@ interface Statement extends ResultStatement
function bindValue($param, $value, $type = null);
/**
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* Binds a PHP variable to a corresponding named or question mark placeholder in the
* SQL statement that was use to prepare the statement. Unlike PDOStatement->bindValue(),
* the variable is bound as a reference and will only be evaluated at the time
* the variable is bound as a reference and will only be evaluated at the time
* that PDOStatement->execute() is called.
*
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* Most parameters are input parameters, that is, parameters that are
* used in a read-only fashion to build up the query. Some drivers support the invocation
* of stored procedures that return data as output parameters, and some also as input/output
* parameters that both send in data and are updated to receive it.
*
......@@ -76,7 +76,7 @@ interface Statement extends ResultStatement
/**
* errorCode
* Fetch the SQLSTATE associated with the last operation on the statement handle
* Fetch the SQLSTATE associated with the last operation on the statement handle
*
* @see Doctrine_Adapter_Interface::errorCode()
* @return string error code string
......
......@@ -56,7 +56,7 @@ class SchemaAlterTableChangeColumnEventArgs extends SchemaEventArgs
/**
* @param \Doctrine\DBAL\Schema\ColumnDiff $columnDiff
* @param \Doctrine\DBAL\Schema\TableDiff $tableDiff
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*/
public function __construct(ColumnDiff $columnDiff, TableDiff $tableDiff, AbstractPlatform $platform)
{
......
......@@ -51,7 +51,7 @@ class SchemaCreateTableEventArgs extends SchemaEventArgs
* @var \Doctrine\DBAL\Platforms\AbstractPlatform
*/
private $_platform = null;
/**
* @var array
*/
......
......@@ -412,7 +412,7 @@ abstract class AbstractPlatform
{
throw DBALException::notSupported(__METHOD__);
}
/**
* Returns global unique identifier
*
......
......@@ -34,7 +34,7 @@ class DB2Keywords extends KeywordList
{
return 'DB2';
}
protected function getKeywords()
{
return array(
......@@ -435,5 +435,4 @@ class DB2Keywords extends KeywordList
);
}
}
\ No newline at end of file
......@@ -31,32 +31,32 @@ namespace Doctrine\DBAL\Platforms\Keywords;
abstract class KeywordList
{
private $keywords = null;
/**
* Check if the given word is a keyword of this dialect/vendor platform.
*
*
* @param string $word
* @return bool
* @return bool
*/
public function isKeyword($word)
{
if ($this->keywords === null) {
$this->initializeKeywords();
}
return isset($this->keywords[strtoupper($word)]);
}
protected function initializeKeywords()
{
$this->keywords = array_flip(array_map('strtoupper', $this->getKeywords()));
}
abstract protected function getKeywords();
/**
* Name of this keyword list.
*
*
* @return string
*/
abstract public function getName();
......
......@@ -35,7 +35,7 @@ class MsSQLKeywords extends KeywordList
{
return 'MsSQL';
}
protected function getKeywords()
{
return array(
......
......@@ -35,7 +35,7 @@ class MySQLKeywords extends KeywordList
{
return 'MySQL';
}
protected function getKeywords()
{
return array(
......
......@@ -35,7 +35,7 @@ class OracleKeywords extends KeywordList
{
return 'Oracle';
}
protected function getKeywords()
{
return array(
......
......@@ -35,7 +35,7 @@ class PostgreSQLKeywords extends KeywordList
{
return 'PostgreSQL';
}
protected function getKeywords()
{
return array(
......
......@@ -34,22 +34,22 @@ class ReservedKeywordsValidator implements Visitor
* @var KeywordList[]
*/
private $keywordLists = array();
/**
* @var array
*/
private $violations = array();
public function __construct(array $keywordLists)
{
$this->keywordLists = $keywordLists;
}
public function getViolations()
{
return $this->violations;
}
/**
* @param string $word
* @return array
......@@ -59,7 +59,7 @@ class ReservedKeywordsValidator implements Visitor
if ($word[0] == "`") {
$word = str_replace('`', '', $word);
}
$keywordLists = array();
foreach ($this->keywordLists AS $keywordList) {
if ($keywordList->isKeyword($word)) {
......@@ -68,16 +68,16 @@ class ReservedKeywordsValidator implements Visitor
}
return $keywordLists;
}
private function addViolation($asset, $violatedPlatforms)
{
if (!$violatedPlatforms) {
return;
}
$this->violations[] = $asset . ' keyword violations: ' . implode(', ', $violatedPlatforms);
}
public function acceptColumn(Table $table, Column $column)
{
$this->addViolation(
......@@ -88,7 +88,7 @@ class ReservedKeywordsValidator implements Visitor
public function acceptForeignKey(Table $localTable, ForeignKeyConstraint $fkConstraint)
{
}
public function acceptIndex(Table $table, Index $index)
......@@ -98,12 +98,12 @@ class ReservedKeywordsValidator implements Visitor
public function acceptSchema(Schema $schema)
{
}
public function acceptSequence(Sequence $sequence)
{
}
public function acceptTable(Table $table)
......
......@@ -34,7 +34,7 @@ class SQLiteKeywords extends KeywordList
{
return 'SQLite';
}
protected function getKeywords()
{
return array(
......
......@@ -320,11 +320,11 @@ class MsSqlPlatform extends AbstractPlatform
$queryParts[] = 'ALTER COLUMN ' .
$this->getColumnDeclarationSQL($column->getQuotedName($this), $column->toArray());
}
$tableSql = array();
if ($this->onSchemaAlterTable($diff, $tableSql)) {
return array_merge($tableSql, $columnSql);
return array_merge($tableSql, $columnSql);
}
foreach ($queryParts as $query) {
......
......@@ -504,7 +504,7 @@ class MySqlPlatform extends AbstractPlatform
$sql = array();
$tableSql = array();
if (!$this->onSchemaAlterTable($diff, $tableSql)) {
if (count($queryParts) > 0) {
$sql[] = 'ALTER TABLE ' . $diff->name . ' ' . implode(", ", $queryParts);
......
......@@ -161,8 +161,8 @@ class OraclePlatform extends AbstractPlatform
*/
public function getBitOrComparisonExpression($value1, $value2)
{
return '(' . $value1 . '-' .
$this->getBitAndComparisonExpression($value1, $value2)
return '(' . $value1 . '-' .
$this->getBitAndComparisonExpression($value1, $value2)
. '+' . $value2 . ')';
}
......
......@@ -32,26 +32,26 @@ class Connection extends \Doctrine\DBAL\Connection
const PORTABILITY_RTRIM = 1;
const PORTABILITY_EMPTY_TO_NULL = 4;
const PORTABILITY_FIX_CASE = 8;
const PORTABILITY_ORACLE = 9;
const PORTABILITY_POSTGRESQL = 13;
const PORTABILITY_SQLITE = 13;
const PORTABILITY_OTHERVENDORS = 12;
/**
* @var int
*/
private $portability = self::PORTABILITY_NONE;
/**
* @var int
*/
private $case;
public function connect()
{
$ret = parent::connect();
if ($ret) {
if ($ret) {
$params = $this->getParams();
if (isset($params['portability'])) {
if ($this->_platform->getName() === "oracle") {
......@@ -72,26 +72,26 @@ class Connection extends \Doctrine\DBAL\Connection
} else {
$this->case = ($params['fetch_case'] == \PDO::CASE_LOWER) ? CASE_LOWER : CASE_UPPER;
}
}
}
}
return $ret;
}
public function getPortability()
{
return $this->portability;
}
public function getFetchCase()
{
return $this->case;
}
public function executeQuery($query, array $params = array(), $types = array(), QueryCacheProfile $qcp = null)
{
return new Statement(parent::executeQuery($query, $params, $types, $qcp), $this);
}
/**
* Prepares an SQL statement.
*
......@@ -102,7 +102,7 @@ class Connection extends \Doctrine\DBAL\Connection
{
return new Statement(parent::prepare($statement), $this);
}
public function query()
{
$this->connect();
......
......@@ -48,7 +48,7 @@ class Statement implements \IteratorAggregate, \Doctrine\DBAL\Driver\Statement
*/
private $case;
/**
/**
* @var int
*/
private $defaultFetchStyle = PDO::FETCH_BOTH;
......
......@@ -34,40 +34,40 @@ class CompositeExpression implements \Countable
* Constant that represents an AND composite expression
*/
const TYPE_AND = 'AND';
/**
* Constant that represents an OR composite expression
*/
const TYPE_OR = 'OR';
/**
* @var string Holds the instance type of composite expression
*/
private $type;
/**
* @var array Each expression part of the composite expression
*/
private $parts = array();
/**
* Constructor.
*
*
* @param string $type Instance type of composite expression
* @param array $parts Composition of expressions to be joined on composite expression
*/
public function __construct($type, array $parts = array())
{
$this->type = $type;
$this->addMultiple($parts);
}
/**
* Adds multiple parts to composite expression.
*
*
* @param array $args
*
*
* @return CompositeExpression
*/
public function addMultiple(array $parts = array())
......@@ -75,38 +75,38 @@ class CompositeExpression implements \Countable
foreach ((array) $parts as $part) {
$this->add($part);
}
return $this;
}
/**
* Adds an expression to composite expression.
*
*
* @param mixed $part
* @return CompositeExpression
* @return CompositeExpression
*/
public function add($part)
{
if ( ! empty($part) || ($part instanceof self && $part->count() > 0)) {
$this->parts[] = $part;
}
return $this;
}
/**
* Retrieves the amount of expressions on composite expression.
*
* @return integer
*
* @return integer
*/
public function count()
{
return count($this->parts);
}
/**
* Retrieve the string representation of this composite expression.
*
*
* @return string
*/
public function __toString()
......@@ -114,13 +114,13 @@ class CompositeExpression implements \Countable
if (count($this->parts) === 1) {
return (string) $this->parts[0];
}
return '(' . implode(') ' . $this->type . ' (', $this->parts) . ')';
}
/**
* Return type of this composite expression (AND/OR)
*
*
* @return string
*/
public function getType()
......
......@@ -38,7 +38,7 @@ class ExpressionBuilder
const LTE = '<=';
const GT = '>';
const GTE = '>=';
/**
* @var Doctrine\DBAL\Connection DBAL Connection
*/
......@@ -53,7 +53,7 @@ class ExpressionBuilder
{
$this->connection = $connection;
}
/**
* Creates a conjunction of the given boolean expressions.
*
......@@ -92,7 +92,7 @@ class ExpressionBuilder
/**
* Creates a comparison expression.
*
*
* @param mixed $x Left expression
* @param string $operator One of the ExpressionBuikder::* constants.
* @param mixed $y Right expression
......@@ -102,7 +102,7 @@ class ExpressionBuilder
{
return $x . ' ' . $operator . ' ' . $y;
}
/**
* Creates an equality comparison expression with the given arguments.
*
......@@ -216,7 +216,7 @@ class ExpressionBuilder
* Creates an IS NULL expression with the given arguments.
*
* @param string $x Field in string format to be restricted by IS NULL
*
*
* @return string
*/
public function isNull($x)
......@@ -228,7 +228,7 @@ class ExpressionBuilder
* Creates an IS NOT NULL expression with the given arguments.
*
* @param string $x Field in string format to be restricted by IS NOT NULL
*
*
* @return string
*/
public function isNotNull($x)
......@@ -241,20 +241,20 @@ class ExpressionBuilder
*
* @param string $x Field in string format to be inspected by LIKE() comparison.
* @param mixed $y Argument to be used in LIKE() comparison.
*
*
* @return string
*/
public function like($x, $y)
{
return $this->comparison($x, 'LIKE', $y);
}
/**
* Quotes a given input parameter.
*
*
* @param mixed $input Parameter to be quoted.
* @param string $type Type of the parameter.
*
*
* @return string
*/
public function literal($input, $type = null)
......
......@@ -34,21 +34,21 @@ class SQLParserUtils
{
/**
* Get an array of the placeholders in an sql statements as keys and their positions in the query string.
*
*
* Returns an integer => integer pair (indexed from zero) for a positional statement
* and a string => int[] pair for a named statement.
*
*
* @param string $statement
* @param bool $isPositional
* @return array
*/
static public function getPlaceholderPositions($statement, $isPositional = true)
{
{
$match = ($isPositional) ? '?' : ':';
if (strpos($statement, $match) === false) {
return array();
}
$count = 0;
$inLiteral = false; // a valid query never starts with quotes
$stmtLen = strlen($statement);
......@@ -75,16 +75,16 @@ class SQLParserUtils
return $paramMap;
}
/**
* For a positional query this method can rewrite the sql statement with regard to array parameters.
*
*
* @param string $query
* @param array $params
* @param array $types
* @param array $types
*/
static public function expandListParameters($query, $params, $types)
{
{
$isPositional = is_int(key($params));
$arrayPositions = array();
$bindIndex = -1;
......@@ -94,15 +94,15 @@ class SQLParserUtils
if ($isPositional) {
$name = $bindIndex;
}
$arrayPositions[$name] = false;
}
}
if ((!$arrayPositions && $isPositional) || (count($params) != count($types))) {
return array($query, $params, $types);
}
$paramPos = self::getPlaceholderPositions($query, $isPositional);
if ($isPositional) {
$paramOffset = 0;
......@@ -111,30 +111,30 @@ class SQLParserUtils
if (!isset($arrayPositions[$needle])) {
continue;
}
$needle += $paramOffset;
$needlePos += $queryOffset;
$len = count($params[$needle]);
$params = array_merge(
array_slice($params, 0, $needle),
$params[$needle],
array_slice($params, $needle + 1)
);
$types = array_merge(
array_slice($types, 0, $needle),
array_fill(0, $len, $types[$needle] - Connection::ARRAY_PARAM_OFFSET), // array needles are at PDO::PARAM_* + 100
array_slice($types, $needle + 1)
);
$expandStr = implode(", ", array_fill(0, $len, "?"));
$query = substr($query, 0, $needlePos) . $expandStr . substr($query, $needlePos + 1);
$paramOffset += ($len - 1); // Grows larger by number of parameters minus the replaced needle.
$queryOffset += (strlen($expandStr) - 1);
}
} else {
$queryOffset= 0;
$typesOrd = array();
......@@ -144,7 +144,7 @@ class SQLParserUtils
$token = substr($needle,0,1);
$needle = substr($needle,1);
$value = $params[$needle];
if (!isset($arrayPositions[$needle])) {
foreach ($needlePos as $pos) {
$pos += $queryOffset;
......@@ -157,23 +157,23 @@ class SQLParserUtils
$len = count($value);
$expandStr = implode(", ", array_fill(0, $len, "?"));
foreach ($needlePos as $pos) {
foreach ($value as $val) {
$paramsOrd[] = $val;
$typesOrd[] = $types[$needle] - Connection::ARRAY_PARAM_OFFSET;
}
$pos += $queryOffset;
$queryOffset += (strlen($expandStr) - $paramLen);
$query = substr($query, 0, $pos) . $expandStr . substr($query, ($pos + $paramLen));
}
}
}
$types = $typesOrd;
$params = $paramsOrd;
}
return array($query, $params, $types);
}
}
\ No newline at end of file
......@@ -76,7 +76,7 @@ abstract class AbstractSchemaManager
}
/**
* Try any method on the schema manager. Normally a method throws an
* Try any method on the schema manager. Normally a method throws an
* exception when your DBMS doesn't support it or if an error occurs.
* This method allows you to try and method on your SchemaManager
* instance and will return false if it does not work or is not supported.
......@@ -178,7 +178,7 @@ abstract class AbstractSchemaManager
/**
* Return true if all the given tables exist.
*
*
* @param array $tableNames
* @return bool
*/
......@@ -271,7 +271,7 @@ abstract class AbstractSchemaManager
/**
* Drops a database.
*
*
* NOTE: You can not drop the database this SchemaManager is currently connected to.
*
* @param string $database The name of the database to drop
......@@ -793,7 +793,7 @@ abstract class AbstractSchemaManager
/**
* Create a schema instance for the current database.
*
*
* @return Schema
*/
public function createSchema()
......@@ -823,7 +823,7 @@ abstract class AbstractSchemaManager
/**
* Given a table comment this method tries to extract a typehint for Doctrine Type, or returns
* the type given as default.
*
*
* @param string $comment
* @param string $currentType
* @return string
......
......@@ -100,7 +100,7 @@ class Column extends AbstractAsset
/**
* Create a new Column
*
*
* @param string $columnName
* @param Doctrine\DBAL\Types\Type $type
* @param int $length
......
......@@ -163,7 +163,7 @@ class Comparator
$changes++;
}
}
foreach ( $table1Columns as $columnName => $column ) {
if ( $table2->hasColumn($columnName) ) {
$changedProperties = $this->diffColumn( $column, $table2->getColumn($columnName) );
......@@ -241,7 +241,7 @@ class Comparator
/**
* Try to find columns that only changed their name, rename operations maybe cheaper than add/drop
* however ambiguouties between different possibilites should not lead to renaming at all.
*
*
* @param TableDiff $tableDifferences
*/
private function detectColumnRenamings(TableDiff $tableDifferences)
......@@ -278,7 +278,7 @@ class Comparator
if (array_map('strtolower', $key1->getLocalColumns()) != array_map('strtolower', $key2->getLocalColumns())) {
return true;
}
if (array_map('strtolower', $key1->getForeignColumns()) != array_map('strtolower', $key2->getForeignColumns())) {
return true;
}
......
......@@ -48,7 +48,7 @@ class DB2SchemaManager extends AbstractSchemaManager
$sql .= " AND CREATOR = UPPER('".$this->_conn->getUsername()."')";
$tables = $this->_conn->fetchAll($sql);
return $this->_getPortableTablesList($tables);
}
......@@ -70,7 +70,7 @@ class DB2SchemaManager extends AbstractSchemaManager
$precision = false;
$type = $this->_platform->getDoctrineTypeMapping($tableColumn['typename']);
switch (strtolower($tableColumn['typename'])) {
case 'varchar':
$length = $tableColumn['length'];
......
......@@ -76,10 +76,10 @@ class Index extends AbstractAsset implements Constraint
{
return $this->_columns;
}
/**
* Is the index neither unique nor primary key?
*
*
* @return bool
*/
public function isSimpleIndex()
......
......@@ -89,7 +89,7 @@ class OracleSchemaManager extends AbstractSchemaManager
protected function _getPortableTableColumnDefinition($tableColumn)
{
$tableColumn = \array_change_key_case($tableColumn, CASE_LOWER);
$dbType = strtolower($tableColumn['data_type']);
if(strpos($dbType, "timestamp(") === 0) {
if (strpos($dbType, "WITH TIME ZONE")) {
......
......@@ -40,7 +40,7 @@ class Schema extends AbstractAsset
* @var array
*/
protected $_tables = array();
/**
* @var array
*/
......@@ -109,7 +109,7 @@ class Schema extends AbstractAsset
/**
* Get all tables of this schema.
*
*
* @return array
*/
public function getTables()
......@@ -133,7 +133,7 @@ class Schema extends AbstractAsset
/**
* Does this schema have a table with the given name?
*
*
* @param string $tableName
* @return Schema
*/
......@@ -177,7 +177,7 @@ class Schema extends AbstractAsset
/**
* Create a new table
*
*
* @param string $tableName
* @return Table
*/
......@@ -221,7 +221,7 @@ class Schema extends AbstractAsset
/**
* Create a new sequence
*
*
* @param string $sequenceName
* @param int $allocationSize
* @param int $initialValue
......@@ -301,7 +301,7 @@ class Schema extends AbstractAsset
public function visit(Visitor $visitor)
{
$visitor->acceptSchema($this);
foreach ($this->_tables AS $table) {
$table->visit($visitor);
}
......
......@@ -66,7 +66,7 @@ class Sequence extends AbstractAsset
{
return $this->_initialValue;
}
public function setAllocationSize($allocationSize)
{
$this->_allocationSize = (is_numeric($allocationSize))?$allocationSize:1;
......
......@@ -33,7 +33,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
{
/**
* {@inheritdoc}
*
*
* @override
*/
public function dropDatabase($database)
......@@ -45,7 +45,7 @@ class SqliteSchemaManager extends AbstractSchemaManager
/**
* {@inheritdoc}
*
*
* @override
*/
public function createDatabase($database)
......
......@@ -83,7 +83,7 @@ class CreateSchemaSqlCollector implements Visitor
public function acceptColumn(Table $table, Column $column)
{
}
/**
......@@ -108,7 +108,7 @@ class CreateSchemaSqlCollector implements Visitor
*/
public function acceptIndex(Table $table, Index $index)
{
}
/**
......
......@@ -37,18 +37,18 @@ class ReservedWordsCommand extends Command
'oracle' => 'Doctrine\DBAL\Platforms\Keywords\OracleKeywords',
'db2' => 'Doctrine\DBAL\Platforms\Keywords\DB2Keywords',
);
/**
* If you want to add or replace a keywords list use this command
*
*
* @param string $name
* @param string $class
* @param string $class
*/
public function setKeywordListClass($name, $class)
{
$this->keywordListClasses[$name] = $class;
}
/**
* @see Console\Command\Command
*/
......@@ -70,12 +70,12 @@ By default SQLite, MySQL, PostgreSQL, MsSQL and Oracle
keywords are checked:
<info>doctrine dbal:reserved-words</info>
If you want to check against specific dialects you can
pass them to the command:
<info>doctrine dbal:reserved-words mysql pgsql</info>
The following keyword lists are currently shipped with Doctrine:
* mysql
......@@ -87,7 +87,7 @@ The following keyword lists are currently shipped with Doctrine:
EOT
);
}
/**
* @see Console\Command\Command
*/
......@@ -95,12 +95,12 @@ EOT
{
/* @var $conn Doctrine\DBAL\Connection */
$conn = $this->getHelper('db')->getConnection();
$keywordLists = (array)$input->getOption('list');
if (!$keywordLists) {
$keywordLists = array('mysql', 'pgsql', 'sqlite', 'oracle', 'mssql');
}
$keywords = array();
foreach ($keywordLists AS $keywordList) {
if (!isset($this->keywordListClasses[$keywordList])) {
......@@ -112,14 +112,14 @@ EOT
$class = $this->keywordListClasses[$keywordList];
$keywords[] = new $class;
}
$output->write('Checking keyword violations for <comment>' . implode(", ", $keywordLists) . "</comment>...", true);
/* @var $schema \Doctrine\DBAL\Schema\Schema */
$schema = $conn->getSchemaManager()->createSchema();
$visitor = new ReservedKeywordsValidator($keywords);
$schema->visit($visitor);
$violations = $visitor->getViolations();
if (count($violations) == 0) {
$output->write("No reserved keywords violations have been found!", true);
......
......@@ -39,7 +39,7 @@ class BooleanType extends Type
{
return $platform->convertBooleans($value);
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
return (null === $value) ? null : (bool) $value;
......
......@@ -35,7 +35,7 @@ class ConversionException extends \Doctrine\DBAL\DBALException
{
/**
* Thrown when a Database to Doctrine Type Conversion fails.
*
*
* @param string $value
* @param string $toType
* @return ConversionException
......@@ -45,11 +45,11 @@ class ConversionException extends \Doctrine\DBAL\DBALException
$value = (strlen($value) > 32) ? substr($value, 0, 20) . "..." : $value;
return new self('Could not convert database value "' . $value . '" to Doctrine Type ' . $toType);
}
/**
* Thrown when a Database to Doctrine Type Conversion fails and we can make a statement
* about the expected format.
*
*
* @param string $value
* @param string $toType
* @return ConversionException
......
......@@ -43,7 +43,7 @@ class DateTimeType extends Type
return ($value !== null)
? $value->format($platform->getDateTimeFormatString()) : null;
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
......
......@@ -52,7 +52,7 @@ class DateTimeTzType extends Type
{
return Type::DATETIMETZ;
}
public function getSQLDeclaration(array $fieldDeclaration, AbstractPlatform $platform)
{
return $platform->getDateTimeTzTypeDeclarationSQL($fieldDeclaration);
......
......@@ -40,10 +40,10 @@ class DateType extends Type
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return ($value !== null)
return ($value !== null)
? $value->format($platform->getDateFormatString()) : null;
}
public function convertToPHPValue($value, AbstractPlatform $platform)
{
if ($value === null) {
......
......@@ -46,7 +46,7 @@ class TimeType extends Type
*/
public function convertToDatabaseValue($value, AbstractPlatform $platform)
{
return ($value !== null)
return ($value !== null)
? $value->format($platform->getTimeFormatString()) : null;
}
......
......@@ -16,7 +16,7 @@
* and is licensed under the LGPL. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\DBAL;
/**
......@@ -42,7 +42,7 @@ class Version
* Compares a Doctrine version with the current one.
*
* @param string $version Doctrine version to compare.
* @return int Returns -1 if older, 0 if it is the same, 1 if version
* @return int Returns -1 if older, 0 if it is the same, 1 if version
* passed as argument is newer.
*/
public static function compare($version)
......
......@@ -8,7 +8,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Configuration;
use Doctrine\DBAL\Events;
class ConnectionTest extends \Doctrine\Tests\DbalTestCase
{
/**
......
......@@ -3,7 +3,7 @@
namespace Doctrine\Tests\DBAL;
require_once __DIR__ . '/../../../TestInit.php';
class OCI8StatementTest extends \Doctrine\Tests\DbalTestCase
{
public function setUp()
......@@ -11,7 +11,7 @@ class OCI8StatementTest extends \Doctrine\Tests\DbalTestCase
if (!extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.');
}
parent::setUp();
}
......@@ -21,7 +21,7 @@ class OCI8StatementTest extends \Doctrine\Tests\DbalTestCase
$statement = "update table set field1 = ?, field2 = ? where field3 = ?";
$executeMode = OCI_COMMIT_ON_SUCCESS;
return $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Statement',
return $this->getMock('\Doctrine\DBAL\Driver\OCI8\OCI8Statement',
array('bindValue', 'errorInfo'),
array(null, $statement, $executeMode), '', false);
}
......@@ -29,7 +29,7 @@ class OCI8StatementTest extends \Doctrine\Tests\DbalTestCase
/**
* This scenario shows that when the first parameter is not null
* it properly sets $hasZeroIndex to 1 and calls bindValue starting at 1.
*
*
* The expected exception is due to oci_execute failing due to no valid connection.
*
* @dataProvider executeDataProvider
......
......@@ -3,7 +3,7 @@
namespace Doctrine\Tests\DBAL;
require_once __DIR__ . '/../TestInit.php';
class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
{
/**
......
......@@ -39,7 +39,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
try {
$this->_conn->beginTransaction();
$this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
try {
$this->_conn->beginTransaction();
$this->assertEquals(2, $this->_conn->getTransactionNestingLevel());
......@@ -48,7 +48,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
} catch (\Exception $e) {
$this->_conn->rollback();
$this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
//no rethrow
//no rethrow
}
$this->assertTrue($this->_conn->isRollbackOnly());
......@@ -164,9 +164,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
try {
$this->_conn->beginTransaction();
$this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
throw new \Exception;
$this->_conn->commit(); // never reached
} catch (\Exception $e) {
$this->assertEquals(1, $this->_conn->getTransactionNestingLevel());
......
......@@ -185,7 +185,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt->closeCursor();
return $data;
}
private function hydrateStmtIterator($stmt, $fetchStyle = \PDO::FETCH_ASSOC)
{
$data = array();
......
......@@ -5,8 +5,8 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class MsSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testSwitchPrimaryKeyColumns()
......@@ -41,7 +41,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->_sm->createTable($table);
$tableFetched = $this->_sm->listTableDetails("diffbug_routing_translations");
$comparator = new \Doctrine\DBAL\Schema\Comparator;
$diff = $comparator->diffTable($tableFetched, $table);
......
......@@ -5,7 +5,7 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\Schema;
require_once __DIR__ . '/../../../TestInit.php';
class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function setUp()
......
......@@ -35,7 +35,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
$this->_sm->renameTable('oldname', 'newname');
}
public function testAutoincrementDetection()
{
$this->markTestSkipped(
......
......@@ -81,7 +81,7 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
foreach ($platform->getCreateTableSQL($table) AS $sql) {
$this->_conn->executeQuery($sql);
}
$this->_conn->beginTransaction();
$this->_conn->insert("nontemporary", array("id" => 1));
......
......@@ -39,7 +39,7 @@ class TypeConversionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_conn->executeQuery($sql);
}
} catch(\Exception $e) {
}
}
......
......@@ -243,7 +243,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
$this->_platform->getDropTableSQL('TABLE');
}
public function testGetAlterTableSqlDispatchEvent()
{
$events = array(
......@@ -335,7 +335,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
$this->markTestSkipped('Platform does not support Column comments.');
}
/**
* @group DBAL-45
*/
......@@ -343,7 +343,7 @@ abstract class AbstractPlatformTestCase extends \Doctrine\Tests\DbalTestCase
{
$keywordList = $this->_platform->getReservedKeywordsList();
$this->assertInstanceOf('Doctrine\DBAL\Platforms\Keywords\KeywordList', $keywordList);
$this->assertTrue($keywordList->isKeyword('table'));
}
}
......@@ -8,7 +8,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\Schema;
require_once __DIR__ . '/../../TestInit.php';
class MySqlPlatformTest extends AbstractPlatformTestCase
{
public function createPlatform()
......@@ -129,7 +129,7 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
public function testDoesSupportSavePoints()
{
$this->assertTrue($this->_platform->supportsSavepoints());
$this->assertTrue($this->_platform->supportsSavepoints());
}
public function getGenerateIndexSql()
......@@ -146,27 +146,27 @@ class MySqlPlatformTest extends AbstractPlatformTestCase
{
return 'ALTER TABLE test ADD FOREIGN KEY (fk_name_id) REFERENCES other_table (id)';
}
/**
* @group DBAL-126
*/
public function testUniquePrimaryKey()
{
{
$keyTable = new Table("foo");
$keyTable->addColumn("bar", "integer");
$keyTable->addColumn("baz", "string");
$keyTable->setPrimaryKey(array("bar"));
$keyTable->addUniqueIndex(array("baz"));
$oldTable = new Table("foo");
$oldTable->addColumn("bar", "integer");
$oldTable->addColumn("baz", "string");
$c = new \Doctrine\DBAL\Schema\Comparator;
$diff = $c->diffTable($oldTable, $keyTable);
$sql = $this->_platform->getAlterTableSQL($diff);
$this->assertEquals(array(
"ALTER TABLE foo ADD PRIMARY KEY (bar)",
"CREATE UNIQUE INDEX UNIQ_8C73652178240498 ON foo (baz)",
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Types\Type;
require_once __DIR__ . '/../../TestInit.php';
class OraclePlatformTest extends AbstractPlatformTestCase
{
public function createPlatform()
......@@ -94,7 +94,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
public function testDropTable()
{
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
$this->assertEquals('DROP TABLE foobar', $this->_platform->getDropTableSQL('foobar'));
}
public function testGeneratesTypeDeclarationForIntegers()
......@@ -145,9 +145,9 @@ class OraclePlatformTest extends AbstractPlatformTestCase
public function testSupportsSavePoints()
{
$this->assertTrue($this->_platform->supportsSavepoints());
$this->assertTrue($this->_platform->supportsSavepoints());
}
public function getGenerateIndexSql()
{
return 'CREATE INDEX my_idx ON mytable (user_name, last_login)';
......@@ -212,8 +212,8 @@ class OraclePlatformTest extends AbstractPlatformTestCase
public function getBitOrComparisonExpressionSql($value1, $value2)
{
return '(' . $value1 . '-' .
$this->getBitAndComparisonExpressionSql($value1, $value2)
return '(' . $value1 . '-' .
$this->getBitAndComparisonExpressionSql($value1, $value2)
. '+' . $value2 . ')';
}
}
\ No newline at end of file
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Types\Type;
require_once __DIR__ . '/../../TestInit.php';
class PostgreSqlPlatformTest extends AbstractPlatformTestCase
{
public function createPlatform()
......
......@@ -13,32 +13,32 @@ class ReservedKeywordsValidatorTest extends \Doctrine\Tests\DbalTestCase
* @var ReservedKeywordsValidator
*/
private $validator;
public function setUp()
{
$this->validator = new ReservedKeywordsValidator(array(
new \Doctrine\DBAL\Platforms\Keywords\MySQLKeywords()
));
}
public function testReservedTableName()
{
$table = new Table("TABLE");
$this->validator->acceptTable($table);
$this->assertEquals(
array('Table TABLE keyword violations: MySQL'),
$this->validator->getViolations()
);
}
public function testReservedColumnName()
{
$table = new Table("TABLE");
$column = $table->addColumn('table', 'string');
$this->validator->acceptColumn($table, $column);
$this->assertEquals(
array('Table TABLE column table keyword violations: MySQL'),
$this->validator->getViolations()
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Types\Type;
require_once __DIR__ . '/../../TestInit.php';
class SqlitePlatformTest extends AbstractPlatformTestCase
{
public function createPlatform()
......@@ -37,19 +37,19 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
public function testGeneratesTransactionCommands()
{
$this->assertEquals(
'PRAGMA read_uncommitted = 0',
'PRAGMA read_uncommitted = 0',
$this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_UNCOMMITTED)
);
$this->assertEquals(
'PRAGMA read_uncommitted = 1',
'PRAGMA read_uncommitted = 1',
$this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_READ_COMMITTED)
);
$this->assertEquals(
'PRAGMA read_uncommitted = 1',
'PRAGMA read_uncommitted = 1',
$this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_REPEATABLE_READ)
);
$this->assertEquals(
'PRAGMA read_uncommitted = 1',
'PRAGMA read_uncommitted = 1',
$this->_platform->getSetTransactionIsolationSQL(\Doctrine\DBAL\Connection::TRANSACTION_SERIALIZABLE)
);
}
......
......@@ -14,67 +14,67 @@ class CompositeExpressionTest extends \Doctrine\Tests\DbalTestCase
public function testCount()
{
$expr = new CompositeExpression(CompositeExpression::TYPE_OR, array('u.group_id = 1'));
$this->assertEquals(1, count($expr));
$expr->add('u.group_id = 2');
$this->assertEquals(2, count($expr));
}
/**
* @dataProvider provideDataForConvertToString
*/
public function testCompositeUsageAndGeneration($type, $parts, $expects)
{
$expr = new CompositeExpression($type, $parts);
$this->assertEquals($expects, (string) $expr);
}
public function provideDataForConvertToString()
{
return array(
array(
CompositeExpression::TYPE_AND,
array('u.user = 1'),
CompositeExpression::TYPE_AND,
array('u.user = 1'),
'u.user = 1'
),
array(
CompositeExpression::TYPE_AND,
array('u.user = 1', 'u.group_id = 1'),
CompositeExpression::TYPE_AND,
array('u.user = 1', 'u.group_id = 1'),
'(u.user = 1) AND (u.group_id = 1)'
),
array(
CompositeExpression::TYPE_OR,
array('u.user = 1'),
CompositeExpression::TYPE_OR,
array('u.user = 1'),
'u.user = 1'
),
array(
CompositeExpression::TYPE_OR,
array('u.group_id = 1', 'u.group_id = 2'),
CompositeExpression::TYPE_OR,
array('u.group_id = 1', 'u.group_id = 2'),
'(u.group_id = 1) OR (u.group_id = 2)'
),
array(
CompositeExpression::TYPE_AND,
CompositeExpression::TYPE_AND,
array(
'u.user = 1',
'u.user = 1',
new CompositeExpression(
CompositeExpression::TYPE_OR,
array('u.group_id = 1', 'u.group_id = 2')
)
),
),
'(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))'
),
array(
CompositeExpression::TYPE_OR,
CompositeExpression::TYPE_OR,
array(
'u.group_id = 1',
'u.group_id = 1',
new CompositeExpression(
CompositeExpression::TYPE_AND,
array('u.user = 1', 'u.group_id = 2')
)
),
),
'(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))'
),
);
......
......@@ -13,140 +13,140 @@ require_once __DIR__ . '/../../../TestInit.php';
class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
{
protected $expr;
public function setUp()
{
$conn = $this->getMock('Doctrine\DBAL\Connection', array(), array(), '', false);
$this->expr = new ExpressionBuilder($conn);
$conn->expects($this->any())
->method('getExpressionBuilder')
->will($this->returnValue($this->expr));
}
/**
* @dataProvider provideDataForAndX
*/
public function testAndX($parts, $expected)
{
$composite = $this->expr->andX();
foreach ($parts as $part) {
$composite->add($part);
}
$this->assertEquals($expected, (string) $composite);
}
public function provideDataForAndX()
{
return array(
array(
array('u.user = 1'),
array('u.user = 1'),
'u.user = 1'
),
array(
array('u.user = 1', 'u.group_id = 1'),
array('u.user = 1', 'u.group_id = 1'),
'(u.user = 1) AND (u.group_id = 1)'
),
array(
array('u.user = 1'),
array('u.user = 1'),
'u.user = 1'
),
array(
array('u.group_id = 1', 'u.group_id = 2'),
array('u.group_id = 1', 'u.group_id = 2'),
'(u.group_id = 1) AND (u.group_id = 2)'
),
array(
array(
'u.user = 1',
'u.user = 1',
new CompositeExpression(
CompositeExpression::TYPE_OR,
array('u.group_id = 1', 'u.group_id = 2')
)
),
),
'(u.user = 1) AND ((u.group_id = 1) OR (u.group_id = 2))'
),
array(
array(
'u.group_id = 1',
'u.group_id = 1',
new CompositeExpression(
CompositeExpression::TYPE_AND,
array('u.user = 1', 'u.group_id = 2')
)
),
),
'(u.group_id = 1) AND ((u.user = 1) AND (u.group_id = 2))'
),
);
}
/**
* @dataProvider provideDataForOrX
*/
public function testOrX($parts, $expected)
{
$composite = $this->expr->orX();
foreach ($parts as $part) {
$composite->add($part);
}
$this->assertEquals($expected, (string) $composite);
}
public function provideDataForOrX()
{
return array(
array(
array('u.user = 1'),
array('u.user = 1'),
'u.user = 1'
),
array(
array('u.user = 1', 'u.group_id = 1'),
array('u.user = 1', 'u.group_id = 1'),
'(u.user = 1) OR (u.group_id = 1)'
),
array(
array('u.user = 1'),
array('u.user = 1'),
'u.user = 1'
),
array(
array('u.group_id = 1', 'u.group_id = 2'),
array('u.group_id = 1', 'u.group_id = 2'),
'(u.group_id = 1) OR (u.group_id = 2)'
),
array(
array(
'u.user = 1',
'u.user = 1',
new CompositeExpression(
CompositeExpression::TYPE_OR,
array('u.group_id = 1', 'u.group_id = 2')
)
),
),
'(u.user = 1) OR ((u.group_id = 1) OR (u.group_id = 2))'
),
array(
array(
'u.group_id = 1',
'u.group_id = 1',
new CompositeExpression(
CompositeExpression::TYPE_AND,
array('u.user = 1', 'u.group_id = 2')
)
),
),
'(u.group_id = 1) OR ((u.user = 1) AND (u.group_id = 2))'
),
);
}
/**
* @dataProvider provideDataForComparison
*/
public function testComparison($leftExpr, $operator, $rightExpr, $expected)
{
$part = $this->expr->comparison($leftExpr, $operator, $rightExpr);
$this->assertEquals($expected, (string) $part);
}
public function provideDataForComparison()
{
return array(
......@@ -158,42 +158,42 @@ class ExpressionBuilderTest extends \Doctrine\Tests\DbalTestCase
array('u.salary', ExpressionBuilder::GTE, '10000', 'u.salary >= 10000'),
);
}
public function testEq()
{
$this->assertEquals('u.user_id = 1', $this->expr->eq('u.user_id', '1'));
}
public function testNeq()
{
$this->assertEquals('u.user_id <> 1', $this->expr->neq('u.user_id', '1'));
}
public function testLt()
{
$this->assertEquals('u.salary < 10000', $this->expr->lt('u.salary', '10000'));
}
public function testLte()
{
$this->assertEquals('u.salary <= 10000', $this->expr->lte('u.salary', '10000'));
}
public function testGt()
{
$this->assertEquals('u.salary > 10000', $this->expr->gt('u.salary', '10000'));
}
public function testGte()
{
$this->assertEquals('u.salary >= 10000', $this->expr->gte('u.salary', '10000'));
}
public function testIsNull()
{
$this->assertEquals('u.deleted IS NULL', $this->expr->isNull('u.deleted'));
}
public function testIsNotNull()
{
$this->assertEquals('u.updated IS NOT NULL', $this->expr->isNotNull('u.updated'));
......
......@@ -19,7 +19,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
// none
array('SELECT * FROM Foo', true, array()),
array('SELECT * FROM Foo', false, array()),
// Positionals
array('SELECT ?', true, array(7)),
array('SELECT * FROM Foo WHERE bar IN (?, ?, ?)', true, array(32, 35, 38)),
......@@ -28,7 +28,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array("SELECT '?' FROM foo", true, array()),
array('SELECT "?" FROM foo WHERE bar = ?', true, array(32)),
array("SELECT '?' FROM foo WHERE bar = ?", true, array(32)),
// named
array('SELECT :foo FROM :bar', false, array(':foo' => array(7), ':bar' => array(17))),
array('SELECT * FROM Foo WHERE bar IN (:name1, :name2)', false, array(':name1' => array(32), ':name2' => array(40))),
......@@ -36,7 +36,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array("SELECT ':foo' FROM Foo WHERE bar IN (:name1, :name2)", false, array(':name1' => array(37), ':name2' => array(45))),
);
}
/**
* @dataProvider dataGetPlaceholderPositions
* @param type $query
......@@ -48,7 +48,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
$actualParamPos = SQLParserUtils::getPlaceholderPositions($query, $isPositional);
$this->assertEquals($expectedParamPos, $actualParamPos);
}
static public function dataExpandListParameters()
{
return array(
......@@ -106,7 +106,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array(1),
array(\PDO::PARAM_INT)
),
// Named parameters : Very simple with param int and string
array(
"SELECT * FROM Foo WHERE foo = :foo AND bar = :bar",
......@@ -116,7 +116,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
array(1,'Some String'),
array(\PDO::PARAM_INT, \PDO::PARAM_STR)
),
// Named parameters : Very simple with one needle
array(
"SELECT * FROM Foo WHERE foo IN (:foo)",
......@@ -182,7 +182,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
),
);
}
/**
* @dataProvider dataExpandListParameters
* @param type $q
......@@ -195,7 +195,7 @@ class SQLParserUtilsTest extends \Doctrine\Tests\DbalTestCase
public function testExpandListParameters($q, $p, $t, $expectedQuery, $expectedParams, $expectedTypes)
{
list($query, $params, $types) = SQLParserUtils::expandListParameters($q, $p, $t);
$this->assertEquals($expectedQuery, $query, "Query was not rewritten correctly.");
$this->assertEquals($expectedParams, $params, "Params dont match");
$this->assertEquals($expectedTypes, $types, "Types dont match");
......
......@@ -89,12 +89,12 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$schemaConfig = new \Doctrine\DBAL\Schema\SchemaConfig;
$table = new Table('bugdb', array ('integerfield1' => new Column('integerfield1', Type::getType('integer'))));
$table->setSchemaConfig($schemaConfig);
$schema1 = new Schema( array($table), array(), $schemaConfig );
$schema2 = new Schema( array(), array(), $schemaConfig );
$expected = new SchemaDiff( array(), array(), array('bugdb' => $table) );
$this->assertEquals($expected, Comparator::compareSchemas( $schema1, $schema2 ) );
}
......@@ -200,7 +200,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$column1->setCustomSchemaOption('foo', 'bar');
$column2->setCustomSchemaOption('foo', 'bar');
$column1->setCustomSchemaOption('foo1', 'bar1');
$column2->setCustomSchemaOption('foo2', 'bar2');
......@@ -518,7 +518,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$schemaB->createSequence('Bar');
$schemaB->createSequence('baz');
$schemaB->createSequence('old');
$c = new Comparator();
$diff = $c->compare($schemaA, $schemaB);
......@@ -612,7 +612,7 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$tableB = new Table("foo");
$tableB->addColumn('baz', 'integer');
$c = new Comparator();
$tableDiff = $c->diffTable($tableA, $tableB);
......@@ -668,8 +668,8 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
$this->assertEquals(array('logged_in_at'), array_keys($tableDiff->addedColumns));
$this->assertEquals(0, count($tableDiff->removedColumns));
}
/**
* @group DBAL-112
*/
......@@ -677,14 +677,14 @@ class ComparatorTest extends \PHPUnit_Framework_TestCase
{
$schema = new Schema();
$sequence = $schema->createSequence('baz');
$schemaNew = clone $schema;
/* @var $schemaNew Schema */
$schemaNew->getSequence('baz')->setAllocationSize(20);
$c = new \Doctrine\DBAL\Schema\Comparator;
$diff = $c->compare($schema, $schemaNew);
$this->assertSame($diff->changedSequences[0] , $schemaNew->getSequence('baz'));
}
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class ArrayTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class BooleanTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class DateTest extends \Doctrine\Tests\DbalTestCase
{
protected
......@@ -61,7 +61,7 @@ class DateTest extends \Doctrine\Tests\DbalTestCase
$this->assertEquals('00:00:00', $date->format('H:i:s'));
$this->assertEquals('2009-11-01', $date->format('Y-m-d'));
}
public function testInvalidDateFormatConversion()
{
$this->setExpectedException('Doctrine\DBAL\Types\ConversionException');
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class DecimalTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class ObjectTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class SmallIntTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class StringTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -6,7 +6,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DBAL\Mocks;
require_once __DIR__ . '/../../TestInit.php';
class TimeTest extends \Doctrine\Tests\DbalTestCase
{
protected
......
......@@ -13,7 +13,7 @@ class DriverMock implements \Doctrine\DBAL\Driver
{
return new DriverConnectionMock();
}
/**
* Constructs the Sqlite PDO DSN.
*
......
......@@ -10,8 +10,8 @@ namespace Doctrine\Tests\Mocks;
*/
class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{
private $_resultSet;
private $_resultSet;
/**
* Creates a new mock statement that will serve the provided fake result set to clients.
*
......@@ -21,7 +21,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{
$this->_resultSet = $resultSet;
}
/**
* Fetches all rows from the result set.
*
......@@ -31,7 +31,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{
return $this->_resultSet;
}
public function fetchColumn($columnNumber = 0)
{
$row = current($this->_resultSet);
......@@ -39,10 +39,10 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
$val = array_shift($row);
return $val !== null ? $val : false;
}
/**
* Fetches the next row in the result set.
*
*
*/
public function fetch($fetchStyle = null)
{
......@@ -50,7 +50,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
next($this->_resultSet);
return $current;
}
/**
* Closes the cursor, enabling the statement to be executed again.
*
......@@ -60,13 +60,13 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
{
return true;
}
public function setResultSet(array $resultSet)
{
reset($resultSet);
$this->_resultSet = $resultSet;
}
public function bindColumn($column, &$param, $type = null)
{
}
......@@ -78,7 +78,7 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
public function bindParam($column, &$variable, $type = null, $length = null, $driverOptions = array())
{
}
public function columnCount()
{
}
......@@ -86,16 +86,16 @@ class HydratorMockStatement implements \Doctrine\DBAL\Driver\Statement
public function errorCode()
{
}
public function errorInfo()
{
}
public function execute($params = array())
{
}
public function rowCount()
{
}
}
}
\ No newline at end of file
......@@ -8,6 +8,6 @@ class SchemaManagerMock extends \Doctrine\DBAL\Schema\AbstractSchemaManager
{
parent::__construct($conn);
}
protected function _getPortableTableColumnDefinition($tableColumn) {}
}
\ 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