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
05a23f6a
Commit
05a23f6a
authored
Oct 01, 2006
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a test case to track an ugly bug.
parent
4eb1060b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
867 additions
and
736 deletions
+867
-736
CustomResultSetOrderTestCase.php
tests/CustomResultSetOrderTestCase.php
+110
-0
classes.php
tests/classes.php
+543
-525
run.php
tests/run.php
+214
-211
No files found.
tests/CustomResultSetOrderTestCase.php
0 → 100644
View file @
05a23f6a
<?
PHP
class
Doctrine_CustomResultSetOrderTestCase
extends
Doctrine_UnitTestCase
{
/**
* Prepares the data under test.
*
* 1st category: 3 Boards
* 2nd category: 1 Board
* 3rd category: 0 boards
*
*/
public
function
prepareData
()
{
$cat1
=
new
CategoryWithPosition
();
$cat1
->
position
=
0
;
$cat1
->
name
=
"First"
;
$cat2
=
new
CategoryWithPosition
();
$cat2
->
position
=
0
;
// same 'priority' as the first
$cat2
->
name
=
"Second"
;
$cat3
=
new
CategoryWithPosition
();
$cat3
->
position
=
1
;
$cat3
->
name
=
"Third"
;
$board1
=
new
BoardWithPosition
();
$board1
->
position
=
0
;
$board2
=
new
BoardWithPosition
();
$board2
->
position
=
1
;
$board3
=
new
BoardWithPosition
();
$board3
->
position
=
2
;
// The first category gets 3 boards!
$cat1
->
Boards
[
0
]
=
$board1
;
$cat1
->
Boards
[
1
]
=
$board2
;
$cat1
->
Boards
[
2
]
=
$board3
;
$board4
=
new
BoardWithPosition
();
$board4
->
position
=
0
;
// The second category gets 1 board!
$cat2
->
Boards
[
0
]
=
$board4
;
$this
->
connection
->
flush
();
}
/**
* Prepares the tables.
*/
public
function
prepareTables
()
{
$this
->
tables
[]
=
"CategoryWithPosition"
;
$this
->
tables
[]
=
"BoardWithPosition"
;
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
testQueryWithOrdering
()
{
$categories
=
$this
->
connection
->
query
(
"FROM CategoryWithPosition.Boards
ORDER BY CategoryWithPosition.position ASC, CategoryWithPosition.Boards.position ASC"
);
// 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
,
$category
->
Boards
->
count
());
break
;
case
"Second"
:
// The second category should have 1 board, but it got 3 now
$this
->
assertEqual
(
1
,
$category
->
Boards
->
count
());
break
;
case
"Third"
:
// The third has no boards as expected.
$this
->
assertEqual
(
0
,
$category
->
Boards
->
count
());
break
;
}
}
}
}
?>
\ No newline at end of file
tests/classes.php
View file @
05a23f6a
This diff is collapsed.
Click to expand it.
tests/run.php
View file @
05a23f6a
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