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
a0958f7d
Commit
a0958f7d
authored
Aug 21, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
66dce041
Changes
23
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
284 additions
and
284 deletions
+284
-284
AccessTestCase.php
tests/AccessTestCase.php
+4
-4
BatchIteratorTestCase.php
tests/BatchIteratorTestCase.php
+1
-1
CacheQuerySqliteTestCase.php
tests/CacheQuerySqliteTestCase.php
+2
-2
CacheSqliteTestCase.php
tests/CacheSqliteTestCase.php
+1
-1
CollectionOffsetTestCase.php
tests/CollectionOffsetTestCase.php
+9
-9
CollectionTestCase.php
tests/CollectionTestCase.php
+16
-16
ConfigurableTestCase.php
tests/ConfigurableTestCase.php
+6
-6
ConnectionTestCase.php
tests/ConnectionTestCase.php
+87
-87
CustomPrimaryKeyTestCase.php
tests/CustomPrimaryKeyTestCase.php
+2
-2
EventListenerTestCase.php
tests/EventListenerTestCase.php
+2
-2
ManagerTestCase.php
tests/ManagerTestCase.php
+6
-6
PessimisticLockingTestCase.php
tests/PessimisticLockingTestCase.php
+4
-4
QueryLimitTestCase.php
tests/QueryLimitTestCase.php
+10
-10
QueryTestCase.php
tests/QueryTestCase.php
+67
-67
RawSqlTestCase.php
tests/RawSqlTestCase.php
+9
-9
RecordTestCase.php
tests/RecordTestCase.php
+25
-25
TableTestCase.php
tests/TableTestCase.php
+4
-4
UnitTestCase.php
tests/UnitTestCase.php
+15
-15
ValidatorTestCase.php
tests/ValidatorTestCase.php
+4
-4
ValueHolderTestCase.php
tests/ValueHolderTestCase.php
+2
-2
ViewTestCase.php
tests/ViewTestCase.php
+2
-2
classes.php
tests/classes.php
+2
-2
run.php
tests/run.php
+4
-4
No files found.
tests/AccessTestCase.php
View file @
a0958f7d
...
...
@@ -3,7 +3,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
"Entity"
,
"User"
);
parent
::
prepareTables
();
parent
::
prepareTables
();
}
public
function
testOffsetMethods
()
{
$user
=
new
User
();
...
...
@@ -14,7 +14,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user
->
save
();
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
$user
->
getID
());
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
$user
->
getID
());
$this
->
assertEqual
(
$user
->
name
,
"Jack"
);
$user
[
"name"
]
=
"Jack"
;
...
...
@@ -32,7 +32,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user
->
save
();
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
$user
->
getID
());
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
$user
->
getID
());
$this
->
assertEqual
(
$user
->
name
,
"Jack"
);
$user
->
name
=
"Jack"
;
...
...
@@ -49,7 +49,7 @@ class Doctrine_AccessTestCase extends Doctrine_UnitTestCase {
$user
->
save
();
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
$user
->
getID
());
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
$user
->
getID
());
$this
->
assertEqual
(
$user
->
get
(
"name"
),
"Jack"
);
...
...
tests/BatchIteratorTestCase.php
View file @
a0958f7d
...
...
@@ -9,7 +9,7 @@ class Doctrine_BatchIteratorTestCase extends Doctrine_UnitTestCase {
}
public
function
testIterator
()
{
$graph
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$graph
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$entities
=
$graph
->
query
(
"FROM Entity"
);
$i
=
0
;
foreach
(
$entities
as
$entity
)
{
...
...
tests/CacheQuerySqliteTestCase.php
View file @
a0958f7d
...
...
@@ -5,12 +5,12 @@ class Doctrine_Cache_Query_SqliteTestCase extends Doctrine_UnitTestCase {
public
function
setUp
()
{
parent
::
setUp
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CACHE
,
Doctrine
::
CACHE_NONE
);
$dir
=
$this
->
sess
ion
->
getAttribute
(
Doctrine
::
ATTR_CACHE_DIR
);
$dir
=
$this
->
connect
ion
->
getAttribute
(
Doctrine
::
ATTR_CACHE_DIR
);
if
(
file_exists
(
$dir
.
DIRECTORY_SEPARATOR
.
"stats.cache"
))
unlink
(
$dir
.
DIRECTORY_SEPARATOR
.
"stats.cache"
);
$this
->
cache
=
new
Doctrine_Cache_Query_Sqlite
(
$this
->
sess
ion
);
$this
->
cache
=
new
Doctrine_Cache_Query_Sqlite
(
$this
->
connect
ion
);
$this
->
cache
->
deleteAll
();
}
public
function
testStore
()
{
...
...
tests/CacheSqliteTestCase.php
View file @
a0958f7d
...
...
@@ -5,7 +5,7 @@ class Doctrine_Cache_SqliteTestCase extends Doctrine_UnitTestCase {
public
function
setUp
()
{
parent
::
setUp
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CACHE
,
Doctrine
::
CACHE_NONE
);
$dir
=
$this
->
sess
ion
->
getAttribute
(
Doctrine
::
ATTR_CACHE_DIR
);
$dir
=
$this
->
connect
ion
->
getAttribute
(
Doctrine
::
ATTR_CACHE_DIR
);
if
(
file_exists
(
$dir
.
DIRECTORY_SEPARATOR
.
"stats.cache"
))
unlink
(
$dir
.
DIRECTORY_SEPARATOR
.
"stats.cache"
);
...
...
tests/CollectionOffsetTestCase.php
View file @
a0958f7d
...
...
@@ -2,7 +2,7 @@
class
Doctrine_Collection_OffsetTestCase
extends
Doctrine_UnitTestCase
{
public
function
testExpand
()
{
$users
=
$this
->
sess
ion
->
query
(
"FROM User-o"
);
$users
=
$this
->
connect
ion
->
query
(
"FROM User-o"
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection_Offset
);
$this
->
assertEqual
(
count
(
$users
),
5
);
...
...
@@ -11,9 +11,9 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$users
[
5
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$users
[
5
];
$this
->
sess
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
3
);
$this
->
connect
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
3
);
$users
=
$this
->
sess
ion
->
query
(
"FROM User-o"
);
$users
=
$this
->
connect
ion
->
query
(
"FROM User-o"
);
$this
->
assertEqual
(
count
(
$users
),
3
);
$this
->
assertEqual
(
$users
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
1
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
...
...
@@ -39,8 +39,8 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$users
[
5
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
sess
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
1
);
$users
=
$this
->
sess
ion
->
query
(
"FROM User-b, User.Phonenumber-o WHERE User."
.
$this
->
objTable
->
getIdentifier
()
.
" = 5"
);
$this
->
connect
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
1
);
$users
=
$this
->
connect
ion
->
query
(
"FROM User-b, User.Phonenumber-o WHERE User."
.
$this
->
objTable
->
getIdentifier
()
.
" = 5"
);
$this
->
assertEqual
(
count
(
$users
),
1
);
...
...
@@ -54,8 +54,8 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
}
public
function
testGetIterator
()
{
$this
->
sess
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
4
);
$coll
=
$this
->
sess
ion
->
query
(
"FROM User-o"
);
$this
->
connect
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
4
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User-o"
);
foreach
(
$coll
as
$user
)
{
}
...
...
@@ -63,9 +63,9 @@ class Doctrine_Collection_OffsetTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$coll
[
3
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$coll
[
6
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
sess
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
3
);
$this
->
connect
ion
->
setAttribute
(
Doctrine
::
ATTR_COLL_LIMIT
,
3
);
$coll
=
$this
->
sess
ion
->
query
(
"FROM User-o"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User-o"
);
foreach
(
$coll
as
$user
)
{
}
...
...
tests/CollectionTestCase.php
View file @
a0958f7d
...
...
@@ -16,7 +16,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
}
public
function
testLoadRelatedForAssociation
()
{
$coll
=
$this
->
sess
ion
->
query
(
"FROM User"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User"
);
$this
->
assertEqual
(
$coll
->
count
(),
8
);
...
...
@@ -34,9 +34,9 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$coll
->
save
();
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
$coll
=
$this
->
sess
ion
->
query
(
"FROM User"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User"
);
$this
->
assertEqual
(
$coll
->
count
(),
8
);
$this
->
assertEqual
(
$coll
[
0
]
->
Group
->
count
(),
2
);
...
...
@@ -44,9 +44,9 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$coll
[
2
]
->
Group
->
count
(),
3
);
$this
->
assertEqual
(
$coll
[
5
]
->
Group
->
count
(),
3
);
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
$coll
=
$this
->
sess
ion
->
query
(
"FROM User"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User"
);
$this
->
assertEqual
(
$coll
->
count
(),
8
);
...
...
@@ -67,10 +67,10 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
}
public
function
testLoadRelated
()
{
$coll
=
$this
->
sess
ion
->
query
(
"FROM User(id)"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User(id)"
);
$q
=
$coll
->
loadRelated
();
...
...
@@ -86,7 +86,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$count
,
$this
->
dbh
->
count
());
}
public
function
testLoadRelatedForLocalKeyRelation
()
{
$coll
=
$this
->
sess
ion
->
query
(
"FROM User"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User"
);
$this
->
assertEqual
(
$coll
->
count
(),
8
);
...
...
@@ -107,10 +107,10 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
}
public
function
testLoadRelatedForForeignKey
()
{
$coll
=
$this
->
sess
ion
->
query
(
"FROM User"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM User"
);
$this
->
assertEqual
(
$coll
->
count
(),
8
);
$count
=
$this
->
dbh
->
count
();
...
...
@@ -139,16 +139,16 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
}
public
function
testCount
()
{
$coll
=
new
Doctrine_Collection
(
$this
->
sess
ion
->
getTable
(
'User'
));
$coll
=
new
Doctrine_Collection
(
$this
->
connect
ion
->
getTable
(
'User'
));
$this
->
assertEqual
(
$coll
->
count
(),
0
);
$coll
[
0
];
$this
->
assertEqual
(
$coll
->
count
(),
1
);
}
public
function
testExpand
()
{
$users
=
$this
->
sess
ion
->
query
(
"FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'"
);
$users
=
$this
->
connect
ion
->
query
(
"FROM User-b.Phonenumber-l WHERE User.Phonenumber.phonenumber LIKE '%123%'"
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection_Batch
);
$this
->
assertTrue
(
$users
[
1
]
instanceof
User
);
...
...
@@ -174,7 +174,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$coll
->
setGenerator
(
$generator
);
$generator
=
$coll
->
getGenerator
();
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$this
->
assertEqual
(
$generator
->
getIndex
(
$user
),
4
);
}
...
...
@@ -190,8 +190,8 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$coll
[
"name"
],
$user
);
$this
->
sess
ion
->
getTable
(
"email"
)
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
"address"
);
$emails
=
$this
->
sess
ion
->
getTable
(
"email"
)
->
findAll
();
$this
->
connect
ion
->
getTable
(
"email"
)
->
setAttribute
(
Doctrine
::
ATTR_COLL_KEY
,
"address"
);
$emails
=
$this
->
connect
ion
->
getTable
(
"email"
)
->
findAll
();
foreach
(
$emails
as
$k
=>
$v
)
{
$this
->
assertTrue
(
gettype
(
$k
),
"string"
);
}
...
...
tests/ConfigurableTestCase.php
View file @
a0958f7d
...
...
@@ -5,7 +5,7 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
public
function
prepareTables
()
{
}
public
function
prepareData
()
{
}
public
function
testSetAttribute
()
{
$table
=
$this
->
sess
ion
->
getTable
(
"User"
);
$table
=
$this
->
connect
ion
->
getTable
(
"User"
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CACHE_TTL
,
100
);
$this
->
assertEqual
(
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_CACHE_TTL
),
100
);
...
...
@@ -52,11 +52,11 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
}
try
{
$this
->
sess
ion
->
beginTransaction
();
$this
->
connect
ion
->
beginTransaction
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LOCKMODE
,
Doctrine
::
LOCK_OPTIMISTIC
);
}
catch
(
Exception
$e
)
{
$this
->
assertTrue
(
$e
instanceof
Exception
);
$this
->
sess
ion
->
commit
();
$this
->
connect
ion
->
commit
();
}
$e
=
false
;
...
...
@@ -82,11 +82,11 @@ class Doctrine_ConfigurableTestCase extends Doctrine_UnitTestCase {
$e
=
false
;
try
{
$this
->
sess
ion
->
beginTransaction
();
$this
->
sess
ion
->
setAttribute
(
Doctrine
::
ATTR_LOCKMODE
,
Doctrine
::
LOCK_PESSIMISTIC
);
$this
->
connect
ion
->
beginTransaction
();
$this
->
connect
ion
->
setAttribute
(
Doctrine
::
ATTR_LOCKMODE
,
Doctrine
::
LOCK_PESSIMISTIC
);
}
catch
(
Exception
$e
)
{
$this
->
assertTrue
(
$e
instanceof
Exception
);
$this
->
sess
ion
->
commit
();
$this
->
connect
ion
->
commit
();
}
try
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_PK_TYPE
,
-
12
);
...
...
tests/
Sess
ionTestCase.php
→
tests/
Connect
ionTestCase.php
View file @
a0958f7d
This diff is collapsed.
Click to expand it.
tests/CustomPrimaryKeyTestCase.php
View file @
a0958f7d
...
...
@@ -16,9 +16,9 @@ class Doctrine_CustomPrimaryKeyTestCase extends Doctrine_UnitTestCase {
$c
->
save
();
$this
->
assertEqual
(
$c
->
getID
(),
array
(
"uid"
=>
1
));
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
$c
=
$this
->
sess
ion
->
getTable
(
'CustomPK'
)
->
find
(
1
);
$c
=
$this
->
connect
ion
->
getTable
(
'CustomPK'
)
->
find
(
1
);
$this
->
assertEqual
(
$c
->
getID
(),
array
(
"uid"
=>
1
));
}
...
...
tests/EventListenerTestCase.php
View file @
a0958f7d
...
...
@@ -3,10 +3,10 @@ require_once("UnitTestCase.php");
class
Doctrine_EventListenerTestCase
extends
Doctrine_UnitTestCase
{
public
function
testEvents
()
{
$
session
=
$this
->
manager
->
openSess
ion
(
Doctrine_DB
::
getConnection
());
$
connection
=
$this
->
manager
->
openConnect
ion
(
Doctrine_DB
::
getConnection
());
$debug
=
$this
->
listener
->
getMessages
();
$last
=
end
(
$debug
);
$this
->
assertTrue
(
$last
->
getObject
()
instanceof
Doctrine_
Sess
ion
);
$this
->
assertTrue
(
$last
->
getObject
()
instanceof
Doctrine_
Connect
ion
);
$this
->
assertTrue
(
$last
->
getCode
()
==
Doctrine_EventListener_Debugger
::
EVENT_OPEN
);
}
public
function
prepareData
()
{
}
...
...
tests/ManagerTestCase.php
View file @
a0958f7d
...
...
@@ -4,8 +4,8 @@ class Doctrine_ManagerTestCase extends Doctrine_UnitTestCase {
public
function
testGetInstance
()
{
$this
->
assertTrue
(
Doctrine_Manager
::
getInstance
()
instanceOf
Doctrine_Manager
);
}
public
function
testOpen
Sess
ion
()
{
$this
->
assertTrue
(
$this
->
session
instanceOf
Doctrine_Sess
ion
);
public
function
testOpen
Connect
ion
()
{
$this
->
assertTrue
(
$this
->
connection
instanceOf
Doctrine_Connect
ion
);
}
public
function
testGetIterator
()
{
$this
->
assertTrue
(
$this
->
manager
->
getIterator
()
instanceof
ArrayIterator
);
...
...
@@ -13,11 +13,11 @@ class Doctrine_ManagerTestCase extends Doctrine_UnitTestCase {
public
function
testCount
()
{
$this
->
assertEqual
(
count
(
$this
->
manager
),
1
);
}
public
function
testGetCurrent
Sess
ion
()
{
$this
->
assertEqual
(
$this
->
manager
->
getCurrent
Session
(),
$this
->
sess
ion
);
public
function
testGetCurrent
Connect
ion
()
{
$this
->
assertEqual
(
$this
->
manager
->
getCurrent
Connection
(),
$this
->
connect
ion
);
}
public
function
testGet
Sess
ions
()
{
$this
->
assertEqual
(
count
(
$this
->
manager
->
get
Sess
ions
()),
1
);
public
function
testGet
Connect
ions
()
{
$this
->
assertEqual
(
count
(
$this
->
manager
->
get
Connect
ions
()),
1
);
}
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
}
...
...
tests/PessimisticLockingTestCase.php
View file @
a0958f7d
...
...
@@ -15,7 +15,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
public
function
setUp
()
{
parent
::
setUp
();
$this
->
lockingManager
=
new
Doctrine_Locking_Manager_Pessimistic
(
$this
->
sess
ion
);
$this
->
lockingManager
=
new
Doctrine_Locking_Manager_Pessimistic
(
$this
->
connect
ion
);
// Create sample data to test on
$entry1
=
new
Forum_Entry
();
...
...
@@ -31,7 +31,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
*/
public
function
testLock
()
{
$entries
=
$this
->
sess
ion
->
query
(
"FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"
);
$entries
=
$this
->
connect
ion
->
query
(
"FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"
);
// Test successful lock
$gotLock
=
$this
->
lockingManager
->
getLock
(
$entries
[
0
],
'romanb'
);
...
...
@@ -51,7 +51,7 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
*/
public
function
testReleaseAgedLocks
()
{
$entries
=
$this
->
sess
ion
->
query
(
"FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"
);
$entries
=
$this
->
connect
ion
->
query
(
"FROM Forum_Entry WHERE Forum_Entry.author = 'Bart Simpson'"
);
$this
->
lockingManager
->
getLock
(
$entries
[
0
],
'romanb'
);
$released
=
$this
->
lockingManager
->
releaseAgedLocks
(
-
1
);
// age -1 seconds => release all
$this
->
assertTrue
(
$released
);
...
...
@@ -64,4 +64,4 @@ class Doctrine_PessimisticLockingTestCase extends Doctrine_UnitTestCase
?>
\ No newline at end of file
?>
tests/QueryLimitTestCase.php
View file @
a0958f7d
...
...
@@ -8,7 +8,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
parent
::
prepareTables
();
}
public
function
testLimitWithOneToOneLeftJoin
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
'User(id).Email'
)
->
limit
(
5
);
$users
=
$q
->
execute
();
...
...
@@ -17,7 +17,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
}
public
function
testLimitWithOneToOneInnerJoin
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
'User(id):Email'
)
->
limit
(
5
);
$users
=
$q
->
execute
();
...
...
@@ -51,7 +51,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
}
public
function
testLimitWithOneToManyLeftJoinAndCondition
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
"User(name)"
)
->
where
(
"User.Phonenumber.phonenumber LIKE '%123%'"
)
->
limit
(
5
);
$users
=
$q
->
execute
();
...
...
@@ -68,7 +68,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
}
public
function
testLimitWithOneToManyLeftJoinAndOrderBy
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
"User(name)"
)
->
where
(
"User.Phonenumber.phonenumber LIKE '%123%'"
)
->
orderby
(
"User.Email.address"
)
->
limit
(
5
);
$users
=
$q
->
execute
();
...
...
@@ -147,11 +147,11 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$users
=
$q
->
execute
(
array
(
'zYne'
));
$this
->
assertEqual
(
$users
->
count
(),
1
);
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
}
public
function
testLimitWithManyToManyColumnAggInheritanceLeftJoin
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
"User.Group"
)
->
limit
(
5
);
$users
=
$q
->
execute
();
...
...
@@ -169,7 +169,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$user
->
Group
[
0
]
->
name
,
"Action Actors"
);
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
$this
->
assertEqual
(
$user
->
Group
[
0
]
->
name
,
"Action Actors"
);
$this
->
assertEqual
(
count
(
$user
->
Group
),
3
);
...
...
@@ -182,7 +182,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$users
->
count
(),
3
);
$this
->
sess
ion
->
clear
();
$this
->
connect
ion
->
clear
();
$q
=
new
Doctrine_Query
();
$q
->
from
(
"User"
)
->
where
(
"User.Group.id = ?"
)
->
orderby
(
"User.id DESC"
);
$users
=
$q
->
execute
(
array
(
$user
->
Group
[
1
]
->
id
));
...
...
@@ -190,7 +190,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$users
->
count
(),
3
);
}
public
function
testLimitWithNormalManyToMany
()
{
$coll
=
new
Doctrine_Collection
(
$this
->
sess
ion
->
getTable
(
"Photo"
));
$coll
=
new
Doctrine_Collection
(
$this
->
connect
ion
->
getTable
(
"Photo"
));
$tag
=
new
Tag
();
$tag
->
tag
=
"Some tag"
;
$coll
[
0
]
->
Tag
[
0
]
=
$tag
;
...
...
@@ -201,7 +201,7 @@ class Doctrine_Query_Limit_TestCase extends Doctrine_UnitTestCase {
$coll
[
2
]
->
name
=
"photo 3"
;
$coll
[
3
]
->
Tag
[
0
]
->
tag
=
"Other tag"
;
$coll
[
3
]
->
name
=
"photo 4"
;
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
$q
=
new
Doctrine_Query
();
$q
->
from
(
"Photo"
)
->
where
(
"Photo.Tag.id = ?"
)
->
orderby
(
"Photo.id DESC"
)
->
limit
(
100
);
...
...
tests/QueryTestCase.php
View file @
a0958f7d
This diff is collapsed.
Click to expand it.
tests/RawSqlTestCase.php
View file @
a0958f7d
...
...
@@ -2,7 +2,7 @@
class
Doctrine_RawSql_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testQueryParser
()
{
$sql
=
"SELECT
{
p.*
}
FROM photos p"
;
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
$query
->
parseQuery
(
$sql
);
$this
->
assertEqual
(
$query
->
from
,
array
(
'photos p'
));
...
...
@@ -19,7 +19,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public
function
testAsteriskOperator
()
{
// Selecting with *
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
$query
->
parseQuery
(
"SELECT
{
entity.*
}
FROM entity"
);
$fields
=
$query
->
getFields
();
...
...
@@ -33,8 +33,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
}
public
function
testLazyPropertyLoading
()
{
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$this
->
sess
ion
->
clear
();
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
$this
->
connect
ion
->
clear
();
// selecting proxy objects (lazy property loading)
...
...
@@ -53,7 +53,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
}
public
function
testSmartMapping
()
{
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
// smart component mapping (no need for additional addComponent call
$query
->
parseQuery
(
"SELECT
{
entity.name
}
,
{
entity.id
}
FROM entity"
);
...
...
@@ -70,7 +70,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
}
public
function
testMultipleComponents
()
{
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
// multi component fetching
$query
->
parseQuery
(
"SELECT
{
entity.name
}
,
{
entity.id
}
,
{
phonenumber.*
}
FROM entity LEFT JOIN phonenumber ON phonenumber.entity_id = entity.id"
);
...
...
@@ -92,7 +92,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public
function
testPrimaryKeySelectForcing
()
{
// forcing the select of primary key fields
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
$query
->
parseQuery
(
"SELECT
{
entity.name
}
FROM entity"
);
...
...
@@ -104,7 +104,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
is_numeric
(
$coll
[
7
]
->
id
));
}
public
function
testMethodOverloading
()
{
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
$query
->
select
(
'{entity.name}'
)
->
from
(
'entity'
);
$query
->
addComponent
(
"entity"
,
"User"
);
$coll
=
$query
->
execute
();
...
...
@@ -117,7 +117,7 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
public
function
testColumnAggregationInheritance
()
{
// forcing the select of primary key fields
$query
=
new
Doctrine_RawSql
(
$this
->
sess
ion
);
$query
=
new
Doctrine_RawSql
(
$this
->
connect
ion
);
$query
->
parseQuery
(
"SELECT
{
entity.name
}
FROM entity"
);
$query
->
addComponent
(
"entity"
,
"User"
);
...
...
tests/RecordTestCase.php
View file @
a0958f7d
...
...
@@ -79,13 +79,13 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$e
->
Entity
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$e
->
Entity
[
1
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$coll
=
$this
->
sess
ion
->
query
(
"FROM Entity WHERE Entity.name = 'Friend 1'"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM Entity WHERE Entity.name = 'Friend 1'"
);
$this
->
assertEqual
(
$coll
->
count
(),
1
);
$this
->
assertEqual
(
$coll
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$coll
[
0
]
->
name
,
"Friend 1"
);
$query
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$query
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$query
->
from
(
"Entity.Entity"
)
->
where
(
"Entity.Entity.name = 'Friend 1 1'"
);
...
...
@@ -115,7 +115,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public
function
testSerialize
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$str
=
serialize
(
$user
);
$user2
=
unserialize
(
$str
);
...
...
@@ -191,26 +191,26 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$record
->
entity1
=
2
;
$record
->
save
();
$coll
=
$this
->
sess
ion
->
query
(
"FROM EntityReference-b"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM EntityReference-b"
);
$this
->
assertTrue
(
$coll
[
0
]
instanceof
EntityReference
);
$this
->
assertEqual
(
$coll
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertTrue
(
$coll
[
1
]
instanceof
EntityReference
);
$this
->
assertEqual
(
$coll
[
1
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$coll
=
$this
->
sess
ion
->
query
(
"FROM EntityReference-b WHERE EntityReference.entity2 = 5"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM EntityReference-b WHERE EntityReference.entity2 = 5"
);
$this
->
assertEqual
(
$coll
->
count
(),
1
);
}
public
function
testManyToManyTreeStructure
()
{
$task
=
$this
->
sess
ion
->
create
(
"Task"
);
$task
=
$this
->
connect
ion
->
create
(
"Task"
);
$this
->
assertEqual
(
$task
->
getTable
()
->
getAlias
(
"Resource"
),
"ResourceAlias"
);
$task
->
name
=
"Task 1"
;
$task
->
ResourceAlias
[
0
]
->
name
=
"Resource 1"
;
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
$this
->
assertTrue
(
$task
->
ResourceAlias
[
0
]
instanceof
Resource
);
$this
->
assertEqual
(
$task
->
ResourceAlias
[
0
]
->
name
,
"Resource 1"
);
...
...
@@ -234,7 +234,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$task
->
ResourceAlias
->
count
(),
1
);
$this
->
assertEqual
(
$task
->
Subtask
[
0
]
->
name
,
"Subtask 1"
);
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
$task
=
$task
->
getTable
()
->
find
(
$task
->
getID
());
...
...
@@ -274,7 +274,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$account
->
amount
=
2000
;
$this
->
assertEqual
(
$account
->
getTable
()
->
getColumnNames
(),
array
(
"id"
,
"entity_id"
,
"amount"
));
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
$this
->
assertEqual
(
$user
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertTrue
(
$account
instanceof
Account
);
...
...
@@ -316,9 +316,9 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public
function
testNewOperator
()
{
$table
=
$this
->
sess
ion
->
getTable
(
"User"
);
$table
=
$this
->
connect
ion
->
getTable
(
"User"
);
$this
->
assertEqual
(
$this
->
sess
ion
->
getTable
(
"User"
)
->
getData
(),
array
());
$this
->
assertEqual
(
$this
->
connect
ion
->
getTable
(
"User"
)
->
getData
(),
array
());
$user
=
new
User
();
$this
->
assertEqual
(
Doctrine_Lib
::
getRecordStateAsString
(
$user
->
getState
()),
Doctrine_Lib
::
getRecordStateAsString
(
Doctrine_Record
::
STATE_TCLEAN
));
$user
->
name
=
"John Locke"
;
...
...
@@ -357,8 +357,8 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
sess
ion
->
flush
();
$elements
=
$this
->
sess
ion
->
query
(
"FROM Element-l"
);
$this
->
connect
ion
->
flush
();
$elements
=
$this
->
connect
ion
->
query
(
"FROM Element-l"
);
$this
->
assertEqual
(
$elements
->
count
(),
5
);
$e
=
$e
->
getTable
()
->
find
(
1
);
...
...
@@ -422,7 +422,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$e
->
save
();
$coll
=
$this
->
sess
ion
->
query
(
"FROM Error-I"
);
$coll
=
$this
->
connect
ion
->
query
(
"FROM Error-I"
);
$e
=
$coll
[
0
];
...
...
@@ -467,7 +467,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$debug
=
$this
->
listener
->
getMessages
();
$p
=
array_pop
(
$debug
);
$this
->
assertTrue
(
$p
->
getObject
()
instanceof
Doctrine_
Sess
ion
);
$this
->
assertTrue
(
$p
->
getObject
()
instanceof
Doctrine_
Connect
ion
);
$this
->
assertTrue
(
$p
->
getCode
()
==
Doctrine_EventListener_Debugger
::
EVENT_COMMIT
);
$user
->
delete
();
...
...
@@ -475,7 +475,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public
function
testUpdate
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
->
set
(
"name"
,
"Jack Daniels"
,
true
);
...
...
@@ -487,7 +487,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$debug
=
$this
->
listener
->
getMessages
();
$p
=
array_pop
(
$debug
);
$this
->
assertTrue
(
$p
->
getObject
()
instanceof
Doctrine_
Sess
ion
);
$this
->
assertTrue
(
$p
->
getObject
()
instanceof
Doctrine_
Connect
ion
);
$this
->
assertTrue
(
$p
->
getCode
()
==
Doctrine_EventListener_Debugger
::
EVENT_COMMIT
);
$p
=
array_pop
(
$debug
);
...
...
@@ -501,7 +501,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public
function
testCopy
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$new
=
$user
->
copy
();
$this
->
assertTrue
(
$new
instanceof
Doctrine_Record
);
$this
->
assertTrue
(
$new
->
getState
()
==
Doctrine_Record
::
STATE_TDIRTY
);
...
...
@@ -511,7 +511,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$user
=
$this
->
objTable
->
find
(
5
);
$pf
=
$this
->
sess
ion
->
getTable
(
"Phonenumber"
);
$pf
=
$this
->
connect
ion
->
getTable
(
"Phonenumber"
);
$this
->
assertTrue
(
$user
->
Phonenumber
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$user
->
Phonenumber
->
count
(),
3
);
...
...
@@ -615,7 +615,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
// REPLACING ONE-TO-ONE REFERENCES
$email
=
$this
->
sess
ion
->
create
(
"Email"
);
$email
=
$this
->
connect
ion
->
create
(
"Email"
);
$email
->
address
=
"absolutist@nottodrink.com"
;
$user
->
Email
=
$email
;
...
...
@@ -628,7 +628,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$user
->
Email
instanceof
Email
);
$this
->
assertEqual
(
$user
->
Email
->
address
,
"absolutist@nottodrink.com"
);
$emails
=
$this
->
sess
ion
->
query
(
"FROM Email WHERE Email.id =
$id
"
);
$emails
=
$this
->
connect
ion
->
query
(
"FROM Email WHERE Email.id =
$id
"
);
//$this->assertEqual(count($emails),0);
}
...
...
@@ -643,7 +643,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
public
function
testSaveAssociations
()
{
$user
=
$this
->
objTable
->
find
(
5
);
$gf
=
$this
->
sess
ion
->
getTable
(
"Group"
);
$gf
=
$this
->
connect
ion
->
getTable
(
"Group"
);
$this
->
assertTrue
(
$user
->
Group
instanceof
Doctrine_Collection
);
...
...
@@ -743,13 +743,13 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
}
public
function
testCount
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$this
->
assertTrue
(
is_integer
(
$user
->
count
()));
}
public
function
testGetReference
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$this
->
assertTrue
(
$user
->
Email
instanceof
Doctrine_Record
);
$this
->
assertTrue
(
$user
->
Phonenumber
instanceof
Doctrine_Collection
);
...
...
@@ -758,7 +758,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$user
->
Phonenumber
->
count
()
==
1
);
}
public
function
testGetIterator
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$this
->
assertTrue
(
$user
->
getIterator
()
instanceof
ArrayIterator
);
}
...
...
tests/TableTestCase.php
View file @
a0958f7d
...
...
@@ -2,11 +2,11 @@
require_once
(
"UnitTestCase.php"
);
class
Doctrine_TableTestCase
extends
Doctrine_UnitTestCase
{
public
function
testBind
()
{
$table
=
$this
->
sess
ion
->
getTable
(
"User"
);
$table
=
$this
->
connect
ion
->
getTable
(
"User"
);
}
public
function
testGetIdentifier
()
{
$table
=
$this
->
sess
ion
->
getTable
(
"User"
);
$table
=
$this
->
connect
ion
->
getTable
(
"User"
);
}
public
function
testGetForeignKey
()
{
$fk
=
$this
->
objTable
->
getForeignKey
(
"Group"
);
...
...
@@ -39,8 +39,8 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
public
function
testGetTableName
()
{
$this
->
assertTrue
(
$this
->
objTable
->
getTableName
()
==
"entity"
);
}
public
function
testGet
Sess
ion
()
{
$this
->
assertTrue
(
$this
->
objTable
->
get
Session
()
instanceof
Doctrine_Sess
ion
);
public
function
testGet
Connect
ion
()
{
$this
->
assertTrue
(
$this
->
objTable
->
get
Connection
()
instanceof
Doctrine_Connect
ion
);
}
public
function
testGetData
()
{
$this
->
assertTrue
(
$this
->
objTable
->
getData
()
==
array
());
...
...
tests/UnitTestCase.php
View file @
a0958f7d
...
...
@@ -19,7 +19,7 @@ require_once("simpletest/reporter.php");
class
Doctrine_UnitTestCase
extends
UnitTestCase
{
protected
$manager
;
protected
$
sess
ion
;
protected
$
connect
ion
;
protected
$objTable
;
protected
$new
;
protected
$old
;
...
...
@@ -63,24 +63,24 @@ class Doctrine_UnitTestCase extends UnitTestCase {
if
(
$this
->
manager
->
count
()
>
0
)
{
$this
->
session
=
$this
->
manager
->
getSess
ion
(
0
);
$this
->
sess
ion
->
evictTables
();
$this
->
dbh
=
$this
->
sess
ion
->
getDBH
();
$this
->
connection
=
$this
->
manager
->
getConnect
ion
(
0
);
$this
->
connect
ion
->
evictTables
();
$this
->
dbh
=
$this
->
connect
ion
->
getDBH
();
$this
->
listener
=
$this
->
manager
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
);
}
else
{
//$this->dbh = Doctrine_DB::getConnection();
$this
->
dbh
=
Doctrine_DB
::
getConn
(
"sqlite::memory:"
);
//$this->dbh = new PDO("sqlite::memory:");
$this
->
session
=
$this
->
manager
->
openSess
ion
(
$this
->
dbh
);
$this
->
connection
=
$this
->
manager
->
openConnect
ion
(
$this
->
dbh
);
$this
->
listener
=
new
Doctrine_EventListener_Debugger
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_LISTENER
,
$this
->
listener
);
}
$this
->
query
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$this
->
query
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$this
->
prepareTables
();
$this
->
prepareData
();
$this
->
valueHolder
=
new
Doctrine_ValueHolder
(
$this
->
sess
ion
->
getTable
(
'User'
));
$this
->
valueHolder
=
new
Doctrine_ValueHolder
(
$this
->
connect
ion
->
getTable
(
'User'
));
}
public
function
prepareTables
()
{
foreach
(
$this
->
tables
as
$name
)
{
...
...
@@ -94,15 +94,15 @@ class Doctrine_UnitTestCase extends UnitTestCase {
foreach
(
$this
->
tables
as
$name
)
{
$name
=
ucwords
(
$name
);
$table
=
$this
->
sess
ion
->
getTable
(
$name
);
$table
=
$this
->
connect
ion
->
getTable
(
$name
);
$table
->
getCache
()
->
deleteAll
();
$table
->
clear
();
}
$this
->
objTable
=
$this
->
sess
ion
->
getTable
(
"User"
);
$this
->
objTable
=
$this
->
connect
ion
->
getTable
(
"User"
);
}
public
function
prepareData
()
{
$groups
=
new
Doctrine_Collection
(
$this
->
sess
ion
->
getTable
(
"Group"
));
$groups
=
new
Doctrine_Collection
(
$this
->
connect
ion
->
getTable
(
"Group"
));
$groups
[
0
]
->
name
=
"Drama Actors"
;
...
...
@@ -113,7 +113,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$groups
[
2
][
"Phonenumber"
][
0
]
->
phonenumber
=
"123 123"
;
$groups
->
save
();
$users
=
new
Doctrine_Collection
(
$this
->
sess
ion
->
getTable
(
"User"
));
$users
=
new
Doctrine_Collection
(
$this
->
connect
ion
->
getTable
(
"User"
));
$users
[
0
]
->
name
=
"zYne"
;
...
...
@@ -156,14 +156,14 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$users
[
7
]
->
Phonenumber
[
0
]
->
phonenumber
=
"111 567 333"
;
$this
->
users
=
$users
;
$this
->
sess
ion
->
flush
();
$this
->
connect
ion
->
flush
();
}
public
function
get
Sess
ion
()
{
return
$this
->
sess
ion
;
public
function
get
Connect
ion
()
{
return
$this
->
connect
ion
;
}
public
function
clearCache
()
{
foreach
(
$this
->
tables
as
$name
)
{
$table
=
$this
->
sess
ion
->
getTable
(
$name
);
$table
=
$this
->
connect
ion
->
getTable
(
$name
);
$table
->
getCache
()
->
deleteAll
();
}
}
...
...
tests/ValidatorTestCase.php
View file @
a0958f7d
...
...
@@ -93,7 +93,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
}
public
function
testValidate
()
{
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
$set
=
array
(
"password"
=>
"this is an example of too long password"
,
"loginname"
=>
"this is an example of too long loginname"
,
...
...
@@ -129,7 +129,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
$validator
=
new
Doctrine_Validator_Email
();
$email
=
$this
->
sess
ion
->
create
(
"Email"
);
$email
=
$this
->
connect
ion
->
create
(
"Email"
);
$this
->
assertFalse
(
$validator
->
validate
(
$email
,
"address"
,
"example@example"
,
null
));
$this
->
assertFalse
(
$validator
->
validate
(
$email
,
"address"
,
"example@@example"
,
null
));
$this
->
assertFalse
(
$validator
->
validate
(
$email
,
"address"
,
"example@example."
,
null
));
...
...
@@ -141,7 +141,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
}
public
function
testSave
()
{
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_VLD
,
true
);
$user
=
$this
->
sess
ion
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connect
ion
->
getTable
(
"User"
)
->
find
(
4
);
try
{
$user
->
name
=
"this is an example of too long name not very good example but an example nevertheless"
;
$user
->
save
();
...
...
@@ -150,7 +150,7 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
}
try
{
$user
=
$this
->
sess
ion
->
create
(
"User"
);
$user
=
$this
->
connect
ion
->
create
(
"User"
);
$user
->
Email
->
address
=
"jackdaniels@drinkmore.info..."
;
$user
->
name
=
"this is an example of too long user name not very good example but an example nevertheles"
;
$user
->
save
();
...
...
tests/ValueHolderTestCase.php
View file @
a0958f7d
...
...
@@ -17,7 +17,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
valueHolder
->
get
(
'key'
),
'second'
);
}
public
function
testSimpleQuery
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
"User"
);
$users
=
$q
->
execute
(
array
(),
Doctrine
::
FETCH_VHOLDER
);
$this
->
assertEqual
(
$users
->
count
(),
8
);
...
...
@@ -25,7 +25,7 @@ class Doctrine_ValueHolder_TestCase extends Doctrine_UnitTestCase {
}
public
function
testQueryWithOneToManyRelation
()
{
$q
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$q
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$q
->
from
(
"User.Phonenumber"
);
$users
=
$q
->
execute
(
array
(),
Doctrine
::
FETCH_VHOLDER
);
$this
->
assertEqual
(
$users
->
count
(),
8
);
...
...
tests/ViewTestCase.php
View file @
a0958f7d
<?php
class
Doctrine_ViewTestCase
extends
Doctrine_UnitTestCase
{
public
function
testCreateView
()
{
$query
=
new
Doctrine_Query
(
$this
->
sess
ion
);
$query
=
new
Doctrine_Query
(
$this
->
connect
ion
);
$query
->
from
(
'User'
);
$view
=
new
Doctrine_View
(
$query
,
'MyView'
);
...
...
@@ -38,6 +38,6 @@ class Doctrine_ViewTestCase extends Doctrine_UnitTestCase {
}
public
function
testConstructor
()
{
}
}
}
?>
tests/classes.php
View file @
a0958f7d
...
...
@@ -47,8 +47,8 @@ class Address extends Doctrine_Record {
}
}
// grouptable doesn't extend Doctrine_Table -> Doctrine_
Sess
ion
// won't initialize grouptable when Doctrine_
Sess
ion->getTable("Group") is called
// grouptable doesn't extend Doctrine_Table -> Doctrine_
Connect
ion
// won't initialize grouptable when Doctrine_
Connect
ion->getTable("Group") is called
class
GroupTable
{
}
class
Group
extends
Entity
{
...
...
tests/run.php
View file @
a0958f7d
...
...
@@ -3,7 +3,7 @@ ob_start();
require_once
(
"ConfigurableTestCase.php"
);
require_once
(
"ManagerTestCase.php"
);
require_once
(
"
Sess
ionTestCase.php"
);
require_once
(
"
Connect
ionTestCase.php"
);
require_once
(
"TableTestCase.php"
);
require_once
(
"EventListenerTestCase.php"
);
require_once
(
"BatchIteratorTestCase.php"
);
...
...
@@ -31,7 +31,7 @@ $test = new GroupTest("Doctrine Framework Unit Tests");
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_
Sess
ionTestCase
());
$test
->
addTestCase
(
new
Doctrine_
Connect
ionTestCase
());
$test
->
addTestCase
(
new
Doctrine_TableTestCase
());
...
...
@@ -76,7 +76,7 @@ $test->addTestCase(new Doctrine_Query_Limit_TestCase());
print
"<pre>"
;
$test
->
run
(
new
HtmlReporter
());
/**
$cache = Doctrine_Manager::getInstance()->getCurrent
Sess
ion()->getCacheHandler();
$cache = Doctrine_Manager::getInstance()->getCurrent
Connect
ion()->getCacheHandler();
if(isset($cache)) {
$a = $cache->getQueries();
print "Executed cache queries: ".count($a)."\n";
...
...
@@ -88,7 +88,7 @@ if(isset($cache)) {
}
*/
$dbh
=
Doctrine_Manager
::
getInstance
()
->
getCurrent
Sess
ion
()
->
getDBH
();
$dbh
=
Doctrine_Manager
::
getInstance
()
->
getCurrent
Connect
ion
()
->
getDBH
();
$a
=
$dbh
->
getQueries
();
print
"Executed queries: "
.
count
(
$a
)
.
"
\n
"
;
...
...
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