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
7f68e096
Commit
7f68e096
authored
Apr 11, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
93c386f6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
69 additions
and
72 deletions
+69
-72
CollectionTestCase.php
tests/CollectionTestCase.php
+21
-19
ExportTestCase.php
tests/ExportTestCase.php
+4
-0
ManyToManyTestCase.php
tests/Relation/ManyToManyTestCase.php
+7
-35
RelationTestCase.php
tests/RelationTestCase.php
+29
-12
UnitTestCase.php
tests/UnitTestCase.php
+2
-4
run.php
tests/run.php
+6
-2
No files found.
tests/CollectionTestCase.php
View file @
7f68e096
...
...
@@ -32,29 +32,30 @@
*/
class
Doctrine_Collection_TestCase
extends
Doctrine_UnitTestCase
{
/**
public function testLoadRelatedForAssociation()
{
$coll
=
$this
->
connection
->
query
(
"FROM User"
);
$coll = $this->connection->query(
'FROM User'
);
$this->assertEqual($coll->count(), 8);
$coll
[
0
]
->
Group
[
1
]
->
name
=
"Actors House 2"
;
$coll[0]->Group[1]->name =
'Actors House 2'
;
$coll
[
0
]
->
Group
[
2
]
->
name
=
"Actors House 3"
;
$coll[0]->Group[2]->name =
'Actors House 3'
;
$coll
[
2
]
->
Group
[
0
]
->
name
=
"Actors House 4"
;
$coll
[
2
]
->
Group
[
1
]
->
name
=
"Actors House 5"
;
$coll
[
2
]
->
Group
[
2
]
->
name
=
"Actors House 6"
;
$coll[2]->Group[0]->name =
'Actors House 4'
;
$coll[2]->Group[1]->name =
'Actors House 5'
;
$coll[2]->Group[2]->name =
'Actors House 6'
;
$coll
[
5
]
->
Group
[
0
]
->
name
=
"Actors House 7"
;
$coll
[
5
]
->
Group
[
1
]
->
name
=
"Actors House 8"
;
$coll
[
5
]
->
Group
[
2
]
->
name
=
"Actors House 9"
;
$coll[5]->Group[0]->name =
'Actors House 7'
;
$coll[5]->Group[1]->name =
'Actors House 8'
;
$coll[5]->Group[2]->name =
'Actors House 9'
;
$coll->save();
$this->connection->clear();
$coll
=
$this
->
connection
->
query
(
"FROM User"
);
$coll = $this->connection->query(
'FROM User'
);
$this->assertEqual($coll->count(), 8);
$this->assertEqual($coll[0]->Group->count(), 2);
...
...
@@ -64,13 +65,13 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
$this->connection->clear();
$coll
=
$this
->
connection
->
query
(
"FROM User"
);
$coll = $this->connection->query(
'FROM User'
);
$this->assertEqual($coll->count(), 8);
$count = $this->dbh->count();
$coll
->
loadRelated
(
"Group"
);
$coll->loadRelated(
'Group'
);
$this->assertEqual(($count + 1), $this->dbh->count());
$this->assertEqual($coll[0]->Group->count(), 2);
$this->assertEqual(($count + 1), $this->dbh->count());
...
...
@@ -97,6 +98,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
$this->assertEqual($coll->count(), 1);
$this->assertEqual($coll[0]->name, 'zYne');
}
*/
public
function
testLoadRelatedForNormalAssociation
()
{
...
...
@@ -148,7 +150,7 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
public
function
testLoadRelated
()
{
$coll
=
$this
->
connection
->
query
(
"FROM User(id)"
);
$coll
=
$this
->
connection
->
query
(
'FROM User(id)'
);
$q
=
$coll
->
loadRelated
();
...
...
@@ -165,24 +167,24 @@ class Doctrine_Collection_TestCase extends Doctrine_UnitTestCase
}
public
function
testLoadRelatedForLocalKeyRelation
()
{
$coll
=
$this
->
connection
->
query
(
"FROM User"
);
$coll
=
$this
->
connection
->
query
(
'FROM User'
);
$this
->
assertEqual
(
$coll
->
count
(),
8
);
$count
=
$this
->
dbh
->
count
();
$coll
->
loadRelated
(
"Email"
);
$coll
->
loadRelated
(
'Email'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$coll
[
0
]
->
Email
->
address
,
"zYne@example.com"
);
$this
->
assertEqual
(
$coll
[
0
]
->
Email
->
address
,
'zYne@example.com'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
$this
->
assertEqual
(
$coll
[
2
]
->
Email
->
address
,
"caine@example.com"
);
$this
->
assertEqual
(
$coll
[
2
]
->
Email
->
address
,
'caine@example.com'
);
$this
->
assertEqual
(
$coll
[
3
]
->
Email
->
address
,
"kitano@example.com"
);
$this
->
assertEqual
(
$coll
[
3
]
->
Email
->
address
,
'kitano@example.com'
);
$this
->
assertEqual
(
$coll
[
4
]
->
Email
->
address
,
"stallone@example.com"
);
$this
->
assertEqual
(
$coll
[
4
]
->
Email
->
address
,
'stallone@example.com'
);
$this
->
assertEqual
((
$count
+
1
),
$this
->
dbh
->
count
());
...
...
tests/ExportTestCase.php
View file @
7f68e096
...
...
@@ -80,6 +80,10 @@ class Doctrine_Export_TestCase extends Doctrine_UnitTestCase
public
function
testRecordIsExportedProperly
()
{
}
public
function
testExport
()
{
}
}
?>
tests/Relation/ManyToManyTestCase.php
View file @
7f68e096
...
...
@@ -13,14 +13,7 @@ class M2MTest extends Doctrine_Record {
}
}
class
RelationErrorTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
200
);
}
public
function
setUp
()
{
$this
->
hasMany
(
'RTCUnknown'
,
'JC1.c1_id'
);
}
}
class
M2MTest2
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'oid'
,
'integer'
,
11
,
array
(
'autoincrement'
,
'primary'
));
...
...
@@ -30,14 +23,7 @@ class M2MTest2 extends Doctrine_Record {
$this
->
hasMany
(
'RTC4 as RTC5'
,
'JC3.c1_id'
);
}
}
class
RTCUnknown
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
200
);
}
public
function
setUp
()
{
$this
->
hasMany
(
'M2MTest'
,
'JC2.c2_id'
);
}
}
class
JC3
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'c1_id'
,
'integer'
);
...
...
@@ -153,21 +139,10 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
$this
->
fail
();
}
}
public
function
testUnknownManyToManyRelation
()
{
try
{
$component
=
new
RelationErrorTest
();
$rel
=
$component
->
getTable
()
->
getRelation
(
'RTCUnknown'
);
$this
->
fail
();
}
catch
(
Doctrine_Table_Exception
$e
)
{
$this
->
pass
();
}
}
public
function
testManyToManyRelationFetchingWithAliasesAndCustomPKs2
()
{
$q
=
new
Doctrine_Query
();
try
{
$q
->
from
(
'M2MTest2 m INNER JOIN m.JC3'
);
$this
->
pass
();
...
...
@@ -182,17 +157,14 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
}
}
public
function
testManyToManyHasRelationWithAliases4
()
{
$component
=
new
M2MTest
();
try
{
$rel
=
$component
->
getTable
()
->
getRelation
(
'RTC4'
);
$component
=
new
M2MTest
();
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
$this
->
assertTrue
(
$rel
instanceof
Doctrine_Relation_Association
);
$this
->
assertTrue
(
$component
->
RTC4
instanceof
Doctrine_Collection
);
}
public
function
testManyToManyHasRelationWithAliases3
()
{
...
...
@@ -212,7 +184,7 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
public
function
testManyToManyHasRelationWithAliases
()
{
$component
=
new
M2MTest
();
try
{
$rel
=
$component
->
getTable
()
->
getRelation
(
'RTC1'
);
$this
->
pass
();
...
...
@@ -226,7 +198,7 @@ class Doctrine_Relation_ManyToMany_TestCase extends Doctrine_UnitTestCase {
public
function
testManyToManyHasRelationWithAliases2
()
{
$component
=
new
M2MTest
();
try
{
$rel
=
$component
->
getTable
()
->
getRelation
(
'RTC2'
);
$this
->
pass
();
...
...
tests/RelationTestCase.php
View file @
7f68e096
<?php
class
RelationTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
class
RelationTest
extends
Doctrine_Record
{
public
function
setTableDefinition
()
{
$this
->
hasColumn
(
'name'
,
'string'
,
200
);
$this
->
hasColumn
(
'child_id'
,
'integer'
);
}
public
function
setUp
()
{
public
function
setUp
()
{
$this
->
ownsMany
(
'OwnsOneToManyWithAlias as AliasO2M'
,
'AliasO2M.component_id'
);
}
}
class
RelationTestChild
extends
RelationTest
{
public
function
setUp
()
{
class
RelationTestChild
extends
RelationTest
{
public
function
setUp
()
{
$this
->
hasOne
(
'RelationTest as Parent'
,
'RelationTestChild.child_id'
);
$this
->
ownsMany
(
'RelationTestChild as Children'
,
'RelationTestChild.child_id'
);
...
...
@@ -37,28 +42,39 @@ class OwnsOneToManyWithAlias extends Doctrine_Record {
}
class
Doctrine_Relation_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
parent
::
prepareTables
();
public
function
prepareData
()
{
}
public
function
prepareTables
()
{}
public
function
setUp
()
{
if
(
!
$this
->
init
)
$this
->
init
();
if
(
isset
(
$this
->
objTable
))
{
$this
->
objTable
->
clear
();
}
$this
->
init
=
true
;
}
public
function
testOneToManyTreeRelationWithConcreteInheritance
()
{
$component
=
new
RelationTestChild
();
try
{
$rel
=
$component
->
getTable
()
->
getRelation
(
'Children'
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
$this
->
assertTrue
(
$rel
instanceof
Doctrine_Relation_ForeignKey
);
$this
->
assertTrue
(
$component
->
Children
instanceof
Doctrine_Collection
);
$this
->
assertTrue
(
$component
->
Children
[
0
]
instanceof
RelationTestChild
);
}
public
function
testOneToOneTreeRelationWithConcreteInheritance
()
{
$component
=
new
RelationTestChild
();
...
...
@@ -114,5 +130,6 @@ class Doctrine_Relation_TestCase extends Doctrine_UnitTestCase {
$this
->
assertTrue
(
$user
->
getTable
()
->
getRelation
(
'Phonenumber'
)
instanceof
Doctrine_Relation_ForeignKey
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_CREATE_TABLES
,
true
);
}
}
}
tests/UnitTestCase.php
View file @
7f68e096
...
...
@@ -22,14 +22,14 @@ class Doctrine_UnitTestCase extends UnitTestCase {
protected
$transaction
;
pr
ivate
$init
=
false
;
pr
otected
$init
=
false
;
public
function
init
()
{
$name
=
get_class
(
$this
);
$this
->
manager
=
Doctrine_Manager
::
getInstance
();
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_FETCHMODE
,
Doctrine
::
FETCH_IMMEDIATE
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_EXPORT
,
Doctrine
::
EXPORT_ALL
);
$this
->
manager
->
setAttribute
(
Doctrine
::
ATTR_EXPORT
,
Doctrine
::
EXPORT_ALL
);
$this
->
tables
=
array_merge
(
$this
->
tables
,
array
(
"entity"
,
...
...
@@ -129,8 +129,6 @@ class Doctrine_UnitTestCase extends UnitTestCase {
$this
->
prepareTables
();
$this
->
prepareData
();
}
$this
->
valueHolder
=
new
Doctrine_ValueHolder
(
$this
->
connection
->
getTable
(
'User'
));
}
public
function
prepareTables
()
{
foreach
(
$this
->
tables
as
$name
)
{
...
...
tests/run.php
View file @
7f68e096
...
...
@@ -104,11 +104,11 @@ $test->addTestCase(new Doctrine_Sequence_Sqlite_TestCase());
// Export module (not yet fully tested)
$test
->
addTestCase
(
new
Doctrine_Export_TestCase
());
//$test->addTestCase(new Doctrine_Export_Reporter_TestCase());
$test
->
addTestCase
(
new
Doctrine_Export_Firebird_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Informix_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Mssql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Pgsql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Export_Oracle_TestCase
());
...
...
@@ -116,6 +116,8 @@ $test->addTestCase(new Doctrine_Export_Sqlite_TestCase());
$test
->
addTestCase
(
new
Doctrine_Export_Mysql_TestCase
());
$test
->
addTestCase
(
new
Doctrine_CascadingDelete_TestCase
());
// Import module (not yet fully tested)
//$test->addTestCase(new Doctrine_Import_TestCase());
$test
->
addTestCase
(
new
Doctrine_Import_Firebird_TestCase
());
...
...
@@ -146,6 +148,7 @@ $test->addTestCase(new Doctrine_Manager_TestCase());
$test
->
addTestCase
(
new
Doctrine_Connection_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Table_TestCase
());
$test
->
addTestCase
(
new
Doctrine_UnitOfWork_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Connection_Transaction_TestCase
());
...
...
@@ -234,6 +237,7 @@ $test->addTestCase(new Doctrine_Cache_Apc_TestCase());
$test
->
addTestCase
(
new
Doctrine_Cache_Memcache_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Cache_Sqlite_TestCase
());
$test
->
addTestCase
(
new
Doctrine_Query_Check_TestCase
());
// Cache tests
//$test->addTestCase(new Doctrine_Cache_Query_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