Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
doctrine-dbal
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Tomáš Trávníček
doctrine-dbal
Commits
be4253f5
Unverified
Commit
be4253f5
authored
Jan 30, 2018
by
Sergei Morozov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
More code style fixes
parent
41906695
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
371 additions
and
183 deletions
+371
-183
ArrayStatement.php
lib/Doctrine/DBAL/Cache/ArrayStatement.php
+1
-1
SQLSrvStatement.php
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
+1
-1
ConnectionTest.php
tests/Doctrine/Tests/DBAL/ConnectionTest.php
+12
-12
DriverManagerTest.php
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
+313
-143
BlobTest.php
tests/Doctrine/Tests/DBAL/Functional/BlobTest.php
+31
-14
PortabilityTest.php
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
+1
-1
StatementTest.php
tests/Doctrine/Tests/DBAL/Functional/StatementTest.php
+1
-3
DBAL630Test.php
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
+2
-2
WriteTest.php
tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
+5
-5
QueryBuilderTest.php
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
+4
-1
No files found.
lib/Doctrine/DBAL/Cache/ArrayStatement.php
View file @
be4253f5
...
...
@@ -123,7 +123,7 @@ class ArrayStatement implements \IteratorAggregate, ResultStatement
return
reset
(
$row
);
}
throw
new
\InvalidArgumentException
(
"Invalid fetch-style given for fetching result."
);
throw
new
\InvalidArgumentException
(
'Invalid fetch-style given for fetching result.'
);
}
/**
...
...
lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvStatement.php
View file @
be4253f5
...
...
@@ -96,7 +96,7 @@ class SQLSrvStatement implements IteratorAggregate, Statement
/**
* The fetch style.
*
* @
param
int
* @
var
int
*/
private
$defaultFetchMode
=
FetchMode
::
MIXED
;
...
...
tests/Doctrine/Tests/DBAL/ConnectionTest.php
View file @
be4253f5
...
...
@@ -495,9 +495,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
public
function
testFetchAssoc
()
{
$statement
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
ParameterType
::
INTEGER
)
;
$result
=
array
()
;
$params
=
[
666
]
;
$types
=
[
ParameterType
::
INTEGER
]
;
$result
=
[]
;
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
...
...
@@ -531,9 +531,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
public
function
testFetchArray
()
{
$statement
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
ParameterType
::
INTEGER
)
;
$result
=
array
()
;
$params
=
[
666
]
;
$types
=
[
ParameterType
::
INTEGER
]
;
$result
=
[]
;
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
...
...
@@ -567,10 +567,10 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
public
function
testFetchColumn
()
{
$statement
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
ParameterType
::
INTEGER
)
;
$params
=
[
666
]
;
$types
=
[
ParameterType
::
INTEGER
]
;
$column
=
0
;
$result
=
array
()
;
$result
=
[]
;
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
...
...
@@ -627,9 +627,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalTestCase
public
function
testFetchAll
()
{
$statement
=
'SELECT * FROM foo WHERE bar = ?'
;
$params
=
array
(
666
)
;
$types
=
array
(
ParameterType
::
INTEGER
)
;
$result
=
array
()
;
$params
=
[
666
]
;
$types
=
[
ParameterType
::
INTEGER
]
;
$result
=
[]
;
$driverMock
=
$this
->
createMock
(
'Doctrine\DBAL\Driver'
);
...
...
tests/Doctrine/Tests/DBAL/DriverManagerTest.php
View file @
be4253f5
...
...
@@ -3,8 +3,18 @@
namespace
Doctrine\Tests\DBAL
;
use
Doctrine\DBAL\DBALException
;
use
Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver
as
DrizzlePDOMySqlDriver
;
use
Doctrine\DBAL\Driver\PDOMySQL\Driver
as
PDOMySQLDriver
;
use
Doctrine\DBAL\Driver\PDOSqlite\Driver
as
PDOSqliteDriver
;
use
Doctrine\DBAL\Driver\SQLSrv\Driver
as
SQLSrvDriver
;
use
Doctrine\DBAL\DriverManager
;
use
Doctrine\Tests\DBAL\Mocks\MockPlatform
;
use
Doctrine\Tests\DbalTestCase
;
use
Doctrine\Tests\Mocks\ConnectionMock
;
use
Doctrine\Tests\Mocks\DriverMock
;
use
stdClass
;
class
DriverManagerTest
extends
\Doctrine\Tests\
DbalTestCase
class
DriverManagerTest
extends
DbalTestCase
{
/**
* @requires extension pdo_sqlite
...
...
@@ -12,10 +22,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testInvalidPdoInstance
()
{
$options
=
array
(
'pdo'
=>
'test'
);
$test
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
DriverManager
::
getConnection
([
'pdo'
=>
'test'
]);
}
/**
...
...
@@ -23,10 +30,10 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testValidPdoInstance
()
{
$
options
=
array
(
'pdo'
=>
new
\PDO
(
'sqlite::memory:'
)
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$options
);
$
conn
=
DriverManager
::
getConnection
([
'pdo'
=>
new
\PDO
(
'sqlite::memory:'
)
,
]
);
self
::
assertEquals
(
'sqlite'
,
$conn
->
getDatabasePlatform
()
->
getName
());
}
...
...
@@ -38,11 +45,9 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
{
$pdo
=
new
\PDO
(
'sqlite::memory:'
);
$pdo
->
setAttribute
(
\PDO
::
ATTR_ERRMODE
,
\PDO
::
ERRMODE_SILENT
);
$options
=
array
(
'pdo'
=>
$pdo
);
$options
=
[
'pdo'
=>
$pdo
];
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
DriverManager
::
getConnection
(
$options
);
self
::
assertEquals
(
\PDO
::
ERRMODE_EXCEPTION
,
$pdo
->
getAttribute
(
\PDO
::
ATTR_ERRMODE
));
}
...
...
@@ -51,7 +56,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testCheckParams
()
{
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
array
()
);
DriverManager
::
getConnection
([]
);
}
/**
...
...
@@ -59,7 +64,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testInvalidDriver
()
{
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
array
(
'driver'
=>
'invalid_driver'
)
);
DriverManager
::
getConnection
([
'driver'
=>
'invalid_driver'
]
);
}
/**
...
...
@@ -67,13 +72,13 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testCustomPlatform
()
{
$mockPlatform
=
new
\Doctrine\Tests\DBAL\Mocks\
MockPlatform
();
$options
=
array
(
$mockPlatform
=
new
MockPlatform
();
$options
=
[
'pdo'
=>
new
\PDO
(
'sqlite::memory:'
),
'platform'
=>
$mockPlatform
)
;
'platform'
=>
$mockPlatform
,
]
;
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
$conn
=
DriverManager
::
getConnection
(
$options
);
self
::
assertSame
(
$mockPlatform
,
$conn
->
getDatabasePlatform
());
}
...
...
@@ -82,14 +87,14 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testCustomWrapper
()
{
$wrapperClass
=
'Doctrine\Tests\Mocks\ConnectionMock'
;
$wrapperClass
=
ConnectionMock
::
class
;
$options
=
array
(
$options
=
[
'pdo'
=>
new
\PDO
(
'sqlite::memory:'
),
'wrapperClass'
=>
$wrapperClass
,
)
;
]
;
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
$conn
=
DriverManager
::
getConnection
(
$options
);
self
::
assertInstanceOf
(
$wrapperClass
,
$conn
);
}
...
...
@@ -100,33 +105,29 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
{
$this
->
expectException
(
DBALException
::
class
);
$options
=
array
(
$options
=
[
'pdo'
=>
new
\PDO
(
'sqlite::memory:'
),
'wrapperClass'
=>
'stdClass'
,
)
;
'wrapperClass'
=>
stdClass
::
class
,
]
;
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
DriverManager
::
getConnection
(
$options
);
}
public
function
testInvalidDriverClass
()
{
$this
->
expectException
(
DBALException
::
class
);
$options
=
array
(
'driverClass'
=>
'stdClass'
);
$options
=
[
'driverClass'
=>
stdClass
::
class
];
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
DriverManager
::
getConnection
(
$options
);
}
public
function
testValidDriverClass
()
{
$options
=
array
(
'driverClass'
=>
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
);
$options
=
[
'driverClass'
=>
PDOMySQLDriver
::
class
];
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
self
::
assertInstanceOf
(
'Doctrine\DBAL\Driver\PDOMySql\Driver'
,
$conn
->
getDriver
());
$conn
=
DriverManager
::
getConnection
(
$options
);
self
::
assertInstanceOf
(
PDOMySQLDriver
::
class
,
$conn
->
getDriver
());
}
/**
...
...
@@ -134,9 +135,7 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
*/
public
function
testDatabaseUrl
(
$url
,
$expected
)
{
$options
=
is_array
(
$url
)
?
$url
:
array
(
'url'
=>
$url
,
);
$options
=
is_array
(
$url
)
?
$url
:
[
'url'
=>
$url
];
if
(
isset
(
$options
[
'pdo'
]))
{
if
(
!
extension_loaded
(
'pdo'
))
{
...
...
@@ -146,19 +145,17 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
$options
[
'pdo'
]
=
$this
->
createMock
(
\PDO
::
class
);
}
$options
=
is_array
(
$url
)
?
$url
:
array
(
'url'
=>
$url
,
);
$options
=
is_array
(
$url
)
?
$url
:
[
'url'
=>
$url
];
if
(
$expected
===
false
)
{
$this
->
expectException
(
DBALException
::
class
);
}
$conn
=
\Doctrine\DBAL\
DriverManager
::
getConnection
(
$options
);
$conn
=
DriverManager
::
getConnection
(
$options
);
$params
=
$conn
->
getParams
();
foreach
(
$expected
as
$key
=>
$value
)
{
if
(
in_array
(
$key
,
array
(
'pdo'
,
'driver'
,
'driverClass'
)
,
true
))
{
if
(
in_array
(
$key
,
[
'pdo'
,
'driver'
,
'driverClass'
]
,
true
))
{
self
::
assertInstanceOf
(
$value
,
$conn
->
getDriver
());
}
else
{
self
::
assertEquals
(
$value
,
$params
[
$key
]);
...
...
@@ -168,121 +165,294 @@ class DriverManagerTest extends \Doctrine\Tests\DbalTestCase
public
function
databaseUrls
()
{
return
array
(
'simple URL'
=>
array
(
return
[
'simple URL'
=>
[
'mysql://foo:bar@localhost/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'simple URL with port'
=>
array
(
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'simple URL with port'
=>
[
'mysql://foo:bar@localhost:11211/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'port'
=>
11211
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'sqlite relative URL with host'
=>
array
(
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'port'
=>
11211
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'sqlite relative URL with host'
=>
[
'sqlite://localhost/foo/dbname.sqlite'
,
array
(
'path'
=>
'foo/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite absolute URL with host'
=>
array
(
[
'path'
=>
'foo/dbname.sqlite'
,
'driver'
=>
PDOSqliteDriver
::
class
,
],
],
'sqlite absolute URL with host'
=>
[
'sqlite://localhost//tmp/dbname.sqlite'
,
array
(
'path'
=>
'/tmp/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite relative URL without host'
=>
array
(
[
'path'
=>
'/tmp/dbname.sqlite'
,
'driver'
=>
PDOSqliteDriver
::
class
,
],
],
'sqlite relative URL without host'
=>
[
'sqlite:///foo/dbname.sqlite'
,
array
(
'path'
=>
'foo/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite absolute URL without host'
=>
array
(
[
'path'
=>
'foo/dbname.sqlite'
,
'driver'
=>
PDOSqliteDriver
::
class
,
],
],
'sqlite absolute URL without host'
=>
[
'sqlite:////tmp/dbname.sqlite'
,
array
(
'path'
=>
'/tmp/dbname.sqlite'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite memory'
=>
array
(
[
'path'
=>
'/tmp/dbname.sqlite'
,
'driver'
=>
PDOSqliteDriver
::
class
,
],
],
'sqlite memory'
=>
[
'sqlite:///:memory:'
,
array
(
'memory'
=>
true
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'sqlite memory with host'
=>
array
(
[
'memory'
=>
true
,
'driver'
=>
PDOSqliteDriver
::
class
,
],
],
'sqlite memory with host'
=>
[
'sqlite://localhost/:memory:'
,
array
(
'memory'
=>
true
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOSqlite\Driver'
),
),
'params parsed from URL override individual params'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'password'
=>
'lulz'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'params not parsed from URL but individual params are preserved'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'port'
=>
1234
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'port'
=>
1234
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'query params from URL are used as extra params'
=>
array
(
[
'memory'
=>
true
,
'driver'
=>
PDOSqliteDriver
::
class
,
],
],
'params parsed from URL override individual params'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'password'
=>
'lulz'
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'params not parsed from URL but individual params are preserved'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'port'
=>
1234
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'port'
=>
1234
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'query params from URL are used as extra params'
=>
[
'url'
=>
'mysql://foo:bar@localhost/dbname?charset=UTF-8'
,
array
(
'charset'
=>
'UTF-8'
)
,
)
,
'simple URL with fallthrough scheme not defined in map'
=>
array
(
[
'charset'
=>
'UTF-8'
]
,
]
,
'simple URL with fallthrough scheme not defined in map'
=>
[
'sqlsrv://foo:bar@localhost/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\SQLSrv\Driver'
),
),
'simple URL with fallthrough scheme containing underscores fails'
=>
array
(
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
SQLSrvDriver
::
class
,
],
],
'simple URL with fallthrough scheme containing underscores fails'
=>
[
'drizzle_pdo_mysql://foo:bar@localhost/baz'
,
false
,
)
,
'simple URL with fallthrough scheme containing dashes works'
=>
array
(
]
,
'simple URL with fallthrough scheme containing dashes works'
=>
[
'drizzle-pdo-mysql://foo:bar@localhost/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver'
),
),
'simple URL with percent encoding'
=>
array
(
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
DrizzlePDOMySqlDriver
::
class
,
],
],
'simple URL with percent encoding'
=>
[
'mysql://foo%3A:bar%2F@localhost/baz+baz%40'
,
array
(
'user'
=>
'foo:'
,
'password'
=>
'bar/'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz+baz@'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'simple URL with percent sign in password'
=>
array
(
[
'user'
=>
'foo:'
,
'password'
=>
'bar/'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz+baz@'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'simple URL with percent sign in password'
=>
[
'mysql://foo:bar%25bar@localhost/baz'
,
array
(
'user'
=>
'foo'
,
'password'
=>
'bar%bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
[
'user'
=>
'foo'
,
'password'
=>
'bar%bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
// DBAL-1234
'URL without scheme and without any driver information'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
)
,
'URL without scheme and without any driver information'
=>
[
[
'url'
=>
'//foo:bar@localhost/baz'
]
,
false
,
),
'URL without scheme but default PDO driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
true
),
],
'URL without scheme but default PDO driver'
=>
[
[
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
true
,
],
false
,
),
'URL without scheme but default driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'driver'
=>
'pdo_mysql'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL without scheme but custom driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
),
'URL without scheme but default PDO driver and default driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'pdo_mysql'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL without scheme but driver and custom driver'
=>
array
(
array
(
'url'
=>
'//foo:bar@localhost/baz'
,
'driver'
=>
'pdo_mysql'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
),
'URL with default PDO driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'driver'
=>
'sqlite'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default custom driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default PDO driver and default driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'sqlite'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default driver and default custom driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'driver'
=>
'sqlite'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
'URL with default PDO driver and default driver and default custom driver'
=>
array
(
array
(
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'sqlite'
,
'driverClass'
=>
'Doctrine\Tests\Mocks\DriverMock'
),
array
(
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
'Doctrine\DBAL\Driver\PDOMySQL\Driver'
),
),
);
],
'URL without scheme but default driver'
=>
[
[
'url'
=>
'//foo:bar@localhost/baz'
,
'driver'
=>
'pdo_mysql'
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL without scheme but custom driver'
=>
[
[
'url'
=>
'//foo:bar@localhost/baz'
,
'driverClass'
=>
DriverMock
::
class
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driverClass'
=>
DriverMock
::
class
,
],
],
'URL without scheme but default PDO driver and default driver'
=>
[
[
'url'
=>
'//foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'pdo_mysql'
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL without scheme but driver and custom driver'
=>
[
[
'url'
=>
'//foo:bar@localhost/baz'
,
'driver'
=>
'pdo_mysql'
,
'driverClass'
=>
DriverMock
::
class
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driverClass'
=>
DriverMock
::
class
,
],
],
'URL with default PDO driver'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL with default driver'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'driver'
=>
'sqlite'
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL with default custom driver'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'driverClass'
=>
DriverMock
::
class
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL with default PDO driver and default driver'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'sqlite'
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL with default driver and default custom driver'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'driver'
=>
'sqlite'
,
'driverClass'
=>
DriverMock
::
class
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
'URL with default PDO driver and default driver and default custom driver'
=>
[
[
'url'
=>
'mysql://foo:bar@localhost/baz'
,
'pdo'
=>
true
,
'driver'
=>
'sqlite'
,
'driverClass'
=>
DriverMock
::
class
,
],
[
'user'
=>
'foo'
,
'password'
=>
'bar'
,
'host'
=>
'localhost'
,
'dbname'
=>
'baz'
,
'driver'
=>
PDOMySQLDriver
::
class
,
],
],
];
}
}
tests/Doctrine/Tests/DBAL/Functional/BlobTest.php
View file @
be4253f5
...
...
@@ -54,26 +54,43 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testSelect
()
{
$this
->
_conn
->
insert
(
'blob_table'
,
array
(
'id'
=>
1
,
'clobfield'
=>
'test'
,
'blobfield'
=>
'test'
,
'binaryfield'
=>
'test'
),
array
(
ParameterType
::
INTEGER
,
ParameterType
::
STRING
,
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
LARGE_OBJECT
)
);
$this
->
_conn
->
insert
(
'blob_table'
,
[
'id'
=>
1
,
'clobfield'
=>
'test'
,
'blobfield'
=>
'test'
,
'binaryfield'
=>
'test'
,
],
[
ParameterType
::
INTEGER
,
ParameterType
::
STRING
,
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
LARGE_OBJECT
,
]);
$this
->
assertBlobContains
(
'test'
);
}
public
function
testUpdate
()
{
$this
->
_conn
->
insert
(
'blob_table'
,
array
(
'id'
=>
1
,
'clobfield'
=>
'test'
,
'blobfield'
=>
'test'
,
'binaryfield'
=>
'test'
),
array
(
ParameterType
::
INTEGER
,
ParameterType
::
STRING
,
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
LARGE_OBJECT
)
);
$this
->
_conn
->
update
(
'blob_table'
,
array
(
'blobfield'
=>
'test2'
,
'binaryfield'
=>
'test2'
),
array
(
'id'
=>
1
),
array
(
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
INTEGER
)
);
$this
->
_conn
->
insert
(
'blob_table'
,
[
'id'
=>
1
,
'clobfield'
=>
'test'
,
'blobfield'
=>
'test'
,
'binaryfield'
=>
'test'
,
],
[
ParameterType
::
INTEGER
,
ParameterType
::
STRING
,
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
LARGE_OBJECT
,
]);
$this
->
_conn
->
update
(
'blob_table'
,
[
'blobfield'
=>
'test2'
,
'binaryfield'
=>
'test2'
,
],
[
'id'
=>
1
],
[
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
LARGE_OBJECT
,
ParameterType
::
INTEGER
,
]);
$this
->
assertBlobContains
(
'test2'
);
$this
->
assertBinaryContains
(
'test2'
);
...
...
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
View file @
be4253f5
...
...
@@ -128,7 +128,7 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
self
::
assertArrayHasKey
(
'test_string'
,
$row
,
"Case should be lowered."
);
self
::
assertEquals
(
3
,
strlen
(
$row
[
'test_string'
]),
"test_string should be rtrimed to length of three for CHAR(32) column."
);
self
::
assertNull
(
$row
[
'test_null'
]);
self
::
assertArrayNotHasKey
(
0
,
$row
,
"The row should not contain numerical keys."
);
self
::
assertArrayNotHasKey
(
0
,
$row
,
'The row should not contain numerical keys.'
);
}
/**
...
...
tests/Doctrine/Tests/DBAL/Functional/StatementTest.php
View file @
be4253f5
...
...
@@ -104,9 +104,7 @@ d+N0hqezcjblboJ3Bj8ARJilHX4FAAA=
EOF
);
$this
->
_conn
->
insert
(
'stmt_long_blob'
,
array
(
'contents'
=>
$contents
,
),
array
(
ParameterType
::
LARGE_OBJECT
));
$this
->
_conn
->
insert
(
'stmt_long_blob'
,
[
'contents'
=>
$contents
],
[
ParameterType
::
LARGE_OBJECT
]);
$stmt
=
$this
->
_conn
->
prepare
(
'SELECT contents FROM stmt_long_blob'
);
$stmt
->
execute
();
...
...
tests/Doctrine/Tests/DBAL/Functional/Ticket/DBAL630Test.php
View file @
be4253f5
...
...
@@ -55,8 +55,8 @@ class DBAL630Test extends \Doctrine\Tests\DbalFunctionalTestCase
{
$this
->
_conn
->
executeUpdate
(
'INSERT INTO dbal630 (bool_col) VALUES(?)'
,
array
(
'false'
)
,
array
(
ParameterType
::
BOOLEAN
)
[
'false'
]
,
[
ParameterType
::
BOOLEAN
]
);
$id
=
$this
->
_conn
->
lastInsertId
(
'dbal630_id_seq'
);
self
::
assertNotEmpty
(
$id
);
...
...
tests/Doctrine/Tests/DBAL/Functional/WriteTest.php
View file @
be4253f5
...
...
@@ -32,10 +32,10 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testExecuteUpdateFirstTypeIsNull
()
{
$sql
=
"INSERT INTO write_table (test_string, test_int) VALUES (?, ?)"
;
$this
->
_conn
->
executeUpdate
(
$sql
,
array
(
"text"
,
1111
),
array
(
null
,
ParameterType
::
INTEGER
)
);
$this
->
_conn
->
executeUpdate
(
$sql
,
[
'text'
,
1111
],
[
null
,
ParameterType
::
INTEGER
]
);
$sql
=
"SELECT * FROM write_table WHERE test_string = ? AND test_int = ?"
;
self
::
assertTrue
((
bool
)
$this
->
_conn
->
fetchColumn
(
$sql
,
array
(
"text"
,
1111
)
));
self
::
assertTrue
((
bool
)
$this
->
_conn
->
fetchColumn
(
$sql
,
[
'text'
,
1111
]
));
}
public
function
testExecuteUpdate
()
...
...
@@ -51,8 +51,8 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sql
=
"INSERT INTO write_table (test_int, test_string) VALUES (?, ?)"
;
$affected
=
$this
->
_conn
->
executeUpdate
(
$sql
,
array
(
1
,
'foo'
)
,
array
(
ParameterType
::
INTEGER
,
ParameterType
::
STRING
)
[
1
,
'foo'
]
,
[
ParameterType
::
INTEGER
,
ParameterType
::
STRING
]
);
self
::
assertEquals
(
1
,
$affected
,
"executeUpdate() should return the number of affected rows!"
);
...
...
@@ -76,7 +76,7 @@ class WriteTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt
=
$this
->
_conn
->
prepare
(
$sql
);
$stmt
->
bindValue
(
1
,
1
,
ParameterType
::
INTEGER
);
$stmt
->
bindValue
(
2
,
"foo"
,
ParameterType
::
STRING
);
$stmt
->
bindValue
(
2
,
'foo'
,
ParameterType
::
STRING
);
$stmt
->
execute
();
self
::
assertEquals
(
1
,
$stmt
->
rowCount
());
...
...
tests/Doctrine/Tests/DBAL/Query/QueryBuilderTest.php
View file @
be4253f5
...
...
@@ -874,7 +874,10 @@ class QueryBuilderTest extends \Doctrine\Tests\DbalTestCase
$qb
->
where
(
'is_active = :isActive'
);
$qb
->
setParameter
(
'isActive'
,
true
,
ParameterType
::
BOOLEAN
);
self
::
assertSame
(
array
(
'name'
=>
ParameterType
::
STRING
,
'isActive'
=>
ParameterType
::
BOOLEAN
),
$qb
->
getParameterTypes
());
self
::
assertSame
([
'name'
=>
ParameterType
::
STRING
,
'isActive'
=>
ParameterType
::
BOOLEAN
,
],
$qb
->
getParameterTypes
());
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment