fix unit tests

This commit is contained in:
Dennis Eichhorn 2020-03-25 19:30:48 +01:00
parent 3b13170a01
commit c720655d3f
7 changed files with 16 additions and 19 deletions

View File

@ -17,6 +17,7 @@ namespace phpOMS\DataStorage\Database\Query\Grammar;
use phpOMS\DataStorage\Database\GrammarAbstract; use phpOMS\DataStorage\Database\GrammarAbstract;
use phpOMS\DataStorage\Database\Query\Builder; use phpOMS\DataStorage\Database\Query\Builder;
use phpOMS\DataStorage\Database\Query\Column; use phpOMS\DataStorage\Database\Query\Column;
use phpOMS\DataStorage\Database\Query\From;
use phpOMS\DataStorage\Database\Query\Parameter; use phpOMS\DataStorage\Database\Query\Parameter;
use phpOMS\DataStorage\Database\Query\QueryType; use phpOMS\DataStorage\Database\Query\QueryType;
use phpOMS\DataStorage\Database\Query\Where; use phpOMS\DataStorage\Database\Query\Where;
@ -262,7 +263,7 @@ class Grammar extends GrammarAbstract
if (isset($element['value'])) { if (isset($element['value'])) {
$expression .= ' ' . \strtoupper($element['operator']) . ' ' . $this->compileValue($query, $element['value']); $expression .= ' ' . \strtoupper($element['operator']) . ' ' . $this->compileValue($query, $element['value']);
} elseif (isset($element['value']) && !($element['column'] instanceof Where)) { } elseif ($element['value'] === null && !($element['column'] instanceof Where)) {
$operator = $element['operator'] === '=' ? 'IS' : 'IS NOT'; $operator = $element['operator'] === '=' ? 'IS' : 'IS NOT';
$expression .= ' ' . $operator . ' ' . $this->compileValue($query, $element['value']); $expression .= ' ' . $operator . ' ' . $this->compileValue($query, $element['value']);
} }

View File

@ -304,6 +304,8 @@ $GLOBALS['dbpool']->create('schema', $CONFIG['db']['core']['masters']['schema'])
DataMapperAbstract::setConnection($GLOBALS['dbpool']->get()); DataMapperAbstract::setConnection($GLOBALS['dbpool']->get());
$GLOBALS['frameworkpath'] = '/';
function phpServe(): void function phpServe(): void
{ {
// OS detection // OS detection

View File

@ -386,7 +386,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testPostData() : void public function testPostData() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestPost.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php'));
$request->setMethod(RequestMethod::POST); $request->setMethod(RequestMethod::POST);
$request->getHeader()->set('Content-Type', MimeType::M_POST); $request->getHeader()->set('Content-Type', MimeType::M_POST);
$request->setData('testKey', 'testValue'); $request->setData('testKey', 'testValue');
@ -404,7 +404,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testJsonData() : void public function testJsonData() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestPost.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php'));
$request->setMethod(RequestMethod::POST); $request->setMethod(RequestMethod::POST);
$request->getHeader()->set('Content-Type', MimeType::M_JSON); $request->getHeader()->set('Content-Type', MimeType::M_JSON);
$request->setData('testKey', 'testValue'); $request->setData('testKey', 'testValue');
@ -422,7 +422,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testMultipartData() : void public function testMultipartData() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestPost.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestPost.php'));
$request->setMethod(RequestMethod::POST); $request->setMethod(RequestMethod::POST);
$request->getHeader()->set('Content-Type', MimeType::M_MULT); $request->getHeader()->set('Content-Type', MimeType::M_MULT);
$request->setData('testKey', 'testValue'); $request->setData('testKey', 'testValue');
@ -440,7 +440,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testLanguage() : void public function testLanguage() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestLanguage.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestLanguage.php'));
$request->setMethod(RequestMethod::GET); $request->setMethod(RequestMethod::GET);
self::assertEquals( self::assertEquals(
@ -456,7 +456,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testLocale() : void public function testLocale() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestLocale.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestLocale.php'));
$request->setMethod(RequestMethod::GET); $request->setMethod(RequestMethod::GET);
self::assertEquals( self::assertEquals(
@ -472,7 +472,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testMobile() : void public function testMobile() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestMobile.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestMobile.php'));
$request->setMethod(RequestMethod::GET); $request->setMethod(RequestMethod::GET);
self::assertEquals( self::assertEquals(
@ -488,7 +488,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testOS() : void public function testOS() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestOS.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestOS.php'));
$request->setMethod(RequestMethod::GET); $request->setMethod(RequestMethod::GET);
self::assertEquals( self::assertEquals(
@ -504,7 +504,7 @@ class HttpRequestTest extends \PHPUnit\Framework\TestCase
*/ */
public function testBrowser() : void public function testBrowser() : void
{ {
$request = new HttpRequest(new HttpUri('http://localhost:1234/phpOMS/tests/Message/Http/HttpRequestBrowser.php')); $request = new HttpRequest(new HttpUri('http://localhost:1234' . $GLOBALS['frameworkpath'] . 'tests/Message/Http/HttpRequestBrowser.php'));
$request->setMethod(RequestMethod::GET); $request->setMethod(RequestMethod::GET);
self::assertEquals( self::assertEquals(

View File

@ -32,7 +32,7 @@ class MarkdownTest extends \PHPUnit\Framework\TestCase
if ($data[1] === 'md' if ($data[1] === 'md'
&& (\file_get_contents(__DIR__ . '/data/' . $data[0] . '.html') !== Markdown::parse(\file_get_contents(__DIR__ . '/data/' . $data[0] . '.md'))) && (\file_get_contents(__DIR__ . '/data/' . $data[0] . '.html') !== Markdown::parse(\file_get_contents(__DIR__ . '/data/' . $data[0] . '.md')))
) { ) {
self::asserTrue(false, $file); self::assertTrue(false, $file);
} }
} }

View File

@ -9,8 +9,6 @@
<p><a href="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p> <p><a href="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><a href="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p> <p><a href="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><a href="data%3A//text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p> <p><a href="data%3A//text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==">xss</a></p>
<p><a href="data?colon;text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=">xss</a></p>
<p><img src="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p> <p><img src="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
<p><img src="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p> <p><img src="data%3Atext/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
<p><img src="data%3A//text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p> <p><img src="data%3A//text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==" alt="xss" /></p>
<p><img src="data?colon;text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg=" alt="xss" /></p>

View File

@ -20,12 +20,8 @@
[xss](data://text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==) [xss](data://text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==)
[xss](data&colon;text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==)
![xss](data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==) ![xss](data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==)
![xss]( data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==) ![xss]( data:text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==)
![xss](data://text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==) ![xss](data://text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==)
![xss](data&colon;text/html;base64,PHNjcmlwdD5hbGVydCgxKTwvc2NyaXB0Pg==)

View File

@ -37,6 +37,6 @@
<php> <php>
<const name="WEB_SERVER_HOST" value="localhost" /> <const name="WEB_SERVER_HOST" value="localhost" />
<const name="WEB_SERVER_PORT" value="1234" /> <const name="WEB_SERVER_PORT" value="1234" />
<const name="WEB_SERVER_DOCROOT" value="./../" /> <const name="WEB_SERVER_DOCROOT" value="./" />
</php> </php>
</phpunit> </phpunit>