File tree 4 files changed +103
-2
lines changed
4 files changed +103
-2
lines changed Original file line number Diff line number Diff line change @@ -216,4 +216,10 @@ pip-log.txt
216
216
.mr.developer.cfg
217
217
218
218
# php-cs-fixer
219
- /.php_cs
219
+ /.php_cs
220
+
221
+ # PHPUnit
222
+ /.phpunit.cache
223
+
224
+ /composer.lock
225
+ /vendor
Original file line number Diff line number Diff line change 16
16
"php" : " >=5.4" ,
17
17
"ext-pdo" : " *"
18
18
},
19
+ "require-dev" : {
20
+ "phpunit/phpunit" : " ^9.0"
21
+ },
19
22
"suggest" : {
20
23
"ext-pdo_mysql" : " For MySQL or MariaDB database" ,
21
24
"ext-pdo_sqlsrv" : " For MSSQL database on both Window/Liunx platform" ,
27
30
},
28
31
"autoload" : {
29
32
"psr-4" : {
30
- "Medoo\\ " : " / src"
33
+ "Medoo\\ " : " src/ "
31
34
}
35
+ },
36
+ "autoload-dev" : {
37
+ "psr-4" : {
38
+ "Medoo\\ Tests\\ " : " tests/"
39
+ }
40
+ },
41
+ "scripts" : {
42
+ "test" : " phpunit"
32
43
}
33
44
}
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/9.5/phpunit.xsd"
4
+ bootstrap =" vendor/autoload.php"
5
+ cacheResultFile =" .phpunit.cache/test-results"
6
+ executionOrder =" depends,defects"
7
+ failOnRisky =" true"
8
+ failOnWarning =" true"
9
+ verbose =" true" >
10
+ <testsuites >
11
+ <testsuite name =" Medoo Test Suite" >
12
+ <directory suffix =" Test.php" >./tests</directory >
13
+ </testsuite >
14
+ </testsuites >
15
+
16
+ <coverage cacheDirectory =" .phpunit.cache/code-coverage"
17
+ processUncoveredFiles =" true" >
18
+ <include >
19
+ <directory suffix =" .php" >src</directory >
20
+ </include >
21
+ </coverage >
22
+ </phpunit >
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Medoo \Tests ;
4
+
5
+ use Medoo \Medoo ;
6
+ use PHPUnit \Framework \TestCase ;
7
+
8
+ class MedooTestCase extends TestCase
9
+ {
10
+ protected Medoo $ database ;
11
+
12
+ public function setUp () : void
13
+ {
14
+ $ this ->database = new Medoo ([
15
+ 'testMode ' => true
16
+ ]);
17
+ }
18
+
19
+ public function typesProvider (): array
20
+ {
21
+ return [
22
+ 'MySQL ' => ['mysql ' ],
23
+ 'MSSQL ' => ['mssql ' ],
24
+ 'SQLite ' => ['sqlite ' ],
25
+ 'PostgreSQL ' => ['pgsql ' ],
26
+ 'Oracle ' => ['oracle ' ]
27
+ ];
28
+ }
29
+
30
+ public function setType ($ type ) : void
31
+ {
32
+ $ this ->database ->type = $ type ;
33
+ }
34
+
35
+ public function expectedQuery ($ expected ) : string
36
+ {
37
+ $ identifier = [
38
+ 'mysql ' => '`$1` ' ,
39
+ 'mssql ' => '[$1] '
40
+ ];
41
+
42
+ return preg_replace (
43
+ '/"((?![_\d])[\p{N}\p{L}_]+)"/u ' ,
44
+ $ identifier [$ this ->database ->type ] ?? '"$1" ' ,
45
+ $ expected
46
+ );
47
+ }
48
+
49
+ public function assertQuery ($ expected , $ query ) : void
50
+ {
51
+ if (is_array ($ expected )) {
52
+
53
+ $ this ->assertEquals (
54
+ $ this ->expectedQuery ($ expected [$ this ->database ->type ] ?? $ expected ['default ' ]),
55
+ $ query
56
+ );
57
+ }
58
+ else {
59
+ $ this ->assertEquals ($ this ->expectedQuery ($ expected ), $ query );
60
+ }
61
+ }
62
+ }
You can’t perform that action at this time.
0 commit comments