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
bafcd662
Commit
bafcd662
authored
Apr 27, 2006
by
doctrine
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
ff9c9d84
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
113 additions
and
54 deletions
+113
-54
Collection.class.php
classes/Collection.class.php
+4
-4
Batch.class.php
classes/Collection/Batch.class.php
+1
-1
Parser.class.php
classes/DQL/Parser.class.php
+2
-0
Record.class.php
classes/Record.class.php
+32
-44
DQLParserTestCase.class.php
tests/DQLParserTestCase.class.php
+2
-0
RecordTestCase.class.php
tests/RecordTestCase.class.php
+37
-0
UnitTestCase.class.php
tests/UnitTestCase.class.php
+1
-1
ValidatorTestCase.class.php
tests/ValidatorTestCase.class.php
+0
-1
classes.php
tests/classes.php
+27
-0
run.php
tests/run.php
+7
-3
No files found.
classes/Collection.class.php
View file @
bafcd662
...
...
@@ -119,9 +119,9 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
foreach
(
$this
->
getNormalIterator
()
as
$record
)
{
if
(
$value
!==
null
)
{
$record
->
s
et
(
$this
->
reference_field
,
$value
);
$record
->
rawS
et
(
$this
->
reference_field
,
$value
);
}
else
{
$record
->
s
et
(
$this
->
reference_field
,
$this
->
reference
);
$record
->
rawS
et
(
$this
->
reference_field
,
$this
->
reference
);
}
}
}
...
...
@@ -284,9 +284,9 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$value
=
$this
->
reference
->
get
(
$this
->
relation
->
getLocal
());
if
(
$value
!==
null
)
{
$this
->
data
[
$key
]
->
s
et
(
$this
->
reference_field
,
$value
);
$this
->
data
[
$key
]
->
rawS
et
(
$this
->
reference_field
,
$value
);
}
else
{
$this
->
data
[
$key
]
->
s
et
(
$this
->
reference_field
,
$this
->
reference
);
$this
->
data
[
$key
]
->
rawS
et
(
$this
->
reference_field
,
$this
->
reference
);
}
}
}
...
...
classes/Collection/Batch.class.php
View file @
bafcd662
...
...
@@ -142,7 +142,7 @@ class Doctrine_Collection_Batch extends Doctrine_Collection {
if
(
isset
(
$this
->
reference_field
))
$this
->
data
[
$key
]
->
s
et
(
$this
->
reference_field
,
$this
->
reference
);
$this
->
data
[
$key
]
->
rawS
et
(
$this
->
reference_field
,
$this
->
reference
);
return
$this
->
data
[
$key
];
...
...
classes/DQL/Parser.class.php
View file @
bafcd662
...
...
@@ -829,3 +829,5 @@ class Doctrine_DQL_Parser {
}
?>
classes/Record.class.php
View file @
bafcd662
...
...
@@ -87,10 +87,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @var integer $oid object identifier
*/
private
$oid
;
/**
* @var boolean $loaded whether or not this object has its data loaded from database
*/
private
$loaded
=
false
;
/**
* constructor
...
...
@@ -149,8 +145,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
$cols
<=
1
)
$this
->
state
=
Doctrine_Record
::
STATE_PROXY
;
else
$this
->
loaded
=
true
;
$this
->
prepareIdentifiers
();
...
...
@@ -177,14 +171,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
public
function
getOID
()
{
return
$this
->
oid
;
}
/**
* isLoaded
* whether or not this object has been fully loaded
* @return boolean
*/
public
function
isLoaded
()
{
return
$this
->
loaded
;
}
/**
* cleanData
* modifies data array
...
...
@@ -245,7 +231,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
unset
(
$this
->
references
);
unset
(
$this
->
originals
);
unset
(
$this
->
oid
);
unset
(
$this
->
loaded
);
foreach
(
$this
->
data
as
$k
=>
$v
)
{
if
(
$v
instanceof
Doctrine_Record
)
...
...
@@ -273,8 +258,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
table
->
getRepository
()
->
add
(
$this
);
$this
->
loaded
=
true
;
$this
->
cleanData
();
//unset($this->data['id']);
...
...
@@ -335,7 +318,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
prepareIdentifiers
();
$this
->
loaded
=
true
;
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
return
true
;
...
...
@@ -360,7 +342,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
$this
->
modified
=
array
();
$this
->
loaded
=
true
;
}
/**
* return the factory that created this data access object
...
...
@@ -390,12 +371,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
// check if the property is not loaded (= it is an empty array)
if
(
is_array
(
$this
->
data
[
$name
]))
{
if
(
!
$this
->
loaded
)
{
// no use trying to load the data from database if the Doctrine_Record is new or clean
// no use trying to load the data from database if the Doctrine_Record is not a proxy
if
(
$this
->
state
!=
Doctrine_Record
::
STATE_TDIRTY
&&
$this
->
state
!=
Doctrine_Record
::
STATE_TCLEAN
&&
$this
->
state
!=
Doctrine_Record
::
STATE_CLEAN
)
{
$this
->
state
!=
Doctrine_Record
::
STATE_CLEAN
&&
$this
->
state
!=
Doctrine_Record
::
STATE_DIRTY
)
{
if
(
!
empty
(
$this
->
collections
))
{
foreach
(
$this
->
collections
as
$collection
)
{
...
...
@@ -406,12 +386,9 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
$this
->
state
=
Doctrine_Record
::
STATE_CLEAN
;
}
$this
->
loaded
=
true
;
}
if
(
is_array
(
$this
->
data
[
$name
]))
return
null
;
}
return
$this
->
data
[
$name
];
}
...
...
@@ -438,7 +415,21 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
if
(
!
empty
(
$id
))
$value
=
$id
;
if
(
isset
(
$this
->
data
[
$name
]))
{
if
(
!
is_array
(
$this
->
data
[
$name
]))
{
if
(
$this
->
data
[
$name
]
!==
$value
)
{
switch
(
$this
->
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
$this
->
state
=
Doctrine_Record
::
STATE_DIRTY
;
break
;
case
Doctrine_Record
::
STATE_TCLEAN
:
$this
->
state
=
Doctrine_Record
::
STATE_TDIRTY
;
endswitch
;
}
}
$this
->
data
[
$name
]
=
$value
;
$this
->
modified
[]
=
$name
;
}
}
/**
* set
...
...
@@ -452,8 +443,6 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
*/
public
function
set
(
$name
,
$value
)
{
if
(
isset
(
$this
->
data
[
$name
]))
{
$old
=
$this
->
get
(
$name
);
if
(
$value
instanceof
Doctrine_Record
)
{
$id
=
$value
->
getID
();
...
...
@@ -462,12 +451,11 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
$value
=
$value
->
getID
();
}
$old
=
$this
->
get
(
$name
);
if
(
$old
!==
$value
)
{
$this
->
data
[
$name
]
=
$value
;
$this
->
modified
[]
=
$name
;
switch
(
$this
->
state
)
:
case
Doctrine_Record
::
STATE_CLEAN
:
case
Doctrine_Record
::
STATE_PROXY
:
...
...
tests/DQLParserTestCase.class.php
View file @
bafcd662
...
...
@@ -207,3 +207,5 @@ class Doctrine_DQL_ParserTestCase extends Doctrine_UnitTestCase {
}
?>
tests/RecordTestCase.class.php
View file @
bafcd662
...
...
@@ -2,6 +2,43 @@
require_once
(
"UnitTestCase.class.php"
);
class
Doctrine_RecordTestCase
extends
Doctrine_UnitTestCase
{
public
function
testManyToManyTreeStructure
()
{
$task
=
$this
->
session
->
create
(
"Task"
);
$task
->
name
=
"Task 1"
;
$task
->
Resource
[
0
]
->
name
=
"Resource 1"
;
$this
->
session
->
flush
();
$this
->
assertEqual
(
$this
->
dbh
->
query
(
"SELECT COUNT(*) FROM assignment"
)
->
fetch
(
PDO
::
FETCH_NUM
),
array
(
1
));
$task
=
new
Task
();
$this
->
assertTrue
(
$task
instanceof
Task
);
$this
->
assertEqual
(
$task
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertTrue
(
$task
->
Task
[
0
]
instanceof
Task
);
$this
->
assertEqual
(
$task
->
Task
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertTrue
(
$task
->
Resource
[
0
]
instanceof
Resource
);
$this
->
assertEqual
(
$task
->
Resource
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_TCLEAN
);
$task
->
name
=
"Task 1"
;
$task
->
Resource
[
0
]
->
name
=
"Resource 1"
;
$task
->
Task
[
0
]
->
name
=
"Subtask 1"
;
$this
->
assertEqual
(
$task
->
name
,
"Task 1"
);
$this
->
assertEqual
(
$task
->
Resource
[
0
]
->
name
,
"Resource 1"
);
$this
->
assertEqual
(
$task
->
Resource
->
count
(),
1
);
$this
->
assertEqual
(
$task
->
Task
[
0
]
->
name
,
"Subtask 1"
);
$this
->
session
->
flush
();
$task
=
$task
->
getTable
()
->
find
(
$task
->
getID
());
$this
->
assertEqual
(
$task
->
name
,
"Task 1"
);
$this
->
assertEqual
(
$task
->
Resource
[
0
]
->
name
,
"Resource 1"
);
$this
->
assertEqual
(
$task
->
Resource
->
count
(),
1
);
$this
->
assertEqual
(
$task
->
Task
[
0
]
->
name
,
"Subtask 1"
);
}
public
function
testOne2OneForeign
()
{
...
...
tests/UnitTestCase.class.php
View file @
bafcd662
...
...
@@ -32,7 +32,7 @@ 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"
,
"email"
,
"phonenumber"
,
"groupuser"
,
"album"
,
"song"
,
"element"
,
"error"
,
"description"
,
"address"
,
"account"
);
$this
->
tables
=
array
(
"entity"
,
"email"
,
"phonenumber"
,
"groupuser"
,
"album"
,
"song"
,
"element"
,
"error"
,
"description"
,
"address"
,
"account"
,
"task"
,
"resource"
,
"assignment"
);
$tables
=
$this
->
tables
;
...
...
tests/ValidatorTestCase.class.php
View file @
bafcd662
...
...
@@ -10,7 +10,6 @@ class Doctrine_ValidatorTestCase extends Doctrine_UnitTestCase {
$email
=
$this
->
old
->
Email
;
$email
->
address
=
"zYne@invalid"
;
$this
->
assertTrue
(
$this
->
old
->
isLoaded
());
$this
->
assertTrue
(
$this
->
old
->
getModified
()
==
$set
);
$validator
=
new
Doctrine_Validator
();
...
...
tests/classes.php
View file @
bafcd662
...
...
@@ -124,4 +124,31 @@ class Song extends Doctrine_Record {
$this
->
hasColumn
(
"title"
,
"string"
,
30
);
}
}
class
Task
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
hasMany
(
"Resource"
,
"Assignment.resource_id"
);
$this
->
hasMany
(
"Task"
,
"Task.parent_id"
);
}
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"name"
,
"string"
,
100
);
$this
->
hasColumn
(
"parent_id"
,
"integer"
);
}
}
class
Resource
extends
Doctrine_Record
{
public
function
setUp
()
{
$this
->
hasMany
(
"Task"
,
"Assignment.task_id"
);
}
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"name"
,
"string"
,
100
);
}
}
class
Assignment
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
"task_id"
,
"integer"
);
$this
->
hasColumn
(
"resource_id"
,
"integer"
);
}
}
?>
tests/run.php
View file @
bafcd662
...
...
@@ -24,13 +24,17 @@ error_reporting(E_ALL);
$test
=
new
GroupTest
(
"Doctrine Framework Unit Tests"
);
$test
->
addTestCase
(
new
Doctrine_TableTestCase
());
$test
->
addTestCase
(
new
Doctrine_SessionTestCase
());
$test
->
addTestCase
(
new
Doctrine_RecordTestCase
());
$test
->
addTestCase
(
new
Doctrine_TableTestCase
());
$test
->
addTestCase
(
new
Doctrine_SessionTestCase
());
$test
->
addTestCase
(
new
Doctrine_DQL_ParserTestCase
());
$test
->
addTestCase
(
new
Doctrine_ValidatorTestCase
());
$test
->
addTestCase
(
new
Doctrine_ManagerTestCase
());
...
...
@@ -44,7 +48,7 @@ $test->addTestCase(new Doctrine_EventListenerTestCase());
$test
->
addTestCase
(
new
Doctrine_BatchIteratorTestCase
());
$test
->
addTestCase
(
new
Doctrine_DQL_ParserTestCase
());
$test
->
addTestCase
(
new
Doctrine_ConfigurableTestCase
());
...
...
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