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
033d511c
Commit
033d511c
authored
Jun 04, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
a41cd2bb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
10 deletions
+59
-10
CustomResultSetOrderTestCase.php
tests/CustomResultSetOrderTestCase.php
+59
-10
No files found.
tests/CustomResultSetOrderTestCase.php
View file @
033d511c
...
@@ -84,6 +84,51 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase {
...
@@ -84,6 +84,51 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase {
$this
->
tables
[]
=
"BoardWithPosition"
;
$this
->
tables
[]
=
"BoardWithPosition"
;
parent
::
prepareTables
();
parent
::
prepareTables
();
}
}
/**
* Checks whether the boards are correctly assigned to the categories.
*
* The 'evil' result set that confuses the object population is displayed below.
*
* catId | catPos | catName | boardPos | board.category_id
* 1 | 0 | First | 0 | 1
* 2 | 0 | Second | 0 | 2 <-- The split that confuses the object population
* 1 | 0 | First | 1 | 1
* 1 | 0 | First | 2 | 1
* 3 | 2 | Third | NULL
*/
public
function
testQueryWithOrdering2
()
{
$q
=
new
Doctrine_Query
(
$this
->
connection
);
print
'<pre>'
;
$categories
=
$q
->
select
(
'c.*, b.*'
)
->
from
(
'CategoryWithPosition c'
)
->
leftJoin
(
'c.Boards b'
)
->
orderBy
(
'c.position ASC, b.position ASC'
)
->
execute
(
array
(),
Doctrine
::
FETCH_ARRAY
);
$this
->
assertEqual
(
3
,
count
(
$categories
),
'Some categories were doubled!'
);
// Check each category
foreach
(
$categories
as
$category
)
{
switch
(
$category
[
'name'
])
{
case
'First'
:
// The first category should have 3 boards, right?
// It has only 1! The other two slipped to the 2nd category!
$this
->
assertEqual
(
3
,
count
(
$category
[
'Boards'
]));
break
;
case
'Second'
:
// The second category should have 1 board, but it got 3 now
$this
->
assertEqual
(
1
,
count
(
$category
[
'Boards'
]));;
break
;
case
'Third'
:
// The third has no boards as expected.
//print $category->Boards[0]->position;
$this
->
assertEqual
(
0
,
count
(
$category
[
'Boards'
]));
break
;
}
}
}
/**
/**
* Checks whether the boards are correctly assigned to the categories.
* Checks whether the boards are correctly assigned to the categories.
...
@@ -97,31 +142,35 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase {
...
@@ -97,31 +142,35 @@ class Doctrine_CustomResultSetOrder_TestCase extends Doctrine_UnitTestCase {
* 1 | 0 | First | 2 | 1
* 1 | 0 | First | 2 | 1
* 3 | 2 | Third | NULL
* 3 | 2 | Third | NULL
*/
*/
public
function
testQueryWithOrdering
()
{
public
function
testQueryWithOrdering
()
{
$q
=
new
Doctrine_Query
(
$this
->
connection
);
$q
=
new
Doctrine_Query
(
$this
->
connection
);
$categories
=
$q
->
select
(
"c.*, b.*"
)
$categories
=
$q
->
select
(
'c.*, b.*'
)
->
from
(
"CategoryWithPosition c"
)
->
from
(
'CategoryWithPosition c'
)
->
leftJoin
(
"c.Boards b"
)
->
leftJoin
(
'c.Boards b'
)
->
orderBy
(
"c.position ASC, b.position ASC"
)
->
orderBy
(
'c.position ASC, b.position ASC'
)
->
execute
();
->
execute
();
$this
->
assertEqual
(
3
,
$categories
->
count
(),
"Some categories were doubled!"
);
$this
->
assertEqual
(
3
,
$categories
->
count
(),
'Some categories were doubled!'
);
// Check each category
// Check each category
foreach
(
$categories
as
$category
)
{
foreach
(
$categories
as
$category
)
{
switch
(
$category
->
name
)
{
switch
(
$category
->
name
)
{
case
"First"
:
case
'First'
:
// The first category should have 3 boards, right?
// The first category should have 3 boards, right?
// It has only 1! The other two slipped to the 2nd category!
// It has only 1! The other two slipped to the 2nd category!
print
$category
->
Boards
->
count
();
$this
->
assertEqual
(
3
,
$category
->
Boards
->
count
());
$this
->
assertEqual
(
3
,
$category
->
Boards
->
count
());
break
;
break
;
case
"Second"
:
case
'Second'
:
// The second category should have 1 board, but it got 3 now
// The second category should have 1 board, but it got 3 now
print
$category
->
Boards
->
count
();
$this
->
assertEqual
(
1
,
$category
->
Boards
->
count
());
$this
->
assertEqual
(
1
,
$category
->
Boards
->
count
());
break
;
break
;
case
"Third"
:
case
'Third'
:
// The third has no boards as expected.
// The third has no boards as expected.
//print $category->Boards[0]->position;
$this
->
assertEqual
(
0
,
$category
->
Boards
->
count
());
$this
->
assertEqual
(
0
,
$category
->
Boards
->
count
());
break
;
break
;
}
}
...
...
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