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
a4913774
Commit
a4913774
authored
Oct 23, 2009
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[2.0] Added ConnectionTest. Fixed sandbox.
parent
4328a4e9
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
72 additions
and
13 deletions
+72
-13
Connection.php
lib/Doctrine/DBAL/Connection.php
+5
-9
ClassMetadata.php
lib/Doctrine/ORM/Mapping/ClassMetadata.php
+1
-1
AllTests.php
tests/Doctrine/Tests/DBAL/Functional/AllTests.php
+1
-0
ConnectionTest.php
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
+64
-0
User.php
tools/sandbox/Entities/User.php
+1
-3
No files found.
lib/Doctrine/DBAL/Connection.php
View file @
a4913774
...
...
@@ -683,10 +683,7 @@ class Connection
}
/**
* Start a transaction or set a savepoint.
*
* if trying to set a savepoint and there is no active transaction
* a new transaction is being started.
* Start a transaction by suspending auto-commit mode.
*
* @return void
*/
...
...
@@ -702,12 +699,11 @@ class Connection
}
/**
* Commits the database changes done during a transaction that is in
* progress or release a savepoint. This function may only be called when
* auto-committing is disabled, otherwise it will fail.
* Commits the current transaction.
*
* @return void
* @throws ConnectionException If the commit failed.
* @throws ConnectionException If the commit failed due to no active transaction or
* because the transaction was marked for rollback only.
*/
public
function
commit
()
{
...
...
@@ -736,7 +732,6 @@ class Connection
* this method can be listened with onPreTransactionRollback and onTransactionRollback
* eventlistener methods
*
* @param string $savepoint Name of a savepoint to rollback to.
* @throws ConnectionException If the rollback operation fails at database level.
*/
public
function
rollback
()
...
...
@@ -752,6 +747,7 @@ class Connection
$this
->
_conn
->
rollback
();
$this
->
_isRollbackOnly
=
false
;
}
else
{
$this
->
_isRollbackOnly
=
true
;
--
$this
->
_transactionNestingLevel
;
}
}
...
...
lib/Doctrine/ORM/Mapping/ClassMetadata.php
View file @
a4913774
...
...
@@ -341,7 +341,7 @@ final class ClassMetadata extends ClassMetadataInfo
}
/**
* Restores some state that c
ould
not be serialized/unserialized.
* Restores some state that c
an
not be serialized/unserialized.
*
* @return void
*/
...
...
tests/Doctrine/Tests/DBAL/Functional/AllTests.php
View file @
a4913774
...
...
@@ -24,6 +24,7 @@ class AllTests
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Functional\Schema\SqliteSchemaManagerTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Functional\Schema\MySqlSchemaManagerTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Functional\Schema\PostgreSqlSchemaManagerTest'
);
$suite
->
addTestSuite
(
'Doctrine\Tests\DBAL\Functional\ConnectionTest'
);
return
$suite
;
}
...
...
tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php
0 → 100644
View file @
a4913774
<?php
namespace
Doctrine\Tests\DBAL\Functional
;
use
Doctrine\DBAL\ConnectionException
;
require_once
__DIR__
.
'/../../TestInit.php'
;
class
ConnectionTest
extends
\Doctrine\Tests\DbalFunctionalTestCase
{
public
function
testTransactionNestingBehavior
()
{
try
{
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
try
{
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
2
,
$this
->
_conn
->
getTransactionNestingLevel
());
throw
new
\Exception
;
$this
->
_conn
->
commit
();
// never reached
}
catch
(
\Exception
$e
)
{
$this
->
_conn
->
rollback
();
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
//no rethrow
}
$this
->
assertTrue
(
$this
->
_conn
->
getRollbackOnly
());
$this
->
_conn
->
commit
();
// should throw exception
$this
->
fail
(
'Transaction commit after failed nested transaction should fail.'
);
}
catch
(
ConnectionException
$e
)
{
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
$this
->
_conn
->
rollback
();
$this
->
assertEquals
(
0
,
$this
->
_conn
->
getTransactionNestingLevel
());
}
}
public
function
testTransactionBehavior
()
{
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
());
$this
->
_conn
->
rollback
();
$this
->
assertEquals
(
0
,
$this
->
_conn
->
getTransactionNestingLevel
());
}
try
{
$this
->
_conn
->
beginTransaction
();
$this
->
assertEquals
(
1
,
$this
->
_conn
->
getTransactionNestingLevel
());
$this
->
_conn
->
commit
();
}
catch
(
\Exception
$e
)
{
$this
->
_conn
->
rollback
();
$this
->
assertEquals
(
0
,
$this
->
_conn
->
getTransactionNestingLevel
());
}
}
}
\ No newline at end of file
tools/sandbox/Entities/User.php
View file @
a4913774
...
...
@@ -2,7 +2,7 @@
namespace
Entities
;
/** @Entity @Table(name="users"
, indexes={@Index(name="name_idx", columns={"name", "test"})}
) */
/** @Entity @Table(name="users") */
class
User
{
/**
* @Id @Column(type="integer")
...
...
@@ -11,8 +11,6 @@ class User {
private
$id
;
/** @Column(type="string", length=50) */
private
$name
;
/** @Column(type="string", length=50) */
private
$test
;
/**
* @OneToOne(targetEntity="Address")
* @JoinColumn(name="address_id", referencedColumnName="id")
...
...
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