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
063d0f87
Commit
063d0f87
authored
May 29, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
f4462041
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
77 additions
and
2 deletions
+77
-2
SnapshotTestCase.php
tests/Collection/SnapshotTestCase.php
+11
-2
FetchModeTestCase.php
tests/Hydrate/FetchModeTestCase.php
+66
-0
No files found.
tests/Collection/SnapshotTestCase.php
View file @
063d0f87
...
...
@@ -38,6 +38,7 @@
*/
class
Doctrine_Collection_Snapshot_TestCase
extends
Doctrine_UnitTestCase
{
public
function
testDiffForSimpleCollection
()
{
$coll
=
Doctrine_Query
::
create
()
->
from
(
'User u'
)
->
orderby
(
'u.id'
)
->
execute
();
...
...
@@ -55,34 +56,41 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$this
->
connection
->
clear
();
$coll
=
Doctrine_Query
::
create
()
->
from
(
'User u'
)
->
execute
();
$this
->
assertEqual
(
$coll
->
count
(),
7
);
}
public
function
testDiffForOneToManyRelatedCollection
()
{
$q
=
Doctrine_Query
::
create
()
->
from
(
'User u LEFT JOIN u.Phonenumber p'
)
->
where
(
'u.id = 8'
);
$q
=
new
Doctrine_Query
();
$q
->
from
(
'User u LEFT JOIN u.Phonenumber p'
)
->
where
(
'u.id = 8'
);
$coll
=
$q
->
execute
();
$this
->
assertEqual
(
$coll
->
count
(),
1
);
$this
->
assertEqual
(
$coll
[
0
]
->
Phonenumber
->
count
(),
3
);
$this
->
assertTrue
(
$coll
[
0
]
->
Phonenumber
instanceof
Doctrine_Collection
);
unset
(
$coll
[
0
]
->
Phonenumber
[
0
]);
$coll
[
0
]
->
Phonenumber
->
remove
(
2
);
$this
->
assertEqual
(
count
(
$coll
[
0
]
->
Phonenumber
->
getSnapshot
()),
3
);
$coll
[
0
]
->
save
();
$this
->
assertEqual
(
$coll
[
0
]
->
Phonenumber
->
count
(),
1
);
$this
->
connection
->
clear
();
$q
=
new
Doctrine_Query
();
$q
=
Doctrine_Query
::
create
()
->
from
(
'User u LEFT JOIN u.Phonenumber p'
)
->
where
(
'u.id = 8'
);
$coll
=
$q
->
execute
();
$this
->
assertEqual
(
$coll
[
0
]
->
Phonenumber
->
count
(),
1
);
}
public
function
testDiffForManyToManyRelatedCollection
()
{
$user
=
new
User
();
...
...
@@ -110,4 +118,5 @@ class Doctrine_Collection_Snapshot_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
count
(
$user
->
Group
->
getSnapshot
()),
0
);
}
}
tests/Hydrate/FetchModeTestCase.php
View file @
063d0f87
...
...
@@ -32,6 +32,7 @@
*/
class
Doctrine_Hydrate_FetchMode_TestCase
extends
Doctrine_UnitTestCase
{
/**
public function testFetchArraySupportsOneToManyRelations()
{
$q = new Doctrine_Query();
...
...
@@ -80,4 +81,69 @@ class Doctrine_Hydrate_FetchMode_TestCase extends Doctrine_UnitTestCase
$this->assertEqual(count($users), 8);
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
}
public function testFetchArraySupportsOneToOneRelations2()
{
$q = new Doctrine_Query();
$q->select('u.*, e.*')->from('User u')->innerJoin('u.Email e')->where("u.name = 'zYne'");
$users = $q->execute(array(), Doctrine::FETCH_ARRAY);
$this->assertEqual(count($users), 1);
$this->assertEqual($users[0]['Email']['address'], 'zYne@example.com');
}
*/
public
function
testFetchRecordSupportsOneToOneRelations
()
{
$q
=
new
Doctrine_Query
();
$q
->
select
(
'u.*, e.*'
)
->
from
(
'User u'
)
->
innerJoin
(
'u.Email e'
);
$count
=
count
(
$this
->
dbh
);
$users
=
$q
->
execute
(
array
(),
Doctrine
::
FETCH_RECORD
);
$this
->
assertEqual
(
count
(
$users
),
8
);
$this
->
assertEqual
(
$users
[
0
][
'Email'
][
'address'
],
'zYne@example.com'
);
$this
->
assertTrue
(
$users
[
0
]
instanceof
User
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
$users
[
0
]
->
state
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
$users
[
0
]
->
id
,
4
);
$this
->
assertTrue
(
$users
[
0
][
'Email'
]
instanceof
Email
);
$this
->
assertEqual
(
$users
[
0
][
'email_id'
],
1
);
$this
->
assertEqual
(
count
(
$this
->
dbh
),
$count
+
1
);
}
public
function
testFetchRecordSupportsOneToManyRelations
()
{
$q
=
new
Doctrine_Query
();
$q
->
select
(
'u.*, p.*'
)
->
from
(
'User u'
)
->
innerJoin
(
'u.Phonenumber p'
);
$count
=
count
(
$this
->
dbh
);
$users
=
$q
->
execute
(
array
(),
Doctrine
::
FETCH_RECORD
);
$this
->
assertEqual
(
count
(
$users
),
8
);
$this
->
assertTrue
(
$users
[
0
]
instanceof
User
);
$this
->
assertEqual
(
$users
[
0
]
->
state
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertTrue
(
$users
instanceof
Doctrine_Collection
);
$this
->
assertTrue
(
$users
[
0
]
->
Phonenumber
instanceof
Doctrine_Collection
);
$this
->
assertEqual
(
count
(
$this
->
dbh
),
$count
+
1
);
}
public
function
testFetchRecordSupportsSimpleFetching
()
{
$q
=
new
Doctrine_Query
();
$q
->
select
(
'u.*'
)
->
from
(
'User u'
);
$count
=
count
(
$this
->
dbh
);
$users
=
$q
->
execute
(
array
(),
Doctrine
::
FETCH_RECORD
);
$this
->
assertEqual
(
count
(
$users
),
8
);
$this
->
assertTrue
(
$users
[
0
]
instanceof
User
);
$this
->
assertEqual
(
$users
[
0
]
->
state
(),
Doctrine_Record
::
STATE_CLEAN
);
$this
->
assertEqual
(
count
(
$this
->
dbh
),
$count
+
1
);
}
}
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