Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
PHP-MySQLi-Database-Class
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Kulya
PHP-MySQLi-Database-Class
Commits
a3f111b8
Commit
a3f111b8
authored
Feb 10, 2015
by
Alexander Butenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update tests
parent
ed4594a9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
3 deletions
+40
-3
tests.php
tests.php
+40
-3
No files found.
tests.php
View file @
a3f111b8
...
...
@@ -93,12 +93,13 @@ function createTable ($name, $data) {
$db
->
rawQuery
(
$q
);
}
// rawQuery test
foreach
(
$tables
as
$name
=>
$fields
)
{
$db
->
rawQuery
(
"DROP TABLE "
.
$prefix
.
$name
);
createTable
(
$prefix
.
$name
,
$fields
);
}
// insert test with autoincrement
foreach
(
$data
as
$name
=>
$datas
)
{
foreach
(
$datas
as
$d
)
{
$id
=
$db
->
insert
(
$name
,
$d
);
...
...
@@ -106,16 +107,48 @@ foreach ($data as $name => $datas) {
$d
[
'id'
]
=
$id
;
else
{
echo
"failed to insert: "
.
$db
->
getLastQuery
()
.
"
\n
"
.
$db
->
getLastError
();
exit
;
}
}
}
// bad insert test
$badUser
=
Array
(
'login'
=>
null
,
'customerId'
=>
10
,
'firstName'
=>
'John'
,
'lastName'
=>
'Doe'
,
'password'
=>
'test'
,
'createdAt'
=>
$db
->
now
(),
'expires'
=>
$db
->
now
(
'+1Y'
),
'loginCount'
=>
$db
->
inc
()
);
$id
=
$db
->
insert
(
"users"
,
$badUser
);
if
(
$id
)
{
echo
"bad insert test failed"
;
exit
;
}
// insert without autoincrement
$q
=
"create table
{
$prefix
}
test (id int(10), name varchar(10));"
;
$db
->
rawQuery
(
$q
);
$id
=
$db
->
insert
(
"test"
,
Array
(
"id"
=>
1
,
"name"
=>
"testname"
));
if
(
!
$id
)
{
echo
"insert without autoincrement failed"
;
exit
;
}
$db
->
get
(
"test"
);
if
(
$db
->
count
!=
1
)
{
echo
"insert without autoincrement failed -- wrong insert count"
;
exit
;
}
$db
->
orderBy
(
"id"
,
"asc"
);
$users
=
$db
->
get
(
"users"
);
if
(
$db
->
count
!=
3
)
{
echo
"Invalid total insert count"
;
exit
;
}
$db
->
where
(
"active"
,
true
);
$users
=
$db
->
get
(
"users"
);
if
(
$db
->
count
!=
1
)
{
...
...
@@ -246,8 +279,8 @@ $usersQ->getOne ("users", "id");
$db2
=
$db
->
copy
();
$db2
->
where
(
"userId"
,
$usersQ
);
$
res
=
$db2
->
getOne
(
"products"
,
"count(id) as cnt
"
);
if
(
$
res
[
'cnt'
]
!=
2
)
{
$
cnt
=
$db2
->
getValue
(
"products"
,
"count(id)
"
);
if
(
$
cnt
!=
2
)
{
echo
"Invalid select result with subquery"
;
exit
;
}
...
...
@@ -259,6 +292,10 @@ if ($db->count != 0) {
exit
;
}
$db
->
delete
(
"products"
);
$q
=
"drop table
{
$prefix
}
test;"
;
$db
->
rawQuery
(
$q
);
echo
"All done"
;
//print_r($db->rawQuery("CALL simpleproc(?)",Array("test")));
...
...
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