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
006e3a11
Commit
006e3a11
authored
Jan 31, 2019
by
pupi1985
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add DBConnection tests
parent
57618205
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
0 deletions
+47
-0
DbConnectionTest.php
qa-tests/src/Database/DbConnectionTest.php
+47
-0
No files found.
qa-tests/src/Database/DbConnectionTest.php
0 → 100644
View file @
006e3a11
<?php
use
Q2A\Database\DbConnection
;
class
DbConnectionTest
extends
PHPUnit_Framework_TestCase
{
/** @var DbConnection */
private
$dbConnection
;
protected
function
setUp
()
{
$this
->
dbConnection
=
new
DbConnection
();
}
public
function
test__applyArraySub_success
()
{
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field = 1'
,
array
());
$this
->
assertSame
(
'SELECT * FROM table WHERE field = 1'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field = ?'
,
array
(
1
));
$this
->
assertSame
(
'SELECT * FROM table WHERE field = ?'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field IN (?)'
,
array
(
array
(
1
)));
$this
->
assertSame
(
'SELECT * FROM table WHERE field IN (?)'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'SELECT * FROM table WHERE field IN (?)'
,
array
(
array
(
1
,
2
)));
$this
->
assertSame
(
'SELECT * FROM table WHERE field IN (?, ?)'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field) VALUES ?'
,
array
(
array
(
array
(
1
))));
$this
->
assertSame
(
'INSERT INTO table(field) VALUES (?)'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field) VALUES ?'
,
array
(
array
(
array
(
1
),
array
(
2
))));
$this
->
assertSame
(
'INSERT INTO table(field) VALUES (?), (?)'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field1, field2) VALUES ?'
,
array
(
array
(
array
(
1
,
2
))));
$this
->
assertSame
(
'INSERT INTO table(field1, field2) VALUES (?, ?)'
,
$result
);
$result
=
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field1, field2) VALUES ?'
,
array
(
array
(
array
(
1
,
2
),
array
(
3
,
4
))));
$this
->
assertSame
(
'INSERT INTO table(field1, field2) VALUES (?, ?), (?, ?)'
,
$result
);
}
public
function
test__applyArraySub_parameter_groups_with_different_element_count_error
()
{
$this
->
setExpectedException
(
'Q2A\Database\Exceptions\SelectSpecException'
);
$this
->
dbConnection
->
applyArraySub
(
'INSERT INTO table(field1, field2) VALUES ?'
,
array
(
array
(
array
(
1
,
2
),
array
(
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