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
e5d49898
Commit
e5d49898
authored
Jul 20, 2020
by
Scott
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update expandQueryParameters tests
parent
78b6181b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
19 deletions
+27
-19
DbConnectionTest.php
qa-tests/src/Database/DbConnectionTest.php
+27
-19
No files found.
qa-tests/src/Database/DbConnectionTest.php
View file @
e5d49898
...
@@ -12,36 +12,44 @@ class DbConnectionTest extends PHPUnit_Framework_TestCase
...
@@ -12,36 +12,44 @@ class DbConnectionTest extends PHPUnit_Framework_TestCase
$this
->
dbConnection
=
new
DbConnection
();
$this
->
dbConnection
=
new
DbConnection
();
}
}
public
function
test__
applyArraySub
_success
()
public
function
test__
expandQueryParameters
_success
()
{
{
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field = 1'
,
array
());
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'SELECT * FROM table WHERE field = 1'
,
[]);
$this
->
assertSame
(
'SELECT * FROM table WHERE field = 1'
,
$result
);
$expected
=
[
'SELECT * FROM table WHERE field = 1'
,
[]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field = ?'
,
array
(
1
));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'SELECT * FROM table WHERE field = ?'
,
[
1
]);
$this
->
assertSame
(
'SELECT * FROM table WHERE field = ?'
,
$result
);
$expected
=
[
'SELECT * FROM table WHERE field = ?'
,
[
1
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field IN (?)'
,
array
(
array
(
1
)));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'SELECT * FROM table WHERE field IN (?)'
,
[[
1
]]);
$this
->
assertSame
(
'SELECT * FROM table WHERE field IN (?)'
,
$result
);
$expected
=
[
'SELECT * FROM table WHERE field IN (?)'
,
[
1
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field IN (?)'
,
array
(
array
(
1
,
2
)));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'SELECT * FROM table WHERE field IN (?)'
,
[[
1
,
2
]]);
$this
->
assertSame
(
'SELECT * FROM table WHERE field IN (?, ?)'
,
$result
);
$expected
=
[
'SELECT * FROM table WHERE field IN (?, ?)'
,
[
1
,
2
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field) VALUES ?'
,
array
(
array
(
array
(
1
))));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'INSERT INTO table(field) VALUES ?'
,
[[
[
1
]
]]);
$this
->
assertSame
(
'INSERT INTO table(field) VALUES (?)'
,
$result
);
$expected
=
[
'INSERT INTO table(field) VALUES (?)'
,
[
1
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field) VALUES ?'
,
array
(
array
(
array
(
1
),
array
(
2
))));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'INSERT INTO table(field) VALUES ?'
,
[[
[
1
],
[
2
]
]]);
$this
->
assertSame
(
'INSERT INTO table(field) VALUES (?), (?)'
,
$result
);
$expected
=
[
'INSERT INTO table(field) VALUES (?), (?)'
,
[
1
,
2
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field1, field2) VALUES ?'
,
array
(
array
(
array
(
1
,
2
))));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'INSERT INTO table(field1, field2) VALUES ?'
,
[[
[
1
,
2
]
]]);
$this
->
assertSame
(
'INSERT INTO table(field1, field2) VALUES (?, ?)'
,
$result
);
$expected
=
[
'INSERT INTO table(field1, field2) VALUES (?, ?)'
,
[
1
,
2
]];
$this
->
assertSame
(
$expected
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field1, field2) VALUES ?'
,
array
(
array
(
array
(
1
,
2
),
array
(
3
,
4
))));
$result
=
$this
->
dbConnection
->
expandQueryParameters
(
'INSERT INTO table(field1, field2) VALUES ?'
,
[[
[
1
,
2
],
[
3
,
4
]
]]);
$this
->
assertSame
(
'INSERT INTO table(field1, field2) VALUES (?, ?), (?, ?)'
,
$result
);
$expected
=
[
'INSERT INTO table(field1, field2) VALUES (?, ?), (?, ?)'
,
[
1
,
2
,
3
,
4
]];
$this
->
assertSame
(
$expected
,
$result
);
}
}
public
function
test__
applyArraySub_parameter_groups_with_different_element_count
_error
()
public
function
test__
expandQueryParameters_incorrect_groups
_error
()
{
{
$this
->
setExpectedException
(
'Q2A\Database\Exceptions\SelectSpecException'
);
$this
->
setExpectedException
(
'Q2A\Database\Exceptions\SelectSpecException'
);
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field1, field2) VALUES ?'
,
array
(
array
(
array
(
1
,
2
),
array
(
3
)))
);
$this
->
dbConnection
->
expandQueryParameters
(
'INSERT INTO table(field1, field2) VALUES ?'
,
[[
[
1
,
2
],
[
3
]
]]
);
}
}
}
}
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