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
3cf559fc
Commit
3cf559fc
authored
Nov 13, 2011
by
Benjamin Eberlei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Port functional test failure routines from ORM to DBAL testsuite
parent
833a3f94
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
47 additions
and
1 deletion
+47
-1
TemporaryTableTest.php
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
+5
-1
DbalFunctionalTestCase.php
tests/Doctrine/Tests/DbalFunctionalTestCase.php
+42
-0
No files found.
tests/Doctrine/Tests/DBAL/Functional/TemporaryTableTest.php
View file @
3cf559fc
...
...
@@ -51,7 +51,11 @@ class TemporaryTableTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
_conn
->
commit
();
$this
->
_conn
->
beginTransaction
();
$this
->
_conn
->
insert
(
"nontemporary"
,
array
(
"id"
=>
1
));
try
{
$this
->
_conn
->
insert
(
"nontemporary"
,
array
(
"id"
=>
1
));
}
catch
(
Exception
$e
)
{
$this
->
fail
(
"Error: "
.
$e
->
getMessage
()
.
" --- Existing tables: "
.
implode
(
", "
,
$this
->
_conn
->
getSchemaManager
()
->
listTableNames
()));
}
$this
->
_conn
->
exec
(
$platform
->
getDropTemporaryTableSQL
(
$tempTable
));
...
...
tests/Doctrine/Tests/DbalFunctionalTestCase.php
View file @
3cf559fc
...
...
@@ -16,6 +16,11 @@ class DbalFunctionalTestCase extends DbalTestCase
*/
protected
$_conn
;
/**
* @var \Doctrine\DBAL\Logging\DebugStack
*/
protected
$_sqlLoggerStack
;
protected
function
resetSharedConn
()
{
if
(
self
::
$_sharedConn
)
{
...
...
@@ -30,5 +35,42 @@ class DbalFunctionalTestCase extends DbalTestCase
self
::
$_sharedConn
=
TestUtil
::
getConnection
();
}
$this
->
_conn
=
self
::
$_sharedConn
;
$this
->
_sqlLoggerStack
=
new
\Doctrine\DBAL\Logging\DebugStack
();
$this
->
_conn
->
getConfiguration
()
->
setSQLLogger
(
$this
->
_sqlLoggerStack
);
}
protected
function
onNotSuccessfulTest
(
\Exception
$e
)
{
if
(
$e
instanceof
\PHPUnit_Framework_AssertionFailedError
)
{
throw
$e
;
}
if
(
isset
(
$this
->
_sqlLoggerStack
->
queries
)
&&
count
(
$this
->
_sqlLoggerStack
->
queries
))
{
$queries
=
""
;
for
(
$i
=
count
(
$this
->
_sqlLoggerStack
->
queries
)
-
1
;
$i
>
max
(
count
(
$this
->
_sqlLoggerStack
->
queries
)
-
25
,
0
)
&&
isset
(
$this
->
_sqlLoggerStack
->
queries
[
$i
]);
$i
--
)
{
$query
=
$this
->
_sqlLoggerStack
->
queries
[
$i
];
$params
=
array_map
(
function
(
$p
)
{
if
(
is_object
(
$p
))
return
get_class
(
$p
);
else
return
"'"
.
$p
.
"'"
;
},
$query
[
'params'
]
?:
array
());
$queries
.=
(
$i
+
1
)
.
". SQL: '"
.
$query
[
'sql'
]
.
"' Params: "
.
implode
(
", "
,
$params
)
.
PHP_EOL
;
}
$trace
=
$e
->
getTrace
();
$traceMsg
=
""
;
foreach
(
$trace
AS
$part
)
{
if
(
isset
(
$part
[
'file'
]))
{
if
(
strpos
(
$part
[
'file'
],
"PHPUnit/"
)
!==
false
)
{
// Beginning with PHPUnit files we don't print the trace anymore.
break
;
}
$traceMsg
.=
$part
[
'file'
]
.
":"
.
$part
[
'line'
]
.
PHP_EOL
;
}
}
$message
=
"["
.
get_class
(
$e
)
.
"] "
.
$e
->
getMessage
()
.
PHP_EOL
.
PHP_EOL
.
"With queries:"
.
PHP_EOL
.
$queries
.
PHP_EOL
.
"Trace:"
.
PHP_EOL
.
$traceMsg
;
throw
new
\Exception
(
$message
,
(
int
)
$e
->
getCode
(),
$e
);
}
throw
$e
;
}
}
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