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
c6e20867
Commit
c6e20867
authored
Jan 11, 2008
by
romanb
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more small refactorings of the new joincondition tests.
parent
62860d51
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
64 deletions
+4
-64
JoinCondition2TestCase.php
tests/Query/JoinCondition2TestCase.php
+4
-64
No files found.
tests/Query/JoinCondition2TestCase.php
View file @
c6e20867
...
...
@@ -60,45 +60,15 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
$zYne
->
save
();
}
public
function
testJoinConditionsRawLeftJoins
()
{
$q
=
Doctrine_Query
::
create
();
$q
->
select
(
'u.id, g.id'
)
->
from
(
'User u'
)
->
leftJoin
(
'u.Group g WITH g.name = ?'
,
'Developers'
)
->
where
(
'u.name = ?'
,
'zYne'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
"SELECT e.id AS e__id, e2.id AS e2__id FROM entity e LEFT JOIN groupuser g"
.
" ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id AND e2.name = ?"
.
" WHERE e.name = ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"
);
$rs
=
$q
->
execute
();
// Should only find zYne
$this
->
assertEqual
(
$rs
->
count
(),
1
);
// Grab the number of runned queries
$queryCount
=
$this
->
connection
->
count
();
// Only one Group fetched for zYne
$this
->
assertEqual
(
$rs
[
0
]
->
Group
->
count
(),
1
);
// Check if it executed any other query
$bug
=
(
$this
->
connection
->
count
()
-
$queryCount
);
// Should return 0 (no more queries executed)
$this
->
assertEqual
(
$bug
,
0
);
}
public
function
testJoinConditionsArgumentsLeftJoins
()
{
$q
=
new
Doctrine_Query
(
$this
->
connection
);
$q
->
select
(
'u.id, g.id'
)
->
from
(
'User u'
)
->
leftJoin
(
'u.Group g WITH g.
id = ?'
,
12
)
->
where
(
'u.id = ?'
,
4
);
$q
->
select
(
'u.id, g.id'
)
->
from
(
'User u'
)
->
leftJoin
(
'u.Group g WITH g.
name = ?'
,
'Developers'
)
->
where
(
'u.name = ?'
,
'zYne'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
"SELECT e.id AS e__id, e2.id AS e2__id FROM entity e"
.
" LEFT JOIN groupuser g ON e.id = g.user_id LEFT JOIN entity e2 ON e2.id = g.group_id"
.
" AND e2.
id = ? WHERE e.id
= ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"
);
.
" AND e2.
name = ? WHERE e.name
= ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"
);
$rs
=
$q
->
execute
();
...
...
@@ -118,45 +88,15 @@ class Doctrine_Query_JoinCondition2_TestCase extends Doctrine_UnitTestCase
$this
->
assertEqual
(
$bug
,
0
);
}
public
function
testJoinConditionsRawInnerJoins
()
{
$q
=
new
Doctrine_Query
(
$this
->
connection
);
$q
->
select
(
'u.id, g.id'
)
->
from
(
'User u'
)
->
innerJoin
(
'u.Group g WITH g.id = 12'
)
->
where
(
'u.id = 4'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
"SELECT e.id AS e__id, e2.id AS e2__id FROM entity e"
.
" INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id"
.
" AND e2.id = 12 WHERE e.id = 4 AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"
);
$rs
=
$q
->
execute
();
// Should only find zYne
$this
->
assertEqual
(
$rs
->
count
(),
1
);
// Grab the number of runned queries
$queryCount
=
$this
->
connection
->
count
();
// Only one Group fetched for zYne
$this
->
assertEqual
(
$rs
[
0
]
->
Group
->
count
(),
1
);
// Check if it executed any other query
$bug
=
(
$this
->
connection
->
count
()
-
$queryCount
);
// Should return 0 (no more queries executed)
$this
->
assertEqual
(
$bug
,
0
);
}
public
function
testJoinCondifitionsArgumentsInnerJoins
()
{
$q
=
new
Doctrine_Query
(
$this
->
connection
);
$q
->
select
(
'u.id, g.id'
)
->
from
(
'User u'
)
->
innerJoin
(
'u.Group g WITH g.
id = ?'
,
12
)
->
where
(
'u.id = ?'
,
4
);
$q
->
select
(
'u.id, g.id'
)
->
from
(
'User u'
)
->
innerJoin
(
'u.Group g WITH g.
name = ?'
,
'Developers'
)
->
where
(
'u.name = ?'
,
'zYne'
);
$this
->
assertEqual
(
$q
->
getQuery
(),
"SELECT e.id AS e__id, e2.id AS e2__id FROM entity e"
.
" INNER JOIN groupuser g ON e.id = g.user_id INNER JOIN entity e2 ON e2.id = g.group_id"
.
" AND e2.
id = ? WHERE e.id
= ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"
);
.
" AND e2.
name = ? WHERE e.name
= ? AND (e.type = 0 AND (e2.type = 1 OR e2.type IS NULL))"
);
$rs
=
$q
->
execute
();
...
...
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