Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Q
question2answer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
outils
question2answer
Commits
5d8bb7d0
Commit
5d8bb7d0
authored
Jul 21, 2020
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for applyTableSub
parent
09c048cc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
4 deletions
+28
-4
DbQueryHelperTest.php
qa-tests/src/Database/DbQueryHelperTest.php
+28
-4
No files found.
qa-tests/src/Database/DbQueryHelperTest.php
View file @
5d8bb7d0
...
...
@@ -14,12 +14,16 @@ class DbQueryHelperTest extends PHPUnit_Framework_TestCase
public
function
test__expandParameters_success
()
{
$result
=
$this
->
helper
->
expandParameters
(
'SELECT * FROM table WHERE field
=
1'
,
[]);
$expected
=
[
'SELECT * FROM table WHERE field
=
1'
,
[]];
$result
=
$this
->
helper
->
expandParameters
(
'SELECT * FROM table WHERE field
=
1'
,
[]);
$expected
=
[
'SELECT * FROM table WHERE field
=
1'
,
[]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
helper
->
expandParameters
(
'SELECT * FROM table WHERE field = ?'
,
[
1
]);
$expected
=
[
'SELECT * FROM table WHERE field = ?'
,
[
1
]];
$result
=
$this
->
helper
->
expandParameters
(
'SELECT * FROM table WHERE field=?'
,
[
1
]);
$expected
=
[
'SELECT * FROM table WHERE field=?'
,
[
1
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
helper
->
expandParameters
(
'SELECT * FROM table WHERE field=#'
,
[
1
]);
$expected
=
[
'SELECT * FROM table WHERE field=?'
,
[
1
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
helper
->
expandParameters
(
'SELECT * FROM table WHERE field IN (?)'
,
[[
1
]]);
...
...
@@ -52,4 +56,24 @@ class DbQueryHelperTest extends PHPUnit_Framework_TestCase
$this
->
setExpectedException
(
'Q2A\Database\Exceptions\SelectSpecException'
);
$this
->
helper
->
expandParameters
(
'INSERT INTO table(field1, field2) VALUES ?'
,
[[
[
1
,
2
],
[
3
]
]]);
}
public
function
test__applyTableSub
()
{
$result
=
$this
->
helper
->
applyTableSub
(
'SELECT * FROM ^options'
);
$this
->
assertSame
(
'SELECT * FROM qa_options'
,
$result
);
$result
=
$this
->
helper
->
applyTableSub
(
'SELECT * FROM ^users WHERE userid=?'
);
$this
->
assertSame
(
'SELECT * FROM qa_users WHERE userid=?'
,
$result
);
}
public
function
test__applyTableSub_users_prefix
()
{
define
(
'QA_MYSQL_USERS_PREFIX'
,
'base_'
);
$result
=
$this
->
helper
->
applyTableSub
(
'SELECT * FROM ^options'
);
$this
->
assertSame
(
'SELECT * FROM qa_options'
,
$result
);
$result
=
$this
->
helper
->
applyTableSub
(
'SELECT * FROM ^users WHERE userid=?'
);
$this
->
assertSame
(
'SELECT * FROM base_users WHERE userid=?'
,
$result
);
}
}
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