parent
f3d5343de6
commit
7712955de7
@ -0,0 +1,44 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
namespace UnitTestFiles\Test; |
||||
use PHPUnit\Framework\TestCase; |
||||
|
||||
class SQL_Injection_Test extends TestCase { |
||||
|
||||
/** |
||||
* @dataProvider dataProviderForTest |
||||
*/ |
||||
public function testException($a) { |
||||
$this->expectException(\Exception::class); |
||||
\tts\safer_sql::get_safer_sql_text($a); |
||||
} |
||||
|
||||
/** |
||||
* @dataProvider safeDataProviderForTest |
||||
*/ |
||||
public function testSafeSQL($a) { |
||||
$this->expectNotToPerformAssertions(); |
||||
\tts\safer_sql::get_safer_sql_text($a); |
||||
} |
||||
|
||||
public function dataProviderForTest() { |
||||
return [ |
||||
["admin: {\$ne : ''}"], |
||||
["' or 1=1-- -"], |
||||
["Drop database me;"], |
||||
["' \|\| DELETE 1=1; --"] |
||||
]; |
||||
} |
||||
|
||||
public function safeDataProviderForTest() { |
||||
return [ |
||||
["John walks (down the road)."], |
||||
["Hey, Boy - Good Work!"], |
||||
["I think; I'm good!"] |
||||
]; |
||||
} |
||||
|
||||
|
||||
} |
||||
Loading…
Reference in new issue