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
1eb8b54d
Commit
1eb8b54d
authored
Jan 21, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
lots of refactorings
parent
b4bf33fc
Changes
21
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
440 additions
and
382 deletions
+440
-382
Collection.php
lib/Doctrine/Collection.php
+4
-4
Connection.php
lib/Doctrine/Connection.php
+1
-1
UnitOfWork.php
lib/Doctrine/Connection/UnitOfWork.php
+2
-2
Sqlite.php
lib/Doctrine/Export/Sqlite.php
+1
-1
Record.php
lib/Doctrine/Record.php
+43
-2
Table.php
lib/Doctrine/Table.php
+73
-52
NestedSet.php
lib/Doctrine/Tree/NestedSet.php
+4
-4
BooleanTestCase.php
tests/BooleanTestCase.php
+3
-3
CollectionTestCase.php
tests/CollectionTestCase.php
+15
-15
ConnectionTestCase.php
tests/ConnectionTestCase.php
+1
-1
ProfilerTestCase.php
tests/Db/ProfilerTestCase.php
+12
-12
ChainTestCase.php
tests/EventListener/ChainTestCase.php
+2
-2
EventListenerChainTestCase.php
tests/EventListenerChainTestCase.php
+1
-1
EventListenerTestCase.php
tests/EventListenerTestCase.php
+1
-1
QueryTestCase.php
tests/QueryTestCase.php
+21
-21
RawSqlTestCase.php
tests/RawSqlTestCase.php
+4
-4
RecordTestCase.php
tests/RecordTestCase.php
+36
-36
TableTestCase.php
tests/TableTestCase.php
+1
-1
ValidatorTestCase.php
tests/ValidatorTestCase.php
+18
-18
ViewTestCase.php
tests/ViewTestCase.php
+1
-1
classes.php
tests/classes.php
+196
-200
No files found.
lib/Doctrine/Collection.php
View file @
1eb8b54d
...
...
@@ -660,8 +660,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
}
}
elseif
(
$rel
instanceof
Doctrine_Relation_ForeignKey
)
{
foreach
(
$this
->
data
as
$key
=>
$record
)
{
if
(
$record
->
getS
tate
()
==
Doctrine_Record
::
STATE_TCLEAN
||
$record
->
getS
tate
()
==
Doctrine_Record
::
STATE_TDIRTY
if
(
$record
->
s
tate
()
==
Doctrine_Record
::
STATE_TCLEAN
||
$record
->
s
tate
()
==
Doctrine_Record
::
STATE_TDIRTY
)
{
continue
;
}
...
...
@@ -682,8 +682,8 @@ class Doctrine_Collection extends Doctrine_Access implements Countable, Iterator
$name
=
$table
->
getComponentName
();
foreach
(
$this
->
data
as
$key
=>
$record
)
{
if
(
$record
->
getS
tate
()
==
Doctrine_Record
::
STATE_TCLEAN
||
$record
->
getS
tate
()
==
Doctrine_Record
::
STATE_TDIRTY
if
(
$record
->
s
tate
()
==
Doctrine_Record
::
STATE_TCLEAN
||
$record
->
s
tate
()
==
Doctrine_Record
::
STATE_TDIRTY
)
{
continue
;
}
...
...
lib/Doctrine/Connection.php
View file @
1eb8b54d
...
...
@@ -886,7 +886,7 @@ abstract class Doctrine_Connection extends Doctrine_Configurable implements Coun
{
$record
->
getTable
()
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onPreSave
(
$record
);
switch
(
$record
->
getS
tate
())
{
switch
(
$record
->
s
tate
())
{
case
Doctrine_Record
::
STATE_TDIRTY
:
$this
->
unitOfWork
->
insert
(
$record
);
break
;
...
...
lib/Doctrine/Connection/UnitOfWork.php
View file @
1eb8b54d
...
...
@@ -157,7 +157,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
// ONE-TO-ONE relationship
$obj
=
$record
->
get
(
$fk
->
getAlias
());
if
(
$obj
->
getS
tate
()
!=
Doctrine_Record
::
STATE_TCLEAN
)
{
if
(
$obj
->
s
tate
()
!=
Doctrine_Record
::
STATE_TCLEAN
)
{
$obj
->
save
();
}
}
...
...
@@ -261,7 +261,7 @@ class Doctrine_Connection_UnitOfWork extends Doctrine_Connection_Module implemen
$set
[]
=
$name
.
" = ?"
;
if
(
$value
instanceof
Doctrine_Record
)
{
switch
(
$value
->
getS
tate
())
{
switch
(
$value
->
s
tate
())
{
case
Doctrine_Record
::
STATE_TCLEAN
:
case
Doctrine_Record
::
STATE_TDIRTY
:
$record
->
save
();
...
...
lib/Doctrine/Export/Sqlite.php
View file @
1eb8b54d
...
...
@@ -157,7 +157,7 @@ class Doctrine_Export_Sqlite extends Doctrine_Export
$sequenceName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getSequenceName
(
$seqName
),
true
);
$seqcolName
=
$this
->
conn
->
quoteIdentifier
(
$this
->
conn
->
getAttribute
(
Doctrine
::
ATTR_SEQCOL_NAME
),
true
);
$query
=
'CREATE TABLE '
.
$sequenceName
.
' ('
.
$seqcolName
.
' INTEGER PRIMARY KEY DEFAULT 0 NOT NULL)'
;
$this
->
conn
->
exec
(
$query
);
if
(
$start
==
1
)
{
...
...
lib/Doctrine/Record.php
View file @
1eb8b54d
...
...
@@ -186,7 +186,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
}
// set the default values for this record
$this
->
set
DefaultValues
();
$this
->
assign
DefaultValues
();
// listen the onCreate event
$this
->
_table
->
getAttribute
(
Doctrine
::
ATTR_LISTENER
)
->
onCreate
(
$this
);
...
...
@@ -309,6 +309,24 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{
return
$this
->
_errorStack
;
}
/**
* errorStack
* assigns / returns record errorStack
*
* @param Doctrine_Validator_ErrorStack errorStack to be assigned for this record
* @return void|Doctrine_Validator_ErrorStack returns the errorStack associated with this record
*/
public
function
errorStack
(
$stack
=
null
)
{
if
(
$stack
!==
null
)
{
if
(
!
(
$stack
instanceof
Doctrine_Validator_ErrorStack
))
{
throw
new
Doctrine_Record_Exception
(
'Argument should be an instance of Doctrine_Validator_ErrorStack.'
);
}
$this
->
_errorStack
=
$stack
;
}
else
{
return
$this
->
_errorStack
;
}
}
/**
* setDefaultValues
* sets the default values for records internal data
...
...
@@ -316,7 +334,7 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @param boolean $overwrite whether or not to overwrite the already set values
* @return boolean
*/
public
function
set
DefaultValues
(
$overwrite
=
false
)
public
function
assign
DefaultValues
(
$overwrite
=
false
)
{
if
(
!
$this
->
_table
->
hasDefaultValues
())
{
return
false
;
...
...
@@ -1462,6 +1480,29 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
{
$this
->
_table
->
setEnumValues
(
$column
,
$values
);
}
/**
* attribute
* sets or retrieves an option
*
* @see Doctrine::ATTR_* constants availible attributes
* @param mixed $attr
* @param mixed $value
* @return mixed
*/
public
function
attribute
(
$attr
,
$value
)
{
if
(
$value
==
null
)
{
if
(
is_array
(
$attr
))
{
foreach
(
$attr
as
$k
=>
$v
)
{
$this
->
_table
->
setAttribute
(
$k
,
$v
);
}
}
else
{
return
$this
->
_table
->
getAttribute
(
$attr
);
}
}
else
{
$this
->
_table
->
setAttribute
(
$attr
,
$value
);
}
}
/**
* option
* sets or retrieves an option
...
...
lib/Doctrine/Table.php
View file @
1eb8b54d
...
...
@@ -260,7 +260,16 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
}
}
};
/**
if ( ! isset($definition['values'])) {
throw new Doctrine_Table_Exception('No values set for enum column ' . $name);
}
if ( ! is_array($definition['values'])) {
throw new Doctrine_Table_Exception('Enum column values should be specified as an array.');
}
*/
if
(
$this
->
getAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
))
{
$this
->
export
();
}
...
...
@@ -276,7 +285,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
array_pop
(
$names
);
$this
->
parents
=
$names
;
$this
->
query
=
"SELECT "
.
implode
(
", "
,
array_keys
(
$this
->
columns
))
.
" FROM "
.
$this
->
getTableName
();
$this
->
query
=
'SELECT '
.
implode
(
', '
,
array_keys
(
$this
->
columns
))
.
' FROM '
.
$this
->
getTableName
();
// check if an instance of this table is already initialized
if
(
!
$this
->
conn
->
addTable
(
$this
))
{
...
...
@@ -294,35 +303,44 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* false if table already existed in the database
*/
public
function
export
()
{
if
(
Doctrine
::
isValidClassname
(
$this
->
options
[
'declaringClass'
]
->
getName
()))
{
try
{
$columns
=
array
();
$primary
=
array
();
foreach
(
$this
->
columns
as
$name
=>
$column
)
{
$definition
=
$column
[
2
];
$definition
[
'type'
]
=
$column
[
0
];
$definition
[
'length'
]
=
$column
[
1
];
if
(
$definition
[
'type'
]
==
'enum'
&&
isset
(
$definition
[
'default'
]))
{
$definition
[
'default'
]
=
$this
->
enumIndex
(
$name
,
$definition
[
'default'
]);
}
if
(
$definition
[
'type'
]
==
'boolean'
&&
isset
(
$definition
[
'default'
]))
{
$definition
[
'default'
]
=
(
int
)
$definition
[
'default'
];
}
$columns
[
$name
]
=
$definition
;
if
(
isset
(
$definition
[
'primary'
])
&&
$definition
[
'primary'
])
{
$primary
[]
=
$name
;
}
}
$options
[
'primary'
]
=
$primary
;
if
(
!
Doctrine
::
isValidClassname
(
$this
->
options
[
'declaringClass'
]
->
getName
()))
{
throw
new
Doctrine_Table_Exception
(
'Class name not valid.'
);
}
$this
->
conn
->
export
->
createTable
(
$this
->
options
[
'tableName'
],
$columns
,
array_merge
(
$this
->
options
,
$options
));
}
catch
(
Doctrine_Connection_Exception
$e
)
{
// we only want to silence table already exists errors
if
(
$e
->
getPortableCode
()
!==
Doctrine
::
ERR_ALREADY_EXISTS
)
{
throw
$e
;
try
{
$columns
=
array
();
$primary
=
array
();
foreach
(
$this
->
columns
as
$name
=>
$column
)
{
$definition
=
$column
[
2
];
$definition
[
'type'
]
=
$column
[
0
];
$definition
[
'length'
]
=
$column
[
1
];
switch
(
$definition
[
'type'
])
{
case
'enum'
:
if
(
isset
(
$definition
[
'default'
]))
{
$definition
[
'default'
]
=
$this
->
enumIndex
(
$name
,
$definition
[
'default'
]);
}
break
;
case
'boolean'
:
if
(
isset
(
$definition
[
'default'
]))
{
$definition
[
'default'
]
=
(
int
)
$definition
[
'default'
];
}
break
;
}
$columns
[
$name
]
=
$definition
;
if
(
isset
(
$definition
[
'primary'
])
&&
$definition
[
'primary'
])
{
$primary
[]
=
$name
;
}
}
$options
[
'primary'
]
=
$primary
;
$this
->
conn
->
export
->
createTable
(
$this
->
options
[
'tableName'
],
$columns
,
array_merge
(
$this
->
options
,
$options
));
}
catch
(
Doctrine_Connection_Exception
$e
)
{
// we only want to silence table already exists errors
if
(
$e
->
getPortableCode
()
!==
Doctrine
::
ERR_ALREADY_EXISTS
)
{
throw
$e
;
}
}
}
...
...
@@ -902,12 +920,12 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
$id
=
array_values
(
$id
);
}
$query
=
$this
->
query
.
" WHERE "
.
implode
(
" = ? AND "
,
$this
->
primaryKeys
)
.
" = ?"
;
$query
=
$this
->
query
.
' WHERE '
.
implode
(
' = ? AND '
,
$this
->
primaryKeys
)
.
' = ?'
;
$query
=
$this
->
applyInheritance
(
$query
);
$params
=
array_merge
(
$id
,
array_values
(
$this
->
options
[
'inheritanceMap'
]));
$stmt
=
$this
->
conn
->
execute
(
$query
,
$params
);
$stmt
=
$this
->
conn
->
execute
(
$query
,
$params
);
$this
->
data
=
$stmt
->
fetch
(
PDO
::
FETCH_ASSOC
);
...
...
@@ -928,10 +946,10 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
if
(
!
empty
(
$this
->
options
[
'inheritanceMap'
]))
{
$a
=
array
();
foreach
(
$this
->
options
[
'inheritanceMap'
]
as
$field
=>
$value
)
{
$a
[]
=
$field
.
" = ?"
;
$a
[]
=
$field
.
' = ?'
;
}
$i
=
implode
(
" AND "
,
$a
);
$where
.=
" AND
$i
"
;
$i
=
implode
(
' AND '
,
$a
);
$where
.=
' AND '
.
$i
;
}
return
$where
;
}
...
...
@@ -1017,7 +1035,9 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
final
public
function
getProxy
(
$id
=
null
)
{
if
(
$id
!==
null
)
{
$query
=
"SELECT "
.
implode
(
", "
,
$this
->
primaryKeys
)
.
" FROM "
.
$this
->
getTableName
()
.
" WHERE "
.
implode
(
" = ? && "
,
$this
->
primaryKeys
)
.
" = ?"
;
$query
=
'SELECT '
.
implode
(
', '
,
$this
->
primaryKeys
)
.
' FROM '
.
$this
->
getTableName
()
.
' WHERE '
.
implode
(
' = ? && '
,
$this
->
primaryKeys
)
.
' = ?'
;
$query
=
$this
->
applyInheritance
(
$query
);
$params
=
array_merge
(
array
(
$id
),
array_values
(
$this
->
options
[
'inheritanceMap'
]));
...
...
@@ -1104,12 +1124,29 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
* @param integer $index
* @return mixed
*/
final
public
function
enumValue
(
$field
,
$index
)
public
function
enumValue
(
$field
,
$index
)
{
if
(
$index
instanceof
Doctrine_Null
)
return
$index
;
return
isset
(
$this
->
options
[
'enumMap'
][
$field
][
$index
])
?
$this
->
options
[
'enumMap'
][
$field
][
$index
]
:
$index
;
return
isset
(
$this
->
columns
[
$field
][
2
][
'values'
][
$index
])
?
$this
->
columns
[
$field
][
2
][
'values'
][
$index
]
:
$index
;
}
/**
* enumIndex
*
* @param string $field
* @param mixed $value
* @return mixed
*/
public
function
enumIndex
(
$field
,
$value
)
{
if
(
!
isset
(
$this
->
columns
[
$field
][
2
][
'values'
]))
{
$values
=
array
();
}
else
{
$values
=
$this
->
columns
[
$field
][
2
][
'values'
];
}
return
array_search
(
$value
,
$values
);
}
/**
* invokeSet
...
...
@@ -1155,23 +1192,7 @@ class Doctrine_Table extends Doctrine_Configurable implements Countable
return
$value
;
}
/**
* enumIndex
*
* @param string $field
* @param mixed $value
* @return mixed
*/
final
public
function
enumIndex
(
$field
,
$value
)
{
if
(
!
isset
(
$this
->
options
[
'enumMap'
][
$field
]))
{
$values
=
array
();
}
else
{
$values
=
$this
->
options
[
'enumMap'
][
$field
];
}
return
array_search
(
$value
,
$values
);
}
/**
* getDefinitionOf
*
...
...
lib/Doctrine/Tree/NestedSet.php
View file @
1eb8b54d
...
...
@@ -53,7 +53,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
*/
public
function
setTableDefinition
()
{
if
(
$root
=
$this
->
getAttribute
(
'root
_column_n
ame'
))
{
if
(
$root
=
$this
->
getAttribute
(
'root
ColumnN
ame'
))
{
$this
->
table
->
setColumn
(
$root
,
'integer'
,
11
);
}
...
...
@@ -207,7 +207,7 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
public
function
getMaxRootId
()
{
$component
=
$this
->
table
->
getComponentName
();
$column
=
$this
->
getAttribute
(
'root
_column_n
ame'
);
$column
=
$this
->
getAttribute
(
'root
ColumnN
ame'
);
// cannot get this dql to work, cannot retrieve result using $coll[0]->max
//$dql = "SELECT MAX(c.$column) FROM $component c";
...
...
@@ -229,10 +229,10 @@ class Doctrine_Tree_NestedSet extends Doctrine_Tree implements Doctrine_Tree_Int
* @param object $query Doctrine_Query
* @param integer $root_id id of destination root
* @return object Doctrine_Query
*/
*/
public
function
returnQueryWithRootId
(
$query
,
$rootId
=
1
)
{
if
(
$root
=
$this
->
getAttribute
(
'root
_column_n
ame'
))
{
if
(
$root
=
$this
->
getAttribute
(
'root
ColumnN
ame'
))
{
$query
->
addWhere
(
$root
.
' = ?'
,
$rootId
);
}
...
...
tests/BooleanTestCase.php
View file @
1eb8b54d
...
...
@@ -42,7 +42,7 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase {
$test
->
is_working
=
false
;
$this
->
assertEqual
(
$test
->
is_working
,
false
);
$this
->
assertEqual
(
$test
->
getS
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$this
->
assertEqual
(
$test
->
s
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$test
->
save
();
$test
->
refresh
();
...
...
@@ -98,7 +98,7 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase {
$this
->
is_working
=
null
;
$this
->
assertEqual
(
$this
->
is_working
,
null
);
$this
->
assertEqual
(
$test
->
getS
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$this
->
assertEqual
(
$test
->
s
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$test
->
save
();
$test
->
refresh
();
...
...
@@ -108,7 +108,7 @@ class Doctrine_Boolean_TestCase extends Doctrine_UnitTestCase {
$this
->
is_working_notnull
=
null
;
$this
->
assertEqual
(
$this
->
is_working_notnull
,
false
);
$this
->
assertEqual
(
$test
->
getS
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$this
->
assertEqual
(
$test
->
s
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$test
->
save
();
$test
->
refresh
();
...
...
tests/CollectionTestCase.php
View file @
1eb8b54d
...
...
@@ -240,7 +240,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
count
(
$coll
),
3
);
$this
->
assertEqual
(
$coll
[
2
]
->
getS
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
2
]
->
s
tate
(),
Doctrine_Record
::
STATE_PROXY
);
...
...
@@ -268,33 +268,33 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase {
}
public
function
testFetchCollectionWithIdAsIndex
()
{
$user
=
new
User
();
$user
->
setA
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
$user
->
a
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
$users
=
$user
->
getTable
()
->
findAll
();
$this
->
assertFalse
(
$users
->
contains
(
0
));
$this
->
assertEqual
(
$users
->
count
(),
8
);
$this
->
assertEqual
(
$users
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
4
]
->
getS
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
4
]
->
s
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
}
public
function
testFetchCollectionWithNameAsIndex
()
{
$user
=
new
User
();
$user
->
setA
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'name'
);
$user
->
a
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'name'
);
$users
=
$user
->
getTable
()
->
findAll
();
$this
->
assertFalse
(
$users
->
contains
(
0
));
$this
->
assertEqual
(
$users
->
count
(),
8
);
$this
->
assertEqual
(
$users
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
'zYne'
]
->
getS
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
'zYne'
]
->
s
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
}
public
function
testFetchMultipleCollections
()
{
$this
->
connection
->
clear
();
$user
=
new
User
();
$user
->
setA
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
$user
->
a
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
$phonenumber
=
new
Phonenumber
();
$phonenumber
->
setA
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
$phonenumber
->
a
ttribute
(
Doctrine
::
ATTR_COLL_KEY
,
'id'
);
$q
=
new
Doctrine_Query
();
...
...
@@ -302,16 +302,16 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase {
$this
->
assertFalse
(
$users
->
contains
(
0
));
$this
->
assertEqual
(
$users
->
count
(),
8
);
$this
->
assertEqual
(
$users
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
2
]
->
getS
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
3
]
->
getS
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
4
]
->
getS
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
2
]
->
s
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
3
]
->
s
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$users
[
4
]
->
s
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
4
]
->
name
,
'zYne'
);
$this
->
assertEqual
(
$users
[
4
]
->
Phonenumber
[
0
]
->
exists
(),
false
);
$this
->
assertEqual
(
$users
[
4
]
->
Phonenumber
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$this
->
assertEqual
(
$users
[
4
]
->
Phonenumber
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_TDIRTY
);
$this
->
assertEqual
(
$users
[
4
]
->
Phonenumber
[
1
]
->
exists
(),
false
);
$this
->
assertEqual
(
$users
[
4
]
->
Phonenumber
[
2
]
->
getS
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
4
]
->
Phonenumber
[
2
]
->
s
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
}
}
...
...
tests/ConnectionTestCase.php
View file @
1eb8b54d
...
...
@@ -135,7 +135,7 @@ class Doctrine_Connection_TestCase extends Doctrine_UnitTestCase {
public
function
testDelete
()
{
$user
=
$this
->
connection
->
create
(
'User'
);
$this
->
connection
->
delete
(
$user
);
$this
->
assertEqual
(
$user
->
getS
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertEqual
(
$user
->
s
tate
(),
Doctrine_Record
::
STATE_TCLEAN
);
}
public
function
testGetTable
()
{
$table
=
$this
->
connection
->
getTable
(
'Group'
);
...
...
tests/Db/ProfilerTestCase.php
View file @
1eb8b54d
...
...
@@ -17,7 +17,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'CREATE TABLE test (id INT)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
QUERY
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
QUERY
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
dbh
->
count
(),
1
);
...
...
@@ -29,14 +29,14 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$event
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
PREPARE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
PREPARE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$stmt
->
execute
(
array
(
1
));
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
dbh
->
count
(),
2
);
...
...
@@ -46,13 +46,13 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
$stmt
=
$this
->
dbh
->
prepare
(
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
PREPARE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
PREPARE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$stmt2
=
$this
->
dbh
->
prepare
(
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
PREPARE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
PREPARE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$stmt
->
execute
(
array
(
1
));
...
...
@@ -60,7 +60,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
dbh
->
count
(),
4
);
...
...
@@ -77,12 +77,12 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
}
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
'INSERT INTO test (id) VALUES (?)'
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
EXECUTE
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
}
public
function
testTransactionRollback
()
{
...
...
@@ -94,7 +94,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
}
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
BEGIN
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
BEGIN
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
try
{
...
...
@@ -106,7 +106,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
ROLLBACK
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
ROLLBACK
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
}
public
function
testTransactionCommit
()
{
...
...
@@ -118,7 +118,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
}
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
BEGIN
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
BEGIN
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
try
{
...
...
@@ -131,7 +131,7 @@ class Doctrine_Db_Profiler_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
getQuery
(),
null
);
$this
->
assertTrue
(
$this
->
profiler
->
lastEvent
()
->
hasEnded
());
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Typ
e
(),
Doctrine_Db_Event
::
COMMIT
);
$this
->
assertEqual
(
$this
->
profiler
->
lastEvent
()
->
get
Cod
e
(),
Doctrine_Db_Event
::
COMMIT
);
$this
->
assertTrue
(
is_numeric
(
$this
->
profiler
->
lastEvent
()
->
getElapsedSecs
()));
}
}
...
...
tests/EventListener/ChainTestCase.php
View file @
1eb8b54d
...
...
@@ -29,7 +29,7 @@
* @link www.phpdoctrine.com
* @since 1.0
* @version $Revision$
*/
*/
class
Doctrine_EventListener_Chain_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testAccessorInvokerChain
()
{
...
...
@@ -79,7 +79,7 @@ class EventListenerChainTest extends Doctrine_Record {
$chain
=
new
Doctrine_EventListener_Chain
();
$chain
->
add
(
new
Doctrine_EventListener_TestA
());
$chain
->
add
(
new
Doctrine_EventListener_TestB
());
$this
->
setA
ttribute
(
Doctrine
::
ATTR_LISTENER
,
$chain
);
$this
->
a
ttribute
(
Doctrine
::
ATTR_LISTENER
,
$chain
);
}
}
...
...
tests/EventListenerChainTestCase.php
View file @
1eb8b54d
...
...
@@ -38,7 +38,7 @@ class EventListenerChainTest extends Doctrine_Record {
$chain
=
new
Doctrine_EventListener_Chain
();
$chain
->
add
(
new
Doctrine_EventListener_TestA
());
$chain
->
add
(
new
Doctrine_EventListener_TestB
());
$this
->
setA
ttribute
(
Doctrine
::
ATTR_LISTENER
,
$chain
);
$this
->
a
ttribute
(
Doctrine
::
ATTR_LISTENER
,
$chain
);
}
}
...
...
tests/EventListenerTestCase.php
View file @
1eb8b54d
...
...
@@ -36,7 +36,7 @@ class EventListenerTest extends Doctrine_Record {
$this
->
hasColumn
(
"password"
,
"string"
,
8
);
}
public
function
setUp
()
{
$this
->
setA
ttribute
(
Doctrine
::
ATTR_LISTENER
,
new
Doctrine_EventListener_AccessorInvoker
());
$this
->
a
ttribute
(
Doctrine
::
ATTR_LISTENER
,
new
Doctrine_EventListener_AccessorInvoker
());
}
public
function
getName
(
$name
)
{
return
strtoupper
(
$name
);
...
...
tests/QueryTestCase.php
View file @
1eb8b54d
...
...
@@ -524,14 +524,14 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$query
->
from
(
"Task-l:ResourceAlias-l"
);
$tasks
=
$query
->
execute
();
$this
->
assertEqual
(
$tasks
->
count
(),
3
);
$this
->
assertTrue
(
$tasks
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
0
]
->
ResourceAlias
->
count
(),
2
);
$this
->
assertTrue
(
$tasks
[
0
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
0
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
// sanity checking
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
[
1
]
->
getState
(),
Doctrine_Record
::
STATE_PROXY
);
...
...
@@ -548,7 +548,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
count
(
$this
->
dbh
),
(
$count
+
4
));
$this
->
assertEqual
(
$tasks
[
2
]
->
ResourceAlias
->
count
(),
1
);
$this
->
assertTrue
(
$tasks
[
2
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
2
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
}
public
function
testManyToManyFetchingWithDotOperator
()
{
...
...
@@ -560,16 +560,16 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$tasks
=
$query
->
query
(
"FROM Task-l.ResourceAlias-l"
);
$this
->
assertEqual
(
$tasks
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
0
]
->
ResourceAlias
->
count
(),
2
);
$this
->
assertTrue
(
$tasks
[
0
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
0
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
// sanity checking
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
[
1
]
->
getState
(),
Doctrine_Record
::
STATE_PROXY
);
...
...
@@ -586,7 +586,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
count
(
$this
->
dbh
),
(
$count
+
4
));
$this
->
assertEqual
(
$tasks
[
2
]
->
ResourceAlias
->
count
(),
1
);
$this
->
assertTrue
(
$tasks
[
2
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
2
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
3
]
->
ResourceAlias
->
count
(),
0
);
$this
->
assertTrue
(
$tasks
[
3
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
...
...
@@ -597,16 +597,16 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$tasks
=
$query
->
query
(
"FROM Task-l.ResourceAlias-l"
);
$this
->
assertEqual
(
$tasks
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
0
]
->
ResourceAlias
->
count
(),
2
);
$this
->
assertTrue
(
$tasks
[
0
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
0
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
->
count
(),
4
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
1
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
// sanity checking
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
[
0
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$tasks
[
1
]
->
ResourceAlias
[
1
]
->
getState
(),
Doctrine_Record
::
STATE_CLEAN
);
...
...
@@ -623,7 +623,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
count
(
$this
->
dbh
),
$count
);
$this
->
assertEqual
(
$tasks
[
2
]
->
ResourceAlias
->
count
(),
1
);
$this
->
assertTrue
(
$tasks
[
2
]
->
ResourceAlias
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$tasks
[
2
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$tasks
[
3
]
->
ResourceAlias
->
count
(),
0
);
$this
->
assertTrue
(
$tasks
[
3
]
->
ResourceAlias
instanceof
Doctrine_Collection
);
...
...
@@ -755,7 +755,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$q
->
from
(
"User-l(name, email_id)"
);
$users
=
$q
->
execute
();
$this
->
assertEqual
(
$users
->
count
(),
8
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$count
=
count
(
$this
->
dbh
);
$this
->
assertTrue
(
is_string
(
$users
[
0
]
->
name
));
$this
->
assertEqual
(
$count
,
count
(
$this
->
dbh
));
...
...
@@ -768,7 +768,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$q
->
from
(
"User-b(name, email_id)"
);
$users
=
$q
->
execute
();
$this
->
assertEqual
(
$users
->
count
(),
8
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
_Batch
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$count
=
count
(
$this
->
dbh
);
$this
->
assertTrue
(
is_string
(
$users
[
0
]
->
name
));
$this
->
assertEqual
(
$count
,
count
(
$this
->
dbh
));
...
...
@@ -830,7 +830,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$count
=
$this
->
dbh
->
count
();
$users
=
$this
->
query
->
from
(
"User-l:Email-i"
)
->
execute
();
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$count
=
$this
->
dbh
->
count
();
foreach
(
$users
as
$user
)
{
...
...
@@ -858,7 +858,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$count
=
$this
->
dbh
->
count
();
$users
=
$this
->
query
->
from
(
"User-l:Account-i"
)
->
execute
();
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$users
->
count
(),
1
);
$this
->
assertEqual
(
$users
[
0
]
->
Account
->
amount
,
3000
);
...
...
@@ -1003,7 +1003,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
$this
->
assertFalse
(
strpos
(
$query
->
getQuery
(),
"LIMIT"
));
$coll
=
$query
->
execute
();
$this
->
assertTrue
(
$coll
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$coll
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$coll
->
count
(),
1
);
...
...
@@ -1054,7 +1054,7 @@ class Doctrine_Query_TestCase extends Doctrine_UnitTestCase {
"SELECT e.id AS e__id FROM entity e WHERE (e.type = 0)"
);
$this
->
assertEqual
(
$users
[
0
]
->
name
,
"zYne"
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
_Lazy
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
}
...
...
tests/RawSqlTestCase.php
View file @
1eb8b54d
...
...
@@ -49,8 +49,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$coll
->
count
(),
11
);
$this
->
assertEqual
(
$coll
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
3
]
->
getS
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
3
]
->
s
tate
(),
Doctrine_Record
::
STATE_PROXY
);
}
public
function
testSmartMapping
()
{
...
...
@@ -66,8 +66,8 @@ class Doctrine_RawSql_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$coll
->
count
(),
11
);
$this
->
assertEqual
(
$coll
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
3
]
->
getS
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_PROXY
);
$this
->
assertEqual
(
$coll
[
3
]
->
s
tate
(),
Doctrine_Record
::
STATE_PROXY
);
}
public
function
testMultipleComponents
()
{
...
...
tests/RecordTestCase.php
View file @
1eb8b54d
This diff is collapsed.
Click to expand it.
tests/TableTestCase.php
View file @
1eb8b54d
...
...
@@ -135,7 +135,7 @@ class Doctrine_Table_TestCase extends Doctrine_UnitTestCase {
public
function
testCreate
()
{
$record
=
$this
->
objTable
->
create
();
$this
->
assertTrue
(
$record
instanceof
Doctrine_Record
);
$this
->
assertTrue
(
$record
->
getS
tate
()
==
Doctrine_Record
::
STATE_TCLEAN
);
$this
->
assertTrue
(
$record
->
s
tate
()
==
Doctrine_Record
::
STATE_TCLEAN
);
}
public
function
testFind
()
{
$record
=
$this
->
objTable
->
find
(
4
);
...
...
tests/ValidatorTestCase.php
View file @
1eb8b54d
...
...
@@ -119,7 +119,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$validator
=
new
Doctrine_Validator
();
$validator
->
validateRecord
(
$test
);
$stack
=
$test
->
getE
rrorStack
();
$stack
=
$test
->
e
rrorStack
();
$this
->
assertTrue
(
$stack
instanceof
Doctrine_Validator_ErrorStack
);
...
...
@@ -137,15 +137,15 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
* Tests Doctrine_Validator::validateRecord()
*/
public
function
testValidate
()
{
$user
=
$this
->
connection
->
getTable
(
"User"
)
->
find
(
4
);
$user
=
$this
->
connection
->
getTable
(
'User'
)
->
find
(
4
);
$set
=
array
(
"password"
=>
"this is an example of too long password"
,
"loginname"
=>
"this is an example of too long loginname"
,
"name"
=>
"valid name"
,
"created"
=>
"invalid"
);
$set
=
array
(
'password'
=>
'this is an example of too long password'
,
'loginname'
=>
'this is an example of too long loginname'
,
'name'
=>
'valid name'
,
'created'
=>
'invalid'
);
$user
->
setArray
(
$set
);
$email
=
$user
->
Email
;
$email
->
address
=
"zYne@invalid"
;
$email
->
address
=
'zYne@invalid'
;
$this
->
assertTrue
(
$user
->
getModified
()
==
$set
);
...
...
@@ -153,7 +153,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$validator
->
validateRecord
(
$user
);
$stack
=
$user
->
getE
rrorStack
();
$stack
=
$user
->
e
rrorStack
();
$this
->
assertTrue
(
$stack
instanceof
Doctrine_Validator_ErrorStack
);
$this
->
assertTrue
(
in_array
(
'length'
,
$stack
[
'loginname'
]));
...
...
@@ -161,12 +161,12 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
in_array
(
'type'
,
$stack
[
'created'
]));
$validator
->
validateRecord
(
$email
);
$stack
=
$email
->
getE
rrorStack
();
$stack
=
$email
->
e
rrorStack
();
$this
->
assertTrue
(
in_array
(
'email'
,
$stack
[
'address'
]));
$email
->
address
=
"arnold@example.com"
;
$email
->
address
=
'arnold@example.com'
;
$validator
->
validateRecord
(
$email
);
$stack
=
$email
->
getE
rrorStack
();
$stack
=
$email
->
e
rrorStack
();
$this
->
assertTrue
(
in_array
(
'unique'
,
$stack
[
'address'
]));
}
...
...
@@ -205,7 +205,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$e
->
count
(),
1
);
$invalidRecords
=
$e
->
getInvalidRecords
();
$this
->
assertEqual
(
count
(
$invalidRecords
),
1
);
$stack
=
$invalidRecords
[
0
]
->
getE
rrorStack
();
$stack
=
$invalidRecords
[
0
]
->
e
rrorStack
();
$this
->
assertTrue
(
in_array
(
'length'
,
$stack
[
'name'
]));
}
...
...
@@ -222,8 +222,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
is_array
(
$a
));
$emailStack
=
$a
[
array_search
(
$user
->
Email
,
$a
)]
->
getE
rrorStack
();
$userStack
=
$a
[
array_search
(
$user
,
$a
)]
->
getE
rrorStack
();
$emailStack
=
$a
[
array_search
(
$user
->
Email
,
$a
)]
->
e
rrorStack
();
$userStack
=
$a
[
array_search
(
$user
,
$a
)]
->
e
rrorStack
();
$this
->
assertTrue
(
in_array
(
'email'
,
$emailStack
[
'address'
]));
$this
->
assertTrue
(
in_array
(
'length'
,
$userStack
[
'name'
]));
...
...
@@ -247,8 +247,8 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$e
->
count
(),
1
);
$invalidRecords
=
$e
->
getInvalidRecords
();
$this
->
assertEqual
(
count
(
$invalidRecords
),
1
);
$stack
=
$invalidRecords
[
0
]
->
getE
rrorStack
();
$stack
=
$invalidRecords
[
0
]
->
e
rrorStack
();
$this
->
assertEqual
(
$stack
->
count
(),
2
);
$this
->
assertTrue
(
in_array
(
'notTheSaint'
,
$stack
[
'name'
]));
// validate() hook constraint
...
...
@@ -267,7 +267,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$invalidRecords
=
$e
->
getInvalidRecords
();
$this
->
assertEqual
(
count
(
$invalidRecords
),
1
);
$stack
=
$invalidRecords
[
0
]
->
getE
rrorStack
();
$stack
=
$invalidRecords
[
0
]
->
e
rrorStack
();
$this
->
assertEqual
(
$stack
->
count
(),
1
);
$this
->
assertTrue
(
in_array
(
'notNobody'
,
$stack
[
'loginname'
]));
// validateOnUpdate() hook constraint
...
...
@@ -290,7 +290,7 @@ class Doctrine_Validator_TestCase extends Doctrine_UnitTestCase {
$user
->
save
();
$this
->
fail
();
}
catch
(
Doctrine_Validator_Exception
$ex
)
{
$errors
=
$user
->
getE
rrorStack
();
$errors
=
$user
->
e
rrorStack
();
$this
->
assertTrue
(
in_array
(
'pwNotTopSecret'
,
$errors
[
'password'
]));
}
...
...
tests/ViewTestCase.php
View file @
1eb8b54d
...
...
@@ -56,7 +56,7 @@ class Doctrine_View_TestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$users
->
count
(),
8
);
$this
->
assertEqual
(
$users
[
0
]
->
name
,
'zYne'
);
$this
->
assertEqual
(
$users
[
0
]
->
getS
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
0
]
->
s
tate
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$count
,
$this
->
dbh
->
count
());
$success
=
true
;
...
...
tests/classes.php
View file @
1eb8b54d
This diff is collapsed.
Click to expand it.
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