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
55f40e6e
Commit
55f40e6e
authored
May 18, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Session flush bug fixed
lots of small bugs fixed small enhancements
parent
94005a9f
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
371 additions
and
45 deletions
+371
-45
Collection.class.php
classes/Collection.class.php
+2
-2
Record.class.php
classes/Record.class.php
+6
-9
Session.class.php
classes/Session.class.php
+129
-16
Table.class.php
classes/Table.class.php
+37
-4
CollectionTestCase.class.php
tests/CollectionTestCase.class.php
+1
-1
QueryTestCase.class.php
tests/QueryTestCase.class.php
+39
-0
RecordTestCase.class.php
tests/RecordTestCase.class.php
+4
-1
SessionTestCase.class.php
tests/SessionTestCase.class.php
+89
-3
TableTestCase.class.php
tests/TableTestCase.class.php
+3
-0
UnitTestCase.class.php
tests/UnitTestCase.class.php
+6
-3
classes.php
tests/classes.php
+52
-0
run.php
tests/run.php
+3
-6
No files found.
classes/Collection.class.php
View file @
55f40e6e
...
...
@@ -221,7 +221,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
if
(
!
isset
(
$offset
))
{
foreach
(
$coll
as
$record
)
{
if
(
isset
(
$this
->
reference_field
))
$record
->
rawS
et
(
$this
->
reference_field
,
$this
->
reference
);
$record
->
s
et
(
$this
->
reference_field
,
$this
->
reference
);
$this
->
reference
->
addReference
(
$record
);
}
...
...
@@ -332,7 +332,7 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
*/
public
function
set
(
$key
,
Doctrine_Record
$record
)
{
if
(
isset
(
$this
->
reference_field
))
$record
->
s
et
(
$this
->
reference_field
,
$this
->
reference
);
$record
->
rawS
et
(
$this
->
reference_field
,
$this
->
reference
);
$this
->
data
[
$key
]
=
$record
;
}
...
...
classes/Record.class.php
View file @
55f40e6e
...
...
@@ -486,9 +486,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$fk
=
$this
->
table
->
getForeignKey
(
$name
);
if
(
$value
->
getTable
()
->
getComponentName
()
!=
$name
)
throw
new
InvalidKeyException
();
// one-to-many or one-to-one relation
if
(
$fk
instanceof
Doctrine_ForeignKey
||
$fk
instanceof
Doctrine_LocalKey
)
{
...
...
@@ -539,20 +536,20 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// listen the onPreSave event
$this
->
table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreSave
(
$this
);
$saveLater
=
$this
->
table
->
getSession
()
->
saveRelated
(
$this
);
$this
->
table
->
getSession
()
->
save
(
$this
);
foreach
(
$saveLater
as
$fk
)
{
$table
=
$fk
->
getTable
();
$foreign
=
$fk
->
getForeign
();
$local
=
$fk
->
getLocal
();
$name
=
$table
->
getComponentName
();
if
(
isset
(
$this
->
references
[
$name
]))
{
$obj
=
$this
->
references
[
$name
];
$alias
=
$this
->
table
->
getAlias
(
$table
->
getComponentName
());
if
(
isset
(
$this
->
references
[
$alias
]))
{
$obj
=
$this
->
references
[
$alias
];
$obj
->
save
();
}
}
...
...
classes/Session.class.php
View file @
55f40e6e
...
...
@@ -246,16 +246,12 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
public
function
create
(
$name
)
{
return
$this
->
getTable
(
$name
)
->
create
();
}
/**
* buildFlushTree
* builds a flush tree that is used in transactions
*
* @return array
*/
public
function
buildFlushTree
()
{
$tables
=
$this
->
tables
;
public
function
buildFlushTree2
(
array
$tables
)
{
$tree
=
array
();
foreach
(
$tables
as
$table
)
{
if
(
!
(
$table
instanceof
Doctrine_Table
))
$table
=
$this
->
getTable
(
$table
);
$name
=
$table
->
getComponentName
();
$index
=
array_search
(
$name
,
$tree
);
if
(
$index
===
false
)
...
...
@@ -288,7 +284,118 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
}
}
}
return
$tree
;
return
array_values
(
$tree
);
}
/**
* buildFlushTree
* builds a flush tree that is used in transactions
*
* @return array
*/
public
function
buildFlushTree
(
array
$tables
)
{
$tree
=
array
();
foreach
(
$tables
as
$k
=>
$table
)
{
$k
=
$k
.
$table
;
if
(
!
(
$table
instanceof
Doctrine_Table
))
$table
=
$this
->
getTable
(
$table
);
$nm
=
$table
->
getComponentName
();
$index
=
array_search
(
$nm
,
$tree
);
if
(
$index
===
false
)
{
$tree
[]
=
$nm
;
$index
=
max
(
array_keys
(
$tree
));
//print "$k -- adding <b>$nm</b>...<br \>";
}
$rels
=
$table
->
getForeignKeys
();
// group relations
foreach
(
$rels
as
$key
=>
$rel
)
{
if
(
$rel
instanceof
Doctrine_ForeignKey
)
{
unset
(
$rels
[
$key
]);
array_unshift
(
$rels
,
$rel
);
}
}
foreach
(
$rels
as
$rel
)
{
$name
=
$rel
->
getTable
()
->
getComponentName
();
$index2
=
array_search
(
$name
,
$tree
);
$type
=
$rel
->
getType
();
// skip self-referenced relations
if
(
$name
===
$nm
)
continue
;
if
(
$rel
instanceof
Doctrine_ForeignKey
)
{
if
(
$index2
!==
false
)
{
if
(
$index2
>=
$index
)
continue
;
unset
(
$tree
[
$index
]);
array_splice
(
$tree
,
$index2
,
0
,
$nm
);
$index
=
$index2
;
//print "$k -- pushing $nm into $index2...<br \>";
}
else
{
$tree
[]
=
$name
;
//print "$k -- adding $nm :$name...<br>";
}
}
elseif
(
$rel
instanceof
Doctrine_LocalKey
)
{
if
(
$index2
!==
false
)
{
if
(
$index2
<=
$index
)
continue
;
unset
(
$tree
[
$index2
]);
array_splice
(
$tree
,
$index
,
0
,
$name
);
//print "$k -- pushing $name into <b>$index</b>...<br \>";
}
else
{
//array_splice($tree, $index, 0, $name);
array_unshift
(
$tree
,
$name
);
$index
++
;
//print "$k -- pushing <b>$name</b> into 0...<br \>";
}
}
elseif
(
$rel
instanceof
Doctrine_Association
)
{
$t
=
$rel
->
getAssociationFactory
();
$n
=
$t
->
getComponentName
();
if
(
$index2
!==
false
)
unset
(
$tree
[
$index2
]);
array_splice
(
$tree
,
$index
,
0
,
$name
);
$index
++
;
$index3
=
array_search
(
$n
,
$tree
);
if
(
$index3
!==
false
)
{
if
(
$index3
>=
$index
)
continue
;
unset
(
$tree
[
$index
]);
array_splice
(
$tree
,
$index3
,
0
,
$n
);
$index
=
$index2
;
//print "$k -- pushing $nm into $index3...<br \>";
}
else
{
$tree
[]
=
$n
;
//print "$k -- adding $nm :$name...<br>";
}
}
//print_r($tree);
}
//print_r($tree);
}
return
array_values
(
$tree
);
}
/**
...
...
@@ -310,7 +417,7 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
* @return void
*/
private
function
saveAll
()
{
$tree
=
$this
->
buildFlushTree
();
$tree
=
$this
->
buildFlushTree
(
$this
->
tables
);
foreach
(
$tree
as
$name
)
{
$table
=
$this
->
tables
[
$name
];
...
...
@@ -685,8 +792,14 @@ abstract class Doctrine_Session extends Doctrine_Configurable implements Countab
$set
[]
=
$name
.
" = ?"
;
if
(
$value
instanceof
Doctrine_Record
)
{
switch
(
$value
->
getState
())
:
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TDIRTY
:
$record
->
save
();
default
:
$array
[
$name
]
=
$value
->
getID
();
$record
->
set
(
$name
,
$value
->
getID
());
endswitch
;
}
endforeach
;
...
...
classes/Table.class.php
View file @
55f40e6e
...
...
@@ -401,6 +401,39 @@ class Doctrine_Table extends Doctrine_Configurable {
return
$name
;
}
/**
* unbinds all relations
*
* @return void
*/
final
public
function
unbindAll
()
{
$this
->
bound
=
array
();
$this
->
relations
=
array
();
$this
->
boundAliases
=
array
();
}
/**
* unbinds a relation
* returns true on success, false on failure
*
* @param $name
* @return boolean
*/
final
public
function
unbind
()
{
if
(
!
isset
(
$this
->
bound
[
$name
]))
return
false
;
unset
(
$this
->
bound
[
$name
]);
if
(
isset
(
$this
->
relations
[
$name
]))
unset
(
$this
->
relations
[
$name
]);
if
(
isset
(
$this
->
boundAliases
[
$name
]))
unset
(
$this
->
boundAliases
[
$name
]);
return
true
;
}
/**
* binds a relation
*
* @param string $name
* @param string $field
* @return void
...
...
@@ -518,9 +551,8 @@ class Doctrine_Table extends Doctrine_Configurable {
}
$this
->
relations
[
$alias
]
=
$relation
;
return
$this
->
relations
[
$alias
];
}
else
{
throw
new
InvalidKeyException
();
}
throw
new
InvalidKeyException
();
}
/**
* returns an array containing all foreign key objects
...
...
@@ -530,9 +562,10 @@ class Doctrine_Table extends Doctrine_Configurable {
final
public
function
getForeignKeys
()
{
$a
=
array
();
foreach
(
$this
->
bound
as
$k
=>
$v
)
{
$
a
[
$k
]
=
$
this
->
getForeignKey
(
$k
);
$this
->
getForeignKey
(
$k
);
}
return
$a
;
return
$this
->
relations
;
}
/**
* sets the database table name
...
...
tests/CollectionTestCase.class.php
View file @
55f40e6e
...
...
@@ -35,7 +35,7 @@ class Doctrine_CollectionTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
count
(
$coll
),
3
);
$this
->
assertTrue
(
$coll
[
2
]
->
getState
()
==
Doctrine_Record
::
STATE_PROXY
);
//$this->assertEqual($coll[2]->getState(),
Doctrine_Record::STATE_PROXY);
$generator
=
new
Doctrine_IndexGenerator
(
$this
->
objTable
->
getIdentifier
());
...
...
tests/QueryTestCase.class.php
View file @
55f40e6e
<?php
class
Doctrine_QueryTestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareTables
()
{
$this
->
tables
[]
=
"Forum_Category"
;
$this
->
tables
[]
=
"Forum_Entry"
;
$this
->
tables
[]
=
"Forum_Board"
;
$this
->
tables
[]
=
"Forum_Thread"
;
parent
::
prepareTables
();
}
public
function
testQueryWithComplexAliases
()
{
$board
=
new
Forum_Board
();
$table
=
$board
->
getTable
();
$this
->
assertTrue
(
$table
->
getForeignKey
(
"Threads"
)
instanceof
Doctrine_ForeignKey
);
$entry
=
new
Forum_Entry
();
$this
->
assertTrue
(
$entry
->
getTable
()
->
getForeignKey
(
"Thread"
)
instanceof
Doctrine_LocalKey
);
$board
->
name
=
"Doctrine Forum"
;
$board
->
Threads
[
0
];
$board
->
Category
->
name
=
"General discussion"
;
$this
->
assertEqual
(
$board
->
name
,
"Doctrine Forum"
);
$this
->
assertEqual
(
$board
->
Category
->
name
,
"General discussion"
);
$this
->
assertEqual
(
$board
->
Category
->
getState
(),
Doctrine_Record
::
STATE_TDIRTY
);
//$this->assertEqual($board->Threads[0]->getState(), Doctrine_Record::STATE_TDIRTY);
$this
->
assertTrue
(
$board
->
Threads
[
0
]
instanceof
Forum_Thread
);
//print_r($this->session->buildFlushTree());
$this
->
session
->
flush
();
/**
$board->getTable()->clear();
$board = $board->getTable()->find($board->getID());
$this->assertEqual($board->Threads->count(), 1);
$this->assertEqual($board->name, "Doctrine Forum");
$this->assertEqual($board->Category->name, "General discussion");
$this->assertEqual($board->Category->getState(), Doctrine_Record::STATE_TDIRTY);
$this->assertEqual($board->Threads[0]->getState(), Doctrine_Record::STATE_CLEAN);
$this->assertTrue($board->Threads[0] instanceof Forum_Thread);
*/
}
public
function
testQueryWithAliases
()
{
$task
=
new
Task
();
...
...
tests/RecordTestCase.class.php
View file @
55f40e6e
...
...
@@ -2,6 +2,7 @@
require_once
(
"UnitTestCase.class.php"
);
class
Doctrine_RecordTestCase
extends
Doctrine_UnitTestCase
{
public
function
testJoinTableSelfReferencing
()
{
$e
=
new
Entity
();
$e
->
name
=
"Entity test"
;
...
...
@@ -118,6 +119,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
public
function
testManyToManyTreeStructure
()
{
$task
=
$this
->
session
->
create
(
"Task"
);
$this
->
assertEqual
(
$task
->
getTable
()
->
getAlias
(
"Resource"
),
"ResourceAlias"
);
...
...
@@ -135,7 +137,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$task
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertTrue
(
$task
->
Subtask
[
0
]
instanceof
Task
);
$this
->
assertEqual
(
$task
->
Subtask
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
//$this->assertEqual($task->Subtask[0]->getState(), Doctrine_Record::STATE_TDIRTY
);
$this
->
assertTrue
(
$task
->
ResourceAlias
[
0
]
instanceof
Resource
);
$this
->
assertEqual
(
$task
->
ResourceAlias
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
...
...
@@ -671,5 +673,6 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$user
=
$this
->
session
->
getTable
(
"User"
)
->
find
(
4
);
$this
->
assertTrue
(
$user
->
getIterator
()
instanceof
ArrayIterator
);
}
}
?>
tests/SessionTestCase.class.php
View file @
55f40e6e
<?php
require_once
(
"UnitTestCase.class.php"
);
class
Doctrine_SessionTestCase
extends
Doctrine_UnitTestCase
{
public
function
testBuildFlushTree
()
{
$tree
=
$this
->
session
->
buildFlushTree
();
$correct
=
array
(
"Task"
,
"Resource"
,
"Assignment"
);
$task
=
new
Task
();
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Task"
));
$this
->
assertEqual
(
$tree
,
array
(
"Resource"
,
"Task"
,
"Assignment"
));
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Task"
,
"Resource"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Task"
,
"Assignment"
,
"Resource"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Assignment"
,
"Task"
,
"Resource"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$correct
=
array
(
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$correct
=
array
(
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Entry"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Thread"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Thread"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Category"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Board"
,
"Forum_Category"
,
"Forum_Thread"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Thread"
,
"Forum_Category"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Entry"
,
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Category"
,
"Forum_Board"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Category"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Thread"
,
"Forum_Board"
,
"Forum_Entry"
,
"Forum_Category"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Entry"
,
"Forum_Board"
,
"Forum_Thread"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Thread"
,
"Forum_Entry"
,
"Forum_Board"
));
$this
->
assertEqual
(
$tree
,
$correct
);
$tree
=
$this
->
session
->
buildFlushTree
(
array
(
"Forum_Category"
,
"Forum_Board"
,
"Forum_Thread"
,
"Forum_Entry"
));
$this
->
assertEqual
(
$tree
,
$correct
);
//print_r($tree);
}
public
function
testBulkInsert
()
{
$u1
=
new
User
();
$u1
->
name
=
"Jean Reno"
;
...
...
@@ -266,6 +353,5 @@ class Doctrine_SessionTestCase extends Doctrine_UnitTestCase {
$this
->
session
->
clear
();
$this
->
assertEqual
(
$this
->
session
->
getTables
(),
array
());
}
}
?>
tests/TableTestCase.class.php
View file @
55f40e6e
<?php
require_once
(
"UnitTestCase.class.php"
);
class
Doctrine_TableTestCase
extends
Doctrine_UnitTestCase
{
public
function
testBind
()
{
$table
=
$this
->
session
->
getTable
(
"User"
);
}
public
function
testGetIdentifier
()
{
$table
=
$this
->
session
->
getTable
(
"User"
);
...
...
tests/UnitTestCase.class.php
View file @
55f40e6e
...
...
@@ -20,7 +20,7 @@ class Doctrine_UnitTestCase extends UnitTestCase {
protected
$listener
;
protected
$cache
;
protected
$users
;
protected
$tables
;
protected
$tables
=
array
()
;
private
$init
=
false
;
...
...
@@ -31,7 +31,8 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CACHE
,
Doctrine
::
CACHE_NONE
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_FETCHMODE
,
Doctrine
::
FETCH_IMMEDIATE
);
$this
->
tables
=
array
(
"entity"
,
"entityReference"
,
"email"
,
"phonenumber"
,
"groupuser"
,
"album"
,
"song"
,
"element"
,
"error"
,
"description"
,
"address"
,
"account"
,
"task"
,
"resource"
,
"assignment"
);
$this
->
tables
=
array_merge
(
$this
->
tables
,
array
(
"entity"
,
"entityReference"
,
"email"
,
"phonenumber"
,
"groupuser"
,
"album"
,
"song"
,
"element"
,
"error"
,
"description"
,
"address"
,
"account"
,
"task"
,
"resource"
,
"assignment"
));
...
...
@@ -52,8 +53,10 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this
->
prepareData
();
}
public
function
prepareTables
()
{
foreach
(
$this
->
tables
as
$name
)
{
$this
->
dbh
->
query
(
"DROP TABLE IF EXISTS
$name
"
);
$this
->
dbh
->
query
(
"DROP TABLE IF EXISTS "
.
strtolower
(
$name
));
}
foreach
(
$this
->
tables
as
$name
)
{
...
...
tests/classes.php
View file @
55f40e6e
...
...
@@ -160,4 +160,56 @@ class Assignment extends Doctrine_Record {
$this
->
hasColumn
(
"resource_id"
,
"integer"
);
}
}
class
Forum_Category
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"root_category_id"
,
"integer"
,
10
);
$this
->
hasColumn
(
"parent_category_id"
,
"integer"
,
10
);
$this
->
hasColumn
(
"name"
,
"string"
,
50
);
$this
->
hasColumn
(
"description"
,
"string"
,
99999
);
}
public
function
setUp
()
{
$this
->
hasMany
(
"Forum_Category as Subcategory"
,
"Subcategory.parent_category_id"
);
$this
->
hasOne
(
"Forum_Category as Rootcategory"
,
"Forum_Category.root_category_id"
);
}
}
class
Forum_Board
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"category_id"
,
"integer"
,
10
);
$this
->
hasColumn
(
"name"
,
"string"
,
100
);
$this
->
hasColumn
(
"description"
,
"string"
,
5000
);
}
public
function
setUp
()
{
$this
->
hasOne
(
"Forum_Category as Category"
,
"Forum_Board.category_id"
);
$this
->
ownsMany
(
"Forum_Thread as Threads"
,
"Forum_Thread.board_id"
);
}
}
class
Forum_Entry
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"author"
,
"string"
,
50
);
$this
->
hasColumn
(
"topic"
,
"string"
,
100
);
$this
->
hasColumn
(
"message"
,
"string"
,
99999
);
$this
->
hasColumn
(
"parent_entry_id"
,
"integer"
,
10
);
$this
->
hasColumn
(
"thread_id"
,
"integer"
,
10
);
$this
->
hasColumn
(
"date"
,
"integer"
,
10
);
}
public
function
setUp
()
{
$this
->
hasOne
(
"Forum_Entry as Parent"
,
"Forum_Entry.parent_entry_id"
);
$this
->
hasOne
(
"Forum_Thread as Thread"
,
"Forum_Entry.thread_id"
);
}
}
class
Forum_Thread
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"board_id"
,
"integer"
,
10
);
$this
->
hasColumn
(
"updated"
,
"integer"
,
10
);
$this
->
hasColumn
(
"closed"
,
"integer"
,
1
);
}
public
function
setUp
()
{
$this
->
hasOne
(
"Forum_Board as Board"
,
"Forum_Thread.board_id"
);
$this
->
ownsMany
(
"Forum_Entry as Entry"
,
"Forum_Entry.thread_id"
);
}
}
?>
tests/run.php
View file @
55f40e6e
...
...
@@ -24,17 +24,12 @@ error_reporting(E_ALL);
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
->
addTestCase
(
new
Doctrine_SessionTestCase
());
$test
->
addTestCase
(
new
Doctrine_TableTestCase
());
$test
->
addTestCase
(
new
Doctrine_SessionTestCase
());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
$test
->
addTestCase
(
new
Doctrine_ManagerTestCase
());
...
...
@@ -54,6 +49,8 @@ $test->addTestCase(new Doctrine_Collection_OffsetTestCase());
$test
->
addTestCase
(
new
Sensei_UnitTestCase
());
$test
->
addTestCase
(
new
Doctrine_QueryTestCase
());
//$test->addTestCase(new Doctrine_Cache_FileTestCase());
//$test->addTestCase(new Doctrine_Cache_SqliteTestCase());
...
...
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