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
92073ad3
Commit
92073ad3
authored
Sep 30, 2013
by
dazz
Committed by
Benjamin Eberlei
Nov 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DBAL-407] Implement and detect connection exceptions
parent
1d9dec7b
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
9 deletions
+42
-9
DBALException.php
lib/Doctrine/DBAL/DBALException.php
+1
-0
ExceptionTest.php
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
+41
-9
No files found.
lib/Doctrine/DBAL/DBALException.php
View file @
92073ad3
...
...
@@ -32,6 +32,7 @@ class DBALException extends \Exception
const
ERROR_SYNTAX
=
9
;
const
ERROR_UNABLE_TO_OPEN
=
10
;
const
ERROR_WRITE_READONLY
=
11
;
const
ERROR_ACCESS_DENIED
=
12
;
/**
* @param string $method
...
...
tests/Doctrine/Tests/DBAL/Functional/ExceptionTest.php
View file @
92073ad3
...
...
@@ -156,15 +156,6 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this
->
_conn
->
executeQuery
(
$sql
);
}
protected
function
onNotSuccessfulTest
(
\Exception
$e
)
{
parent
::
onNotSuccessfulTest
(
$e
);
if
(
"PHPUnit_Framework_SkippedTestError"
==
get_class
(
$e
))
{
return
;
}
var_dump
(
$e
);
}
/**
* @dataProvider getSqLiteOpenConnection
*/
...
...
@@ -206,5 +197,46 @@ class ExceptionTest extends \Doctrine\Tests\DbalFunctionalTestCase
);
}
/**
* @dataProvider getConnectionParams
*/
public
function
testConnectionException
(
$params
,
$exceptionCode
)
{
if
(
$this
->
_conn
->
getDatabasePlatform
()
->
getName
()
==
'sqlite'
)
{
$this
->
markTestSkipped
(
"Only skipped if platform is not sqlite"
);
}
$defaultParams
=
$this
->
_conn
->
getParams
();
$params
=
array_merge
(
$defaultParams
,
$params
);
$conn
=
\Doctrine\DBAL\DriverManager
::
getConnection
(
$params
);
$schema
=
new
\Doctrine\DBAL\Schema\Schema
();
$table
=
$schema
->
createTable
(
"no_connection"
);
$table
->
addColumn
(
'id'
,
'integer'
);
$this
->
setExpectedException
(
'\Doctrine\DBAL\DBALException'
,
null
,
$exceptionCode
);
foreach
(
$schema
->
toSql
(
$conn
->
getDatabasePlatform
())
AS
$sql
)
{
$conn
->
executeQuery
(
$sql
);
}
}
public
function
getConnectionParams
()
{
return
array
(
array
(
array
(
'user'
=>
'not_existing'
),
DBALException
::
ERROR_ACCESS_DENIED
),
array
(
array
(
'password'
=>
'really_not'
),
DBALException
::
ERROR_ACCESS_DENIED
),
array
(
array
(
'host'
=>
'localnope'
),
DBALException
::
ERROR_ACCESS_DENIED
),
);
}
protected
function
onNotSuccessfulTest
(
\Exception
$e
)
{
parent
::
onNotSuccessfulTest
(
$e
);
if
(
"PHPUnit_Framework_SkippedTestError"
==
get_class
(
$e
))
{
return
;
}
var_dump
(
$e
);
}
}
\ No newline at end of file
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