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
6daa1e34
Commit
6daa1e34
authored
Nov 16, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed references to deprecated getTransaction() and getUnitOfWork() methods
parent
4f361df6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
130 deletions
+47
-130
Configurable.php
lib/Doctrine/Configurable.php
+3
-3
Record.php
lib/Doctrine/Record.php
+3
-3
ConnectionTestCase.php
tests/ConnectionTestCase.php
+33
-121
UnitTestCase.php
tests/UnitTestCase.php
+2
-1
run.php
tests/run.php
+6
-2
No files found.
lib/Doctrine/Configurable.php
View file @
6daa1e34
...
...
@@ -47,7 +47,7 @@ abstract class Doctrine_Configurable {
*
* <code>
* $manager->setAttribute(Doctrine::ATTR_PORTABILITY, Doctrine::PORTABILITY_ALL);
*
*
* // or
*
* $manager->setAttribute('portability', Doctrine::PORTABILITY_ALL);
...
...
@@ -76,12 +76,12 @@ abstract class Doctrine_Configurable {
break
;
case
Doctrine
::
ATTR_LOCKMODE
:
if
(
$this
instanceof
Doctrine_Connection
)
{
if
(
$this
->
getTransaction
()
->
getState
()
!=
Doctrine_Connection_Transaction
::
STATE_OPEN
)
if
(
$this
->
transaction
->
getState
()
!=
Doctrine_Connection_Transaction
::
STATE_OPEN
)
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
}
elseif
(
$this
instanceof
Doctrine_Manager
)
{
foreach
(
$this
as
$connection
)
{
if
(
$connection
->
getTransaction
()
->
getState
()
!=
Doctrine_Connection_Transaction
::
STATE_OPEN
)
if
(
$connection
->
transaction
->
getState
()
!=
Doctrine_Connection_Transaction
::
STATE_OPEN
)
throw
new
Doctrine_Exception
(
"Couldn't set lockmode. There are transactions open."
);
}
}
else
{
...
...
lib/Doctrine/Record.php
View file @
6daa1e34
...
...
@@ -864,12 +864,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$conn
->
beginTransaction
();
$saveLater
=
$conn
->
getUnitOfWork
()
->
saveRelated
(
$this
);
$saveLater
=
$conn
->
unitOfWork
->
saveRelated
(
$this
);
if
(
$this
->
isValid
())
{
$conn
->
save
(
$this
);
}
else
{
$conn
->
getTransaction
()
->
addInvalid
(
$this
);
$conn
->
transaction
->
addInvalid
(
$this
);
}
foreach
(
$saveLater
as
$fk
)
{
...
...
@@ -884,7 +884,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// save the MANY-TO-MANY associations
$conn
->
getUnitOfWork
()
->
saveAssociations
(
$this
);
$conn
->
unitOfWork
->
saveAssociations
(
$this
);
//$this->saveAssociations();
$conn
->
commit
();
...
...
tests/ConnectionTestCase.php
View file @
6daa1e34
<?php
require_once
(
"UnitTestCase.php"
);
class
Doctrine_ConnectionTestCase
extends
Doctrine_UnitTestCase
{
public
function
testbuildFlushTree
()
{
$correct
=
array
(
"Task"
,
"ResourceType"
,
"Resource"
,
"Assignment"
,
"ResourceReference"
);
// new model might switch some many-to-many components (NO HARM!)
$correct2
=
array
(
0
=>
'Resource'
,
1
=>
'Task'
,
2
=>
'ResourceType'
,
3
=>
'Assignment'
,
4
=>
'ResourceReference'
,
);
$task
=
new
Task
();
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Task"
));
$this
->
assertEqual
(
$tree
,
array
(
"Resource"
,
"Task"
,
"Assignment"
));
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Task"
,
"Resource"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Task"
,
"Assignment"
,
"Resource"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Assignment"
,
"Task"
,
"Resource"
));
$this
->
assertEqual
(
$tree
,
$correct2
);
$correct
=
array
(
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$correct
=
array
(
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Entry"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Thread"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Thread"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Category"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Category"
,
"Forum_Thread"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Thread"
,
"Forum_Category"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Category"
,
"Forum_Board"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Category"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Entry"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Entry"
,
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
connection
->
getUnitOfWork
()
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
}
public
function
testBulkInsert
()
{
$u1
=
new
User
();
$u1
->
name
=
"Jean Reno"
;
...
...
@@ -111,7 +8,22 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$id
=
$u1
->
obtainIdentifier
();
$u1
->
delete
();
}
public
function
testUnknownModule
()
{
try
{
$this
->
connection
->
unknown
;
$this
->
fail
();
}
catch
(
Doctrine_Connection_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testGetModule
()
{
$this
->
assertTrue
(
$this
->
connection
->
unitOfWork
instanceof
Doctrine_Connection_UnitOfWork
);
//$this->assertTrue($this->connection->dataDict instanceof Doctrine_DataDict);
$this
->
assertTrue
(
$this
->
connection
->
expression
instanceof
Doctrine_Expression
);
$this
->
assertTrue
(
$this
->
connection
->
transaction
instanceof
Doctrine_Transaction
);
$this
->
assertTrue
(
$this
->
connection
->
export
instanceof
Doctrine_Export
);
}
public
function
testFlush
()
{
...
...
@@ -312,8 +224,8 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$this
->
connection
->
getIterator
()
instanceof
ArrayIterator
);
}
public
function
testGetState
()
{
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
Doctrine_Lib
::
getConnectionStateAsString
(
$this
->
connection
->
getTransaction
()
->
getState
()),
"open"
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
Doctrine_Lib
::
getConnectionStateAsString
(
$this
->
connection
->
transaction
->
getState
()),
"open"
);
}
public
function
testGetTables
()
{
$this
->
assertTrue
(
is_array
(
$this
->
connection
->
getTables
()));
...
...
@@ -322,9 +234,9 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
public
function
testTransactions
()
{
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
connection
->
commit
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
connection
->
beginTransaction
();
...
...
@@ -341,26 +253,26 @@ class Doctrine_ConnectionTestCase extends Doctrine_UnitTestCase {
public
function
testRollback
()
{
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
connection
->
rollback
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
}
public
function
testNestedTransactions
()
{
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
connection
->
beginTransaction
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_BUSY
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
2
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_BUSY
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
2
);
$this
->
connection
->
commit
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
1
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_ACTIVE
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
1
);
$this
->
connection
->
commit
();
$this
->
assertEqual
(
$this
->
connection
->
getTransaction
()
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
getTransactionLevel
(),
0
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getState
(),
Doctrine_Connection_Transaction
::
STATE_OPEN
);
$this
->
assertEqual
(
$this
->
connection
->
transaction
->
getTransactionLevel
(),
0
);
}
}
?>
tests/UnitTestCase.php
View file @
6daa1e34
...
...
@@ -30,6 +30,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
protected
$users
;
protected
$valueHolder
;
protected
$tables
=
array
();
protected
$unitOfWork
;
private
$init
=
false
;
...
...
@@ -79,7 +80,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this
->
listener
=
new
Doctrine_EventListener_Debugger
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LISTENER
,
$this
->
listener
);
}
$this
->
unitOfWork
=
$this
->
connection
->
unitOfWork
;
$this
->
connection
->
setListener
(
new
Doctrine_EventListener
());
$this
->
query
=
new
Doctrine_Query
(
$this
->
connection
);
$this
->
prepareTables
();
...
...
tests/run.php
View file @
6daa1e34
...
...
@@ -43,6 +43,8 @@ require_once('QueryShortAliasesTestCase.php');
require_once
(
'QueryDeleteTestCase.php'
);
require_once
(
'QueryUpdateTestCase.php'
);
require_once
(
'UnitOfWorkTestCase.php'
);
require_once
(
'RelationAccessTestCase.php'
);
require_once
(
'RelationTestCase.php'
);
require_once
(
'RelationManyToManyTestCase.php'
);
...
...
@@ -67,6 +69,10 @@ print '<pre>';
$test
=
new
GroupTest
(
'Doctrine Framework Unit Tests'
);
$test
->
addTestCase
(
new
Doctrine_UnitOfWork_TestCase
());
$test
->
addTestCase
(
new
Doctrine_ConnectionTestCase
());
$test
->
addTestCase
(
new
Doctrine_Db_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Db_Profiler_TestCase
());
...
...
@@ -75,8 +81,6 @@ $test->addTestCase(new Doctrine_Query_MultiJoin_TestCase());
$test
->
addTestCase
(
new
Doctrine_Record_TestCase
());
$test
->
addTestCase
(
new
Doctrine_ConnectionTestCase
());
$test
->
addTestCase
(
new
Doctrine_DataDict_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Relation_ManyToMany_TestCase
());
...
...
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