Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pquery
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
pquery
Commits
a6e7de46
Commit
a6e7de46
authored
Dec 10, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Made SQL unit test complete (100% coverage).
parent
3460a986
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
4 deletions
+54
-4
tests/sql.php
tests/sql.php
+54
-4
No files found.
tests/sql.php
View file @
a6e7de46
...
@@ -156,16 +156,66 @@ class pQuerySqlTest extends PHPUnit_Framework_TestCase {
...
@@ -156,16 +156,66 @@ class pQuerySqlTest extends PHPUnit_Framework_TestCase {
$this
->
assertEquals
(
"DELETE FROM `foo` WHERE `bar` = 'test3';"
,
$sql
->
query
);
$this
->
assertEquals
(
"DELETE FROM `foo` WHERE `bar` = 'test3';"
,
$sql
->
query
);
}
}
/**
function
test_fetch_assoc
()
{
* @depends test_select_query
$sql
=
_sql
(
"select bar from foo where id = 1"
);
*/
$result
=
$sql
->
fetch
(
'assoc'
);
function
test_select
()
{
$this
->
assertEquals
(
array
(
'bar'
=>
'test1'
),
$result
);
$this
->
assertFalse
(
$sql
->
fetch
());
}
function
test_fetch_array
()
{
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$result
=
$sql
->
fetch
(
'array'
);
$this
->
assertEquals
(
array
(
0
=>
'test1'
,
'bar'
=>
'test1'
),
$result
);
$this
->
assertFalse
(
$sql
->
fetch
());
}
function
test_fetch_object
()
{
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$result
=
$sql
->
fetch
(
'object'
);
$result
=
$sql
->
fetch
(
'object'
);
$this
->
assertEquals
(
'test1'
,
$result
->
bar
);
$this
->
assertEquals
(
'test1'
,
$result
->
bar
);
$this
->
assertFalse
(
$sql
->
fetch
());
$this
->
assertFalse
(
$sql
->
fetch
());
}
}
/**
* @depends test_fetch_assoc
*/
function
test_fetch_all
()
{
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$results
=
$sql
->
fetch_all
(
'assoc'
);
$this
->
assertEquals
(
array
(
array
(
'bar'
=>
'test1'
)),
$results
);
}
/*
* @depends test_select_query
* @depends test_fetch_assoc
*/
function
test_select_all
()
{
$select
=
__sql
::
select
(
'foo'
,
'*'
,
array
(
'bar'
=>
'test1'
))
->
execute
();
$result
=
$select
->
fetch
(
'assoc'
);
$this
->
assertEquals
(
array
(
'id'
=>
1
,
'bar'
=>
'test1'
),
$result
);
}
/*
* @depends test_select_query
* @depends test_fetch_assoc
*/
function
test_select_single
()
{
$select
=
__sql
::
select
(
'foo'
,
'bar'
,
array
(
'bar'
=>
'test1'
))
->
execute
();
$result
=
$select
->
fetch
(
'assoc'
);
$this
->
assertEquals
(
array
(
'bar'
=>
'test1'
),
$result
);
}
/*
* @depends test_select_query
* @depends test_fetch_assoc
*/
function
test_select_multiple
()
{
$select
=
__sql
::
select
(
'foo'
,
array
(
'id'
,
'bar'
),
array
(
'bar'
=>
'test1'
))
->
execute
();
$result
=
$select
->
fetch
(
'assoc'
);
$this
->
assertEquals
(
array
(
'id'
=>
1
,
'bar'
=>
'test1'
),
$result
);
}
/**
/**
* @depends test_update_query
* @depends test_update_query
*/
*/
...
...
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