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
e96617bb
Commit
e96617bb
authored
Aug 11, 2007
by
zYne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
--no commit message
--no commit message
parent
a181b06e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
7 deletions
+41
-7
WhereTestCase.php
tests/Query/WhereTestCase.php
+41
-7
No files found.
tests/Query/WhereTestCase.php
View file @
e96617bb
...
...
@@ -33,12 +33,13 @@
*/
class
Doctrine_Query_Where_TestCase
extends
Doctrine_UnitTestCase
{
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
'Entity'
,
'EnumTest'
,
'GroupUser'
);
public
function
prepareData
()
{
}
public
function
prepareTables
()
{
$this
->
tables
=
array
(
'Entity'
,
'EnumTest'
,
'GroupUser'
,
'Account'
,
'Book'
);
parent
::
prepareTables
();
}
public
function
testDirectParameterSetting
()
{
$this
->
connection
->
clear
();
...
...
@@ -49,14 +50,46 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$q
=
new
Doctrine_Query
();
$q
->
from
(
'User'
)
->
addWhere
(
'User.id = ?'
,
1
);
$q
->
from
(
'User'
)
->
addWhere
(
'User.id = ?'
,
1
);
$users
=
$q
->
execute
();
$this
->
assertEqual
(
$users
->
count
(),
1
);
$this
->
assertEqual
(
$users
[
0
]
->
name
,
'someone'
);
}
public
function
testFunctionalExpressionAreSupportedInWherePart
()
{
$q
=
new
Doctrine_Query
();
$q
->
select
(
'u.name'
)
->
from
(
'User u'
)
->
addWhere
(
'TRIM(u.name) = ?'
,
'someone'
);
$users
=
$q
->
execute
();
$this
->
assertEqual
(
$q
->
getQuery
(),
'SELECT e.id AS e__id, e.name AS e__name FROM entity e WHERE TRIM(e.name) = ? AND (e.type = 0)'
);
$this
->
assertEqual
(
$users
->
count
(),
1
);
$this
->
assertEqual
(
$users
[
0
]
->
name
,
'someone'
);
}
public
function
testArithmeticExpressionAreSupportedInWherePart
()
{
$this
->
connection
->
clear
();
$account
=
new
Account
();
$account
->
amount
=
1000
;
$account
->
save
();
$q
=
new
Doctrine_Query
();
$q
->
from
(
'Account a'
)
->
addWhere
(
'((a.amount + 5000) * a.amount + 3) < 10000000'
);
$accounts
=
$q
->
execute
();
$this
->
assertEqual
(
$q
->
getSql
(),
'SELECT a.id AS a__id, a.entity_id AS a__entity_id, a.amount AS a__amount FROM account a WHERE ((a.amount + 5000) * a.amount + 3) < 10000000'
);
$this
->
assertEqual
(
$accounts
->
count
(),
1
);
$this
->
assertEqual
(
$accounts
[
0
]
->
amount
,
1000
);
}
public
function
testDirectMultipleParameterSetting
()
{
$user
=
new
User
();
...
...
@@ -117,12 +150,13 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
// find all users which have groups
try
{
$q
->
from
(
'User u'
)
->
where
(
'EXISTS (SELECT
Groupuser.id FROM Groupuser WHERE Groupuser
.user_id = u.id)'
);
$q
->
from
(
'User u'
)
->
where
(
'EXISTS (SELECT
g.id FROM Groupuser g WHERE g
.user_id = u.id)'
);
$this
->
pass
();
}
catch
(
Doctrine_Exception
$e
)
{
$this
->
fail
();
}
$users
=
$q
->
execute
();
$this
->
assertEqual
(
$users
->
count
(),
1
);
$this
->
assertEqual
(
$users
[
0
]
->
name
,
'someone with a group'
);
}
...
...
@@ -271,5 +305,5 @@ class Doctrine_Query_Where_TestCase extends Doctrine_UnitTestCase
$this
->
assertTrue
(
empty
(
$p
[
':id'
]));
$q
->
execute
(
array
(
1
,
'verified'
));
}
}
?>
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