You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
967 B
44 lines
967 B
<?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!"]
|
|
];
|
|
}
|
|
|
|
|
|
} |