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
14b95350
Commit
14b95350
authored
Sep 28, 2006
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #132, refactored some test cases
Ticket: 132
parent
d5b1c350
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
90 additions
and
72 deletions
+90
-72
Record.php
lib/Doctrine/Record.php
+4
-2
Repository.php
lib/Doctrine/Repository.php
+7
-1
EnumTestCase.php
tests/EnumTestCase.php
+60
-0
QueryTestCase.php
tests/QueryTestCase.php
+2
-2
RecordTestCase.php
tests/RecordTestCase.php
+14
-64
TableTestCase.php
tests/TableTestCase.php
+3
-3
No files found.
lib/Doctrine/Record.php
View file @
14b95350
...
...
@@ -783,10 +783,12 @@ abstract class Doctrine_Record extends Doctrine_Access implements Countable, Ite
* @return boolean
*/
public
function
contains
(
$name
)
{
if
(
isset
(
$this
->
data
[
$name
]))
$lower
=
strtolower
(
$name
);
if
(
isset
(
$this
->
data
[
$lower
]))
return
true
;
if
(
isset
(
$this
->
id
[
$
name
]))
if
(
isset
(
$this
->
id
[
$
lower
]))
return
true
;
if
(
isset
(
$this
->
references
[
$name
]))
...
...
lib/Doctrine/Repository.php
View file @
14b95350
...
...
@@ -41,11 +41,15 @@ class Doctrine_Repository implements Countable, IteratorAggregate {
private
$registry
=
array
();
/**
* constructor
*
* @param Doctrine_Table $table
*/
public
function
__construct
(
Doctrine_Table
$table
)
{
$this
->
table
=
$table
;
}
/**
/**
* getTable
*
* @return object Doctrine_Table
*/
public
function
getTable
()
{
...
...
@@ -53,7 +57,9 @@ class Doctrine_Repository implements Countable, IteratorAggregate {
}
/**
* add
*
* @param Doctrine_Record $record record to be added into registry
* @return boolean
*/
public
function
add
(
Doctrine_Record
$record
)
{
$oid
=
$record
->
getOID
();
...
...
tests/EnumTestCase.php
View file @
14b95350
...
...
@@ -20,7 +20,67 @@ class Doctrine_EnumTestCase extends Doctrine_UnitTestCase {
$ret
=
$query
->
query
(
'FROM EnumTest WHERE EnumTest.status = open'
);
$this
->
assertEqual
(
count
(
$ret
),
1
);
}
public
function
testEnumType
()
{
$enum
=
new
EnumTest
();
$enum
->
status
=
"open"
;
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
status
=
"closed"
;
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$this
->
assertTrue
(
is_numeric
(
$enum
->
id
));
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
}
public
function
testEnumTypeWithCaseConversion
()
{
$this
->
dbh
->
setAttribute
(
PDO
::
ATTR_CASE
,
PDO
::
CASE_UPPER
);
$enum
=
new
EnumTest
();
$enum
->
status
=
"open"
;
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
status
=
"closed"
;
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$this
->
dbh
->
setAttribute
(
PDO
::
ATTR_CASE
,
PDO
::
CASE_NATURAL
);
}
public
function
testFailingRefresh
()
{
$enum
=
$this
->
connection
->
getTable
(
'EnumTest'
)
->
find
(
1
);
$this
->
dbh
->
query
(
'DELETE FROM enum_test WHERE id = 1'
);
$f
=
false
;
try
{
$enum
->
refresh
();
}
catch
(
Doctrine_Record_Exception
$e
)
{
$f
=
true
;
}
$this
->
assertTrue
(
$f
);
}
}
?>
tests/QueryTestCase.php
View file @
14b95350
...
...
@@ -927,11 +927,11 @@ class Doctrine_QueryTestCase extends Doctrine_UnitTestCase {
$fk
=
$table
->
getRelation
(
"Threads"
);
$this
->
assertEqual
(
$table
->
getComponentName
(),
"Forum_Board"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_
Relation_
ForeignKey
);
$this
->
assertEqual
(
$fk
->
getTable
()
->
getComponentName
(),
"Forum_Thread"
);
$entry
=
new
Forum_Entry
();
$this
->
assertTrue
(
$entry
->
getTable
()
->
getRelation
(
"Thread"
)
instanceof
Doctrine_LocalKey
);
$this
->
assertTrue
(
$entry
->
getTable
()
->
getRelation
(
"Thread"
)
instanceof
Doctrine_
Relation_
LocalKey
);
$board
->
name
=
"Doctrine Forum"
;
...
...
tests/RecordTestCase.php
View file @
14b95350
...
...
@@ -9,6 +9,17 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
tables
[]
=
"GzipTest"
;
parent
::
prepareTables
();
}
public
function
testIssetForPrimaryKey
()
{
$this
->
assertTrue
(
isset
(
$this
->
users
[
0
]
->
id
));
$this
->
assertTrue
(
isset
(
$this
->
users
[
0
][
'id'
]));
$this
->
assertTrue
(
$this
->
users
[
0
]
->
contains
(
'id'
));
$user
=
new
User
();
$this
->
assertFalse
(
isset
(
$user
->
id
));
$this
->
assertFalse
(
isset
(
$user
[
'id'
]));
$this
->
assertFalse
(
$user
->
contains
(
'id'
));
}
public
function
testNotNullConstraint
()
{
$null
=
new
NotNullTest
();
...
...
@@ -46,67 +57,6 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$this
->
assertEqual
(
$gzip
->
gzip
,
"compressed 2"
);
}
public
function
testEnumType
()
{
$enum
=
new
EnumTest
();
$enum
->
status
=
"open"
;
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
status
=
"closed"
;
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$this
->
assertTrue
(
is_numeric
(
$enum
->
id
));
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
}
public
function
testEnumTypeWithCaseConversion
()
{
$this
->
dbh
->
setAttribute
(
PDO
::
ATTR_CASE
,
PDO
::
CASE_UPPER
);
$enum
=
new
EnumTest
();
$enum
->
status
=
"open"
;
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"open"
);
$enum
->
status
=
"closed"
;
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$enum
->
save
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$enum
->
refresh
();
$this
->
assertEqual
(
$enum
->
status
,
"closed"
);
$this
->
dbh
->
setAttribute
(
PDO
::
ATTR_CASE
,
PDO
::
CASE_NATURAL
);
}
public
function
testFailingRefresh
()
{
$enum
=
$this
->
connection
->
getTable
(
'EnumTest'
)
->
find
(
1
);
$this
->
dbh
->
query
(
'DELETE FROM enum_test WHERE id = 1'
);
$f
=
false
;
try
{
$enum
->
refresh
();
}
catch
(
Doctrine_Record_Exception
$e
)
{
$f
=
true
;
}
$this
->
assertTrue
(
$f
);
}
public
function
testDefaultValues
()
{
$test
=
new
FieldNameTest
;
...
...
@@ -540,7 +490,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$e
=
new
Element
();
$fk
=
$e
->
getTable
()
->
getRelation
(
"Child"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_
Relation_
ForeignKey
);
$this
->
assertEqual
(
$fk
->
getType
(),
Doctrine_Relation
::
MANY_AGGREGATE
);
$this
->
assertEqual
(
$fk
->
getForeign
(),
"parent_id"
);
$this
->
assertEqual
(
$fk
->
getLocal
(),
"id"
);
...
...
@@ -609,7 +559,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
$fk
=
$e
->
getTable
()
->
getRelation
(
"Description"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_
Relation_
ForeignKey
);
$this
->
assertEqual
(
$fk
->
getLocal
(),
"file_md5"
);
$this
->
assertEqual
(
$fk
->
getForeign
(),
"file_md5"
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
...
...
@@ -911,7 +861,7 @@ class Doctrine_RecordTestCase extends Doctrine_UnitTestCase {
// ACCESSING ASSOCIATION OBJECT PROPERTIES
$user
=
new
User
();
$this
->
assertTrue
(
$user
->
getTable
()
->
getRelation
(
"Groupuser"
)
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$user
->
getTable
()
->
getRelation
(
"Groupuser"
)
instanceof
Doctrine_
Relation_
ForeignKey
);
$this
->
assertTrue
(
$user
->
Groupuser
instanceof
Doctrine_Collection
);
$this
->
assertTrue
(
$user
->
Groupuser
[
0
]
instanceof
Groupuser
);
...
...
tests/TableTestCase.php
View file @
14b95350
...
...
@@ -62,14 +62,14 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
}
public
function
testGetForeignKey
()
{
$fk
=
$this
->
objTable
->
getRelation
(
"Group"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_Association
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_
Relation_
Association
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$fk
->
getType
()
==
Doctrine_Relation
::
MANY_AGGREGATE
);
$this
->
assertTrue
(
$fk
->
getLocal
()
==
"user_id"
);
$this
->
assertTrue
(
$fk
->
getForeign
()
==
"group_id"
);
$fk
=
$this
->
objTable
->
getRelation
(
"Email"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_LocalKey
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_
Relation_
LocalKey
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$fk
->
getType
()
==
Doctrine_Relation
::
ONE_COMPOSITE
);
$this
->
assertTrue
(
$fk
->
getLocal
()
==
"email_id"
);
...
...
@@ -77,7 +77,7 @@ class Doctrine_TableTestCase extends Doctrine_UnitTestCase {
$fk
=
$this
->
objTable
->
getRelation
(
"Phonenumber"
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_ForeignKey
);
$this
->
assertTrue
(
$fk
instanceof
Doctrine_
Relation_
ForeignKey
);
$this
->
assertTrue
(
$fk
->
getTable
()
instanceof
Doctrine_Table
);
$this
->
assertTrue
(
$fk
->
getType
()
==
Doctrine_Relation
::
MANY_COMPOSITE
);
$this
->
assertTrue
(
$fk
->
getLocal
()
==
$this
->
objTable
->
getIdentifier
());
...
...
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