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
1d53c44e
Commit
1d53c44e
authored
Dec 05, 2011
by
Taddeus Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added unit tests for SQL plugin.
parent
be0b6542
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
1 deletion
+47
-1
test/test_sql.php
test/test_sql.php
+47
-1
No files found.
test/test_sql.php
View file @
1d53c44e
<?php
__p
::
load_plugin
(
'sql'
);
include
'../../debug.php'
;
class
pQuerySqlTest
extends
UnitTestCase
{
function
__construct
()
{
parent
::
__construct
(
'pQuery MySQL plugin'
);
}
function
test_
()
{
function
setUp
()
{
__sql
::
set_login_data
(
'localhost'
,
'root'
,
''
,
'pquery_test'
);
}
function
test_set_login_data
()
{
__sql
::
set_login_data
(
'a'
,
'b'
,
'c'
,
'd'
);
$this
->
assertEqual
(
__sql
::
$login_data
[
'host'
],
'a'
);
$this
->
assertEqual
(
__sql
::
$login_data
[
'username'
],
'b'
);
$this
->
assertEqual
(
__sql
::
$login_data
[
'password'
],
'c'
);
$this
->
assertEqual
(
__sql
::
$login_data
[
'dbname'
],
'd'
);
}
function
test_no_login_data
()
{
$this
->
expectException
(
'pQueryException'
);
__sql
::
$login_data
=
array
();
__sql
::
assert_login_data_exist
();
}
function
test_query_getter
()
{
$sql
=
_sql
(
'foobar'
);
$this
->
assertEqual
(
$sql
->
variable
,
'foobar'
);
$this
->
assertEqual
(
$sql
->
query
,
'foobar'
);
}
function
test_variable_query
()
{
$sql
=
_sql
(
"select id from foo where bar = '[bar]'"
)
->
set
(
array
(
'bar'
=>
'test1'
));
$this
->
assertEqual
(
$sql
->
query
,
"select id from foo where bar = 'test1'"
);
}
function
test_unescaped_query
()
{
$sql
=
_sql
(
"select id from foo where bar = '[bar]'"
)
->
set_unescaped
(
array
(
'bar'
=>
"select id from foo where bar = 'test1'"
));
$this
->
assertEqual
(
$sql
->
query
,
"select id from foo where bar = 'select id from foo where bar = 'test1''"
);
}
function
test_escaped_query
()
{
$sql
=
_sql
(
"select id from foo where bar = '[bar]'"
)
->
set
(
array
(
'bar'
=>
"select id from foo where bar = 'test1'"
));
$this
->
assertNotEqual
(
$sql
->
query
,
"select id from foo where bar = 'select id from foo where bar = 'test1''"
);
}
function
test_select_simple
()
{
$sql
=
_sql
(
"select bar from foo where id = 1"
);
$results
=
$sql
->
fetch_all
(
'object'
);
$this
->
assertEqual
(
$results
[
0
]
->
bar
,
'test1'
);
}
}
...
...
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