Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Stud.IP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan-Hendrik Willms
Stud.IP
Commits
17080324
Commit
17080324
authored
3 years ago
by
Marcus Eibrink-Lunzenauer
Browse files
Options
Downloads
Patches
Plain Diff
remove pdo_sqlite dependency
parent
6531b2db
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
tests/unit/_bootstrap.php
+1
-1
1 addition, 1 deletion
tests/unit/_bootstrap.php
tests/unit/lib/classes/StudipPdoTest.php
+20
-10
20 additions, 10 deletions
tests/unit/lib/classes/StudipPdoTest.php
with
21 additions
and
11 deletions
tests/unit/_bootstrap.php
+
1
−
1
View file @
17080324
...
...
@@ -40,7 +40,7 @@ define("TEST_FIXTURES_PATH", dirname(__DIR__) . "/_data/");
require
__DIR__
.
'/../../composer/autoload.php'
;
global
$STUDIP_BASE_PATH
;
$STUDIP_BASE_PATH
=
realpath
(
dirname
(
dirname
(
__FILE
__
)
)
.
'/..'
);
$STUDIP_BASE_PATH
=
realpath
(
dirname
(
__DIR
__
)
.
'/..'
);
require
'lib/classes/StudipAutoloader.php'
;
require
'lib/functions.php'
;
...
...
This diff is collapsed.
Click to expand it.
tests/unit/lib/classes/StudipPdoTest.php
+
20
−
10
View file @
17080324
<?php
/*
* studip_pdo_test.php - unit tests for the StudipPDO class
*
...
...
@@ -16,7 +17,16 @@ class StudipPdoTest extends \Codeception\Test\Unit
{
public
function
setUp
():
void
{
$this
->
testPdo
=
new
class
(
'sqlite::memory:'
)
extends
StudipPDO
{
$dsn
=
'mysql:host='
.
$GLOBALS
[
'DB_STUDIP_HOST'
]
.
';dbname='
.
$GLOBALS
[
'DB_STUDIP_DATABASE'
]
.
';charset=utf8mb4'
;
$username
=
$GLOBALS
[
'DB_STUDIP_USER'
];
$password
=
$GLOBALS
[
'DB_STUDIP_PASSWORD'
];
$this
->
testPdo
=
new
class
(
$dsn
,
$username
,
$password
)
extends
StudipPDO
{
public
static
function
doReplaceStrings
(
$statement
)
{
return
parent
::
replaceStrings
(
$statement
);
...
...
@@ -33,7 +43,7 @@ class StudipPdoTest extends \Codeception\Test\Unit
public
function
testSimpleString
()
{
$query
=
'SELECT * FROM bar'
;
$query
=
'SELECT * FROM bar'
;
$expect
=
$query
;
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
...
...
@@ -41,12 +51,12 @@ class StudipPdoTest extends \Codeception\Test\Unit
public
function
testDoubleQuotedString
()
{
$query
=
'SELECT "\'foo""\\"" FROM bar WHERE foo = "\\\\"'
;
$query
=
'SELECT "\'foo""\\"" FROM bar WHERE foo = "\\\\"'
;
$expect
=
'SELECT ? FROM bar WHERE foo = ?'
;
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
$query
=
str_repeat
(
$query
,
100
);
$query
=
str_repeat
(
$query
,
100
);
$expect
=
str_repeat
(
$expect
,
100
);
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
...
...
@@ -54,12 +64,12 @@ class StudipPdoTest extends \Codeception\Test\Unit
public
function
testSingleQuotedString
()
{
$query
=
'SELECT \'"foo\'\'\\\'\' FROM bar WHERE foo = \'\\\\\''
;
$query
=
'SELECT \'"foo\'\'\\\'\' FROM bar WHERE foo = \'\\\\\''
;
$expect
=
'SELECT ? FROM bar WHERE foo = ?'
;
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
$query
=
str_repeat
(
$query
,
100
);
$query
=
str_repeat
(
$query
,
100
);
$expect
=
str_repeat
(
$expect
,
100
);
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
...
...
@@ -67,12 +77,12 @@ class StudipPdoTest extends \Codeception\Test\Unit
public
function
testMixedQuotedString
()
{
$query
=
'SELECT """\'", \'"\' FROM bar WHERE foo IN (\'\'\'"\'"")'
;
$query
=
'SELECT """\'", \'"\' FROM bar WHERE foo IN (\'\'\'"\'"")'
;
$expect
=
'SELECT ?, ? FROM bar WHERE foo IN (??)'
;
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
$query
=
str_repeat
(
$query
,
100
);
$query
=
str_repeat
(
$query
,
100
);
$expect
=
str_repeat
(
$expect
,
100
);
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
...
...
@@ -80,7 +90,7 @@ class StudipPdoTest extends \Codeception\Test\Unit
public
function
testUnterminatedSingleQuote
()
{
$query
=
'SELECT \'1\' ORDER BY \'au.username asc'
;
$query
=
'SELECT \'1\' ORDER BY \'au.username asc'
;
$expect
=
'SELECT ? ORDER BY \'au.username asc'
;
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
...
...
@@ -88,7 +98,7 @@ class StudipPdoTest extends \Codeception\Test\Unit
public
function
testUnterminatedDoubleQuote
()
{
$query
=
'SELECT "1" ORDER BY "au.username asc'
;
$query
=
'SELECT "1" ORDER BY "au.username asc'
;
$expect
=
'SELECT ? ORDER BY "au.username asc'
;
$this
->
assertEquals
(
$expect
,
$this
->
testPdo
::
doReplaceStrings
(
$query
));
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment