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
f0686b39
Commit
f0686b39
authored
Dec 18, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix all failing tests on MySQL, PostgreSQL and Oracle
parent
4c5317e0
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
57 deletions
+82
-57
ResultCacheStatement.php
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
+1
-1
OracleSessionInit.php
lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
+1
-4
Statement.php
lib/Doctrine/DBAL/Portability/Statement.php
+11
-11
PostgreSqlSchemaManager.php
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
+6
-3
DataAccessTest.php
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
+17
-15
NamedParametersTest.php
tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php
+5
-1
PortabilityTest.php
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
+2
-1
ResultCacheTest.php
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
+13
-13
SchemaManagerFunctionalTestCase.php
...BAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
+17
-7
TestUtil.php
tests/Doctrine/Tests/TestUtil.php
+9
-1
No files found.
lib/Doctrine/DBAL/Cache/ResultCacheStatement.php
View file @
f0686b39
lib/Doctrine/DBAL/Event/Listeners/OracleSessionInit.php
View file @
f0686b39
<?php
/*
* $Id$
*
* 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
...
...
@@ -37,8 +35,7 @@ use Doctrine\Common\EventSubscriber;
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @link www.doctrine-project.com
* @since 1.0
* @version $Revision$
* @since 2.0
* @author Benjamin Eberlei <kontakt@beberlei.de>
*/
class
OracleSessionInit
implements
EventSubscriber
...
...
lib/Doctrine/DBAL/Portability/Statement.php
View file @
f0686b39
lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php
View file @
f0686b39
...
...
@@ -21,13 +21,12 @@
namespace
Doctrine\DBAL\Schema
;
/**
*
xxx
*
PostgreSQL Schema Manager
*
* @license http://www.opensource.org/licenses/lgpl-license.php LGPL
* @author Konsta Vesterinen <kvesteri@cc.hut.fi>
* @author Lukas Smith <smith@pooteeweet.org> (PEAR MDB2 library)
* @author Benjamin Eberlei <kontakt@beberlei.de>
* @version $Revision$
* @since 2.0
*/
class
PostgreSqlSchemaManager
extends
AbstractSchemaManager
...
...
@@ -338,6 +337,10 @@ class PostgreSqlSchemaManager extends AbstractSchemaManager
break
;
}
if
(
$tableColumn
[
'default'
]
&&
preg_match
(
"('([^']+)'::)"
,
$tableColumn
[
'default'
],
$match
))
{
$tableColumn
[
'default'
]
=
$match
[
1
];
}
$options
=
array
(
'length'
=>
$length
,
'notnull'
=>
(
bool
)
$tableColumn
[
'isnotnull'
],
...
...
tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
View file @
f0686b39
...
...
@@ -10,11 +10,13 @@ require_once __DIR__ . '/../../TestInit.php';
class
DataAccessTest
extends
\Doctrine\Tests\DbalFunctionalTestCase
{
static
private
$generated
=
false
;
public
function
setUp
()
{
parent
::
setUp
();
try
{
if
(
self
::
$generated
===
false
)
{
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */
$table
=
new
\Doctrine\DBAL\Schema\Table
(
"fetch_table"
);
$table
->
addColumn
(
'test_int'
,
'integer'
);
...
...
@@ -26,8 +28,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$sm
->
createTable
(
$table
);
$this
->
_conn
->
insert
(
'fetch_table'
,
array
(
'test_int'
=>
1
,
'test_string'
=>
'foo'
,
'test_datetime'
=>
'2010-01-01 10:10:10'
));
}
catch
(
\Exception
$e
)
{
self
::
$generated
=
true
;
}
}
...
...
@@ -354,6 +355,7 @@ class DataAccessTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertEquals
(
4
,
count
(
$data
));
$this
->
assertEquals
(
count
(
$bitmap
),
count
(
$data
));
foreach
(
$data
as
$row
)
{
$row
=
array_change_key_case
(
$row
,
CASE_LOWER
);
$this
->
assertArrayHasKey
(
'test_int'
,
$row
);
...
...
tests/Doctrine/Tests/DBAL/Functional/NamedParametersTest.php
View file @
f0686b39
...
...
@@ -156,6 +156,10 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt
=
$this
->
_conn
->
executeQuery
(
$query
,
$params
,
$types
);
$result
=
$stmt
->
fetchAll
(
\PDO
::
FETCH_ASSOC
);
foreach
(
$result
as
$k
=>
$v
)
{
$result
[
$k
]
=
array_change_key_case
(
$v
,
CASE_LOWER
);
}
$this
->
assertEquals
(
$result
,
$expected
);
}
...
...
tests/Doctrine/Tests/DBAL/Functional/PortabilityTest.php
View file @
f0686b39
...
...
@@ -61,6 +61,7 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
assertFetchResultRows
(
$rows
);
$stmt
=
$this
->
getPortableConnection
()
->
query
(
'SELECT * FROM portability_table'
);
$stmt
->
setFetchMode
(
\PDO
::
FETCH_ASSOC
);
foreach
(
$stmt
as
$row
)
{
$this
->
assertFetchResultRow
(
$row
);
}
...
...
tests/Doctrine/Tests/DBAL/Functional/ResultCacheTest.php
View file @
f0686b39
...
...
@@ -72,13 +72,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
foreach
(
$this
->
expectedResult
AS
$v
)
{
$numExpectedResult
[]
=
array_values
(
$v
);
}
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
$this
->
hydrateStmt
(
$stmt
,
\PDO
::
FETCH_ASSOC
);
$this
->
assertEquals
(
$this
->
expectedResult
,
$data
);
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
$this
->
hydrateStmt
(
$stmt
,
\PDO
::
FETCH_NUM
);
...
...
@@ -94,10 +94,10 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
assertStandardAndIteratorFetchAreEqual
(
$fetchStyle
)
{
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetchStyle
);
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data_iterator
=
$this
->
hydrateStmtIterator
(
$stmt
,
$fetchStyle
);
$this
->
assertEquals
(
$data
,
$data_iterator
);
...
...
@@ -105,14 +105,14 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testDontCloseNoCache
()
{
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
array
();
while
(
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
))
{
$data
[]
=
$row
;
}
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
array
();
while
(
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_NUM
))
{
...
...
@@ -124,12 +124,12 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
testDontFinishNoCache
()
{
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$row
=
$stmt
->
fetch
(
\PDO
::
FETCH_ASSOC
);
$stmt
->
closeCursor
();
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$data
=
$this
->
hydrateStmt
(
$stmt
,
\PDO
::
FETCH_NUM
);
...
...
@@ -138,13 +138,13 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
public
function
assertCacheNonCacheSelectSameFetchModeAreEqual
(
$expectedResult
,
$fetchStyle
)
{
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$this
->
assertEquals
(
2
,
$stmt
->
columnCount
());
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetchStyle
);
$this
->
assertEquals
(
$expectedResult
,
$data
);
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$stmt
=
$this
->
_conn
->
executeQuery
(
"SELECT * FROM caching
ORDER BY test_int ASC
"
,
array
(),
array
(),
new
QueryCacheProfile
(
10
,
"testcachekey"
));
$this
->
assertEquals
(
2
,
$stmt
->
columnCount
());
$data
=
$this
->
hydrateStmt
(
$stmt
,
$fetchStyle
);
...
...
@@ -180,7 +180,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
{
$data
=
array
();
while
(
$row
=
$stmt
->
fetch
(
$fetchStyle
))
{
$data
[]
=
$row
;
$data
[]
=
array_change_key_case
(
$row
,
CASE_LOWER
)
;
}
$stmt
->
closeCursor
();
return
$data
;
...
...
@@ -191,7 +191,7 @@ class ResultCacheTest extends \Doctrine\Tests\DbalFunctionalTestCase
$data
=
array
();
$stmt
->
setFetchMode
(
$fetchStyle
);
foreach
(
$stmt
as
$row
)
{
$data
[]
=
$row
;
$data
[]
=
array_change_key_case
(
$row
,
CASE_LOWER
)
;
}
$stmt
->
closeCursor
();
return
$data
;
...
...
tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
View file @
f0686b39
...
...
@@ -98,8 +98,8 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
'list_table_columns'
);
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'length'
=>
255
,
'notnull'
=>
false
));
$table
->
addColumn
(
'foo'
,
'text'
,
array
(
'notnull'
=>
true
,
'default'
=>
'expected default'
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'length'
=>
255
,
'notnull'
=>
false
,
'default'
=>
'expected default'
));
$table
->
addColumn
(
'foo'
,
'text'
,
array
(
'notnull'
=>
true
));
$table
->
addColumn
(
'bar'
,
'decimal'
,
array
(
'precision'
=>
10
,
'scale'
=>
4
,
'notnull'
=>
false
));
$table
->
addColumn
(
'baz1'
,
'datetime'
);
$table
->
addColumn
(
'baz2'
,
'time'
);
...
...
@@ -130,7 +130,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this
->
assertEquals
(
255
,
$columns
[
'test'
]
->
getlength
());
$this
->
assertEquals
(
false
,
$columns
[
'test'
]
->
getfixed
());
$this
->
assertEquals
(
false
,
$columns
[
'test'
]
->
getnotnull
());
$this
->
assertEquals
(
null
,
$columns
[
'test'
]
->
getdefault
());
$this
->
assertEquals
(
'expected default'
,
$columns
[
'test'
]
->
getdefault
());
$this
->
assertInternalType
(
'array'
,
$columns
[
'test'
]
->
getPlatformOptions
());
$this
->
assertEquals
(
'foo'
,
strtolower
(
$columns
[
'foo'
]
->
getname
()));
...
...
@@ -138,7 +138,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$this
->
assertEquals
(
false
,
$columns
[
'foo'
]
->
getunsigned
());
$this
->
assertEquals
(
false
,
$columns
[
'foo'
]
->
getfixed
());
$this
->
assertEquals
(
true
,
$columns
[
'foo'
]
->
getnotnull
());
$this
->
assertEquals
(
'expected default'
,
$columns
[
'foo'
]
->
getdefault
());
$this
->
assertEquals
(
null
,
$columns
[
'foo'
]
->
getdefault
());
$this
->
assertInternalType
(
'array'
,
$columns
[
'foo'
]
->
getPlatformOptions
());
$this
->
assertEquals
(
'bar'
,
strtolower
(
$columns
[
'bar'
]
->
getname
()));
...
...
@@ -188,7 +188,7 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
public
function
testListTableIndexes
()
{
$table
=
$this
->
getTestTable
(
'list_table_indexes_test'
);
$table
=
$this
->
getTest
Composite
Table
(
'list_table_indexes_test'
);
$table
->
addUniqueIndex
(
array
(
'test'
),
'test_index_name'
);
$table
->
addIndex
(
array
(
'id'
,
'test'
),
'test_composite_idx'
);
...
...
@@ -505,10 +505,20 @@ class SchemaManagerFunctionalTestCase extends \Doctrine\Tests\DbalFunctionalTest
$table
=
new
\Doctrine\DBAL\Schema\Table
(
$name
,
array
(),
array
(),
array
(),
false
,
$options
);
$table
->
setSchemaConfig
(
$this
->
_sm
->
createSchemaConfig
());
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
setPrimaryKey
(
array
(
'id'
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'length'
=>
255
));
$table
->
addColumn
(
'foreign_key_test'
,
'integer'
);
return
$table
;
}
protected
function
getTestCompositeTable
(
$name
)
{
$table
=
new
\Doctrine\DBAL\Schema\Table
(
$name
,
array
(),
array
(),
array
(),
false
,
array
());
$table
->
setSchemaConfig
(
$this
->
_sm
->
createSchemaConfig
());
$table
->
addColumn
(
'id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
addColumn
(
'other_id'
,
'integer'
,
array
(
'notnull'
=>
true
));
$table
->
setPrimaryKey
(
array
(
'id'
,
'other_id'
));
$table
->
addColumn
(
'test'
,
'string'
,
array
(
'length'
=>
255
));
$table
->
addColumn
(
'foreign_key_test'
,
'integer'
);
return
$table
;
}
...
...
tests/Doctrine/Tests/TestUtil.php
View file @
f0686b39
...
...
@@ -100,6 +100,14 @@ class TestUtil
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$params
);
}
if
(
isset
(
$GLOBALS
[
'db_event_subscribers'
]))
{
$evm
=
$conn
->
getEventManager
();
foreach
(
explode
(
","
,
$GLOBALS
[
'db_event_subscribers'
])
AS
$subscriberClass
)
{
$subscriberInstance
=
new
$subscriberClass
();
$evm
->
addEventSubscriber
(
$subscriberInstance
);
}
}
return
$conn
;
}
...
...
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