Commit 454d7fb3 authored by Carsten  Rose's avatar Carsten Rose
Browse files

Merge branch 'B7455PHPUnitTestsFail' into 'master'

B7455 php unit tests fail

See merge request !117
parents 358a8ad3 0b1e336a
Pipeline #1182 passed with stage
in 1 minute and 34 seconds
......@@ -75,8 +75,7 @@ plantuml:
bootstrap: .npmpackages .plantuml_install .virtual_env
npm update
grunt default
composer update
cd extension/Resources/Private; composer update
cd extension; composer update
basic: .npmpackages .virtual_env
npm update
......
{
"require-dev": {
"phpunit/phpunit": "^6.5"
}
}
{
"require": {
"phpoffice/phpspreadsheet": "^1.3"
}
}
<?php
/**
* Created by PhpStorm.
* User: megger
* Date: 12/17/18
* Time: 12:17 PM
*/
// use autoloader of composer. Directories for autoload specified in composer.json -> autoload
require_once(__DIR__ . '/../vendor/autoload.php');
require_once(__DIR__ . '/core/Constants.php');
\ No newline at end of file
......@@ -264,7 +264,7 @@ class Sanitize {
public static function digitCheckAndCleanGet($key) {
if (isset($_GET[$key]) && !ctype_digit($_GET[$key])) {
if (ctype_digit($_GET[$key][0])) {
if (!empty($_GET[$key]) && ctype_digit($_GET[$key][0])) {
$_GET[$key] = $_GET[$key][0];
} else {
$_GET[$key] = '';
......
......@@ -25,7 +25,7 @@ require_once(__DIR__ . '/../helper/HelperFile.php');
require_once(__DIR__ . '/../exceptions/DownloadException.php');
//require_once(__DIR__ . '/../Evaluate.php');
//require_once(__DIR__ . '/../helper/KeyValueStringParser.php');
require __DIR__ . '/../../../Resources/Private/vendor/autoload.php';
require __DIR__ . '/../../../vendor/autoload.php';
use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
......
#!/bin/bash
function help_message() {
cat <<EOF
`basename $0` -p <phpunitphar> -t <testdirectory> -m <mailto> [-h]
EOF
}
while getopts p:t:m:h name
do
case "$name" in
h)
help_message
exit 0
;;
p)
PHPUNITPHAR=$OPTARG
;;
t)
TESTPATH=$OPTARG
;;
m)
MAILTO=$OPTARG
;;
esac
done
if [ -z "$PHPUNITPHAR" -o -z "$TESTPATH" -o -z "$MAILTO" ]
then
help_message
exit 1
fi
PHPUNITOUTPUT=`php $PHPUNITPHAR "$TESTPATH/phpunit" 2>&1`
if [ $? -ne 0 ]; then
echo "$PHPUNITOUTPUT" | mailx -s 'QFQ PHPUnit Tests Failed' $MAILTO
fi
# if type phantomjs >/dev/null 2>&1
# then
# phantomjs "$TESTPATH/phantom.js"
# if [ -f /tmp/phantomjs.png ]
# then
# mailx -s 'PhantomJS freaked' -a /tmp/phantomjs.png $MAILTO && rm -f /tmp/phantomjs.png
# fi
# fi
......@@ -7,15 +7,9 @@
*/
namespace qfq;
//use qfq;
require_once(__DIR__ . '/../../core/BodytextParser.php');
require_once(__DIR__ . '/../../core/exceptions/UserFormException.php');
use PHPUnit\Framework\TestCase;
//class BodytextParserTest extends \PHPUnit_Framework_TestCase {
/**
* Class BodytextParserTest
* @package qfq
......
......@@ -3,11 +3,9 @@
* @author Carsten Rose <carsten.rose@math.uzh.ch>
*/
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../../core/exceptions/DbException.php');
require_once(__DIR__ . '/../../core/QuickFormQuery.php');
require_once(__DIR__ . '/../../core/helper/Support.php');
namespace qfq;
require_once(__DIR__ . '/database/AbstractDatabaseTest.php');
/**
* Class BuildFormPlainTest
......@@ -446,7 +444,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// _id: 1, name: Doe, link
$formElement['sql1'] = $this->dbArray[DB_INDEX_DEFAULT]->sql('SELECT id AS "_id", name, CONCAT("s:1|p:form&form=person&r=" , id , "|t:", name) AS "link" FROM Person ORDER BY id LIMIT 2');
$result = $build->buildSubrecord($formElement, 'name:1', '', $json);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th><th></th></tr></thead><tbody><tr class="record" ><td>Doe</td><td><a href="index.php?id=form&s=badcaffee1234" >Doe</a></td></tr><tr class="record" ><td>Smith</td><td><a href="index.php?id=form&s=badcaffee1234" >Smith</a></td></tr></tbody></table>', $result);
$this->assertEquals('<table class="' . SUBRECORD_TABLE_CLASS_DEFAULT . '" ><thead><tr><th>name</th><th></th></tr></thead><tbody><tr class="record" ><td>Doe</td><td><a href="../../../../../../../../../scratch/software/typo3/typo3_src-8.7.20/index.php?id=form&s=badcaffee1234" >Doe</a></td></tr><tr class="record" ><td>Smith</td><td><a href="../../../../../../../../../scratch/software/typo3/typo3_src-8.7.20/index.php?id=form&s=badcaffee1234" >Smith</a></td></tr></tbody></table>', $result);
}
/**
......@@ -529,11 +527,11 @@ class BuildFormPlainTest extends AbstractDatabaseTest {
// Use always the latest (production) FormEditor: played during QuickFormQuery()
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `Form`");
$this->dbArray[DB_INDEX_DEFAULT]->sql("DROP TABLE IF EXISTS `FormElement`");
$this->executeSQLFile(__DIR__ . '/../../sql/formEditor.sql', true);
$this->executeSQLFile(__DIR__ . '/../../../Source/sql/formEditor.sql', true);
$this->store->unsetStore(STORE_ADDITIONAL_FORM_ELEMENTS);
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/fixtures/TestForm.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/TestForm.sql', true);
// Defaults
$this->store->setVar('name', 'varchar(255)', STORE_TABLE_COLUMN_TYPES, true);
......
......@@ -8,14 +8,13 @@
namespace qfq;
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/../../core/Delete.php');
require_once(__DIR__ . '/database/AbstractDatabaseTest.php');
/**
* Class DeleteTest
* @package qfq
*/
class DeleteTest extends \AbstractDatabaseTest {
class DeleteTest extends AbstractDatabaseTest {
/**
* @expectedException \qfq\CodeException
......@@ -107,7 +106,7 @@ class DeleteTest extends \AbstractDatabaseTest {
$this->store->setVar('form', 'TestFormName', STORE_TYPO3);
$this->store->setVar(SYSTEM_SITE_PATH, '/tmp', STORE_SYSTEM, true);
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
}
}
......@@ -8,18 +8,13 @@
namespace qfq;
use qfq;
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/../../core/Evaluate.php');
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../../core/store/Store.php');
require_once(__DIR__ . '/database/AbstractDatabaseTest.php');
/**
* Class EvaluateTest
* @package qfq
*/
class EvaluateTest extends \AbstractDatabaseTest {
class EvaluateTest extends AbstractDatabaseTest {
public function testVars() {
$eval = new \qfq\Evaluate($this->store, $this->dbArray[DB_INDEX_DEFAULT]);
......@@ -389,7 +384,7 @@ class EvaluateTest extends \AbstractDatabaseTest {
parent::setUp();
$this->store->setVar('form', 'TestFormName', STORE_TYPO3);
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
}
}
......@@ -7,16 +7,10 @@
* Time: 7:11 PM
*/
require_once(__DIR__ . '/../../core/Constants.php');
require_once(__DIR__ . '/../../core/QuickFormQuery.php');
require_once(__DIR__ . '/../../core/store/Store.php');
require_once(__DIR__ . '/../../core/store/Sip.php');
namespace qfq;
use PHPUnit\Framework\TestCase;
//class QuickFormQueryTest extends \PHPUnit_Framework_TestCase {
/**
* Class QuickFormQueryTest
*/
......@@ -26,7 +20,7 @@ class QuickFormQueryTest extends TestCase {
public function testProcess() {
$form = new qfq\QuickFormQuery(['bodytext' => "\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n"]);
// $form = new QuickFormQuery(['bodytext' => "\n; some comment\n" . TYPO3_FORM . "=testformnameDoNotChange\n"]);
// $this->assertEquals("", $form->process());
}
//
......@@ -54,28 +48,28 @@ class QuickFormQueryTest extends TestCase {
// <empty> bodytext
$t3data[T3DATA_BODYTEXT] = "\n \n \n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$qfq = new QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('', $result);
// form=
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "=\n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$qfq = new QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('', $result);
// form=<formname>
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "=myForm\n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$qfq = new QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('myForm', $result);
// form={{SELECT 'nextForm'}}
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "={{SELECT 'nextForm'}}\n";
$t3data[T3DATA_UID] = "123";
$qfq = new qfq\QuickFormQuery($t3data, true);
$qfq = new QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('nextForm', $result);
......@@ -83,18 +77,18 @@ class QuickFormQueryTest extends TestCase {
$t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "={{form:C:alnumx}}\n";
$t3data[T3DATA_UID] = "123";
$_SERVER['form'] = 'formNameViaGet';
$qfq = new qfq\QuickFormQuery($t3data, true);
$qfq = new QuickFormQuery($t3data, true);
$result = $qfq->getFormName(FORM_LOAD, $foundInStore);
$this->assertEquals('formNameViaGet', $result);
// form={{form}}
// $sip = new qfq\Sip('fakesessionname', true);
// $sip = new Sip('fakesessionname', true);
// $sip->sipUniqId('badcaffee1234');
// $t3data[T3DATA_BODYTEXT] = "\n \n" . TYPO3_FORM . "={{form}}\n";
// $t3data[T3DATA_UID] = "123";
// $_SERVER[CLIENT_SIP]='badcaffee1234';
// $dummy = $sip->queryStringToSip("http://example.com/index.php?id=input&r=1&form=person", RETURN_URL);
// $qfq = new qfq\QuickFormQuery($t3data, true);
// $qfq = new QuickFormQuery($t3data, true);
// $result = $qfq->getFormName(FORM_LOAD, $foundInStore);
// $this->assertEquals('person', $result);
......
......@@ -6,14 +6,9 @@
* Time: 8:47 AM
*/
//namespace qfq;
//
//use qfq\Save;
//use qfq\Database;
namespace qfq;
require_once(__DIR__ . '/../../core/Save.php');
//require_once(__DIR__ . '/../../qfq/Database.php');
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/database/AbstractDatabaseTest.php');
/**
* Class SaveTest
......@@ -22,8 +17,8 @@ class SaveTest extends AbstractDatabaseTest {
public function testUpdateRecord() {
$save = new qfq\Save([F_DB_INDEX => DB_INDEX_DEFAULT], array(), array(), array());
// $db = new qfq\Database();
$save = new Save([F_DB_INDEX => DB_INDEX_DEFAULT], array(), array(), array());
// $db = new Database();
$values = ['name' => 'Doe', 'firstName' => 'John'];
$id = $save->insertRecord('Person', $values);
......@@ -34,14 +29,14 @@ class SaveTest extends AbstractDatabaseTest {
$sql = "SELECT name, firstName FROM Person WHERE id = ? ";
$result = $this->dbArray[DB_INDEX_DEFAULT]->sql($sql, ROW_REGULAR, [$id]);
$this->assertEquals($values, $result[0], array());
$this->assertEquals($values, $result[0]);
}
public function testInsertRecord() {
$save = new qfq\Save([F_DB_INDEX => DB_INDEX_DEFAULT], array(), array(), array());
// $db = new qfq\Database();
$save = new Save([F_DB_INDEX => DB_INDEX_DEFAULT], array(), array(), array());
// $db = new Database();
$values = ['name' => 'Doe', 'firstName' => 'John'];
$id = $save->insertRecord('Person', $values);
......@@ -60,7 +55,7 @@ class SaveTest extends AbstractDatabaseTest {
protected function setUp() {
parent::setUp();
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/database/fixtures/Generic.sql', true);
}
}
......@@ -3,15 +3,7 @@
* @author Carsten Rose <carsten.rose@math.uzh.ch>
*/
//namespace qfq;
use qfq\Store;
//use qfq;
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../../core/store/Store.php');
require_once(__DIR__ . '/../../core/store/Sip.php');
namespace qfq;
use PHPUnit\Framework\TestCase;
......@@ -27,17 +19,17 @@ abstract class AbstractDatabaseTest extends TestCase {
static protected $mysqli = null;
/**
* @var qfq\Database
* @var Database
*/
protected $dbArray = array();
/**
* @var qfq\Store
* @var Store
*/
protected $store = null;
/**
* @var qfq\Sip
* @var Sip
*/
protected $sip = null;
......@@ -68,9 +60,9 @@ abstract class AbstractDatabaseTest extends TestCase {
protected function setUp() {
// Init the store also reads db credential configuration
$this->store = qfq\Store::getInstance('', true);
$this->store = Store::getInstance('', true);
$this->sip = new qfq\Sip(true);
$this->sip = new Sip(true);
$this->sip->sipUniqId('badcaffee1234');
// SWITCH to TestDB
......@@ -82,7 +74,7 @@ abstract class AbstractDatabaseTest extends TestCase {
// $this->store->setVar('DB_1_NAME', $dbNamePhpUnit, STORE_SYSTEM);
$dbName = $this->store->getVar('DB_NAME_TEST', STORE_SYSTEM);
if ($dbName == '') {
throw new \qfq\CodeException('Missing DB_NAME_TEST in ' . CONFIG_QFQ_PHP, ERROR_MISSING_REQUIRED_PARAMETER);
throw new CodeException('Missing DB_NAME_TEST in ' . CONFIG_QFQ_PHP, ERROR_MISSING_REQUIRED_PARAMETER);
} else {
$this->store->setVar('DB_1_NAME', $dbName, STORE_SYSTEM);
}
......@@ -90,12 +82,12 @@ abstract class AbstractDatabaseTest extends TestCase {
$dbIndexData = $this->store->getVar(SYSTEM_DB_INDEX_DATA, STORE_SYSTEM);
$dbIndexQfq = $this->store->getVar(SYSTEM_DB_INDEX_QFQ, STORE_SYSTEM);
if ($dbIndexData != $dbIndexQfq) {
throw new \qfq\CodeException('phpUnit Tests are not prepared for MultiDB tests');
throw new CodeException('phpUnit Tests are not prepared for MultiDB tests');
}
if (empty($this->dbArray)) {
$this->dbArray[DB_INDEX_DEFAULT] = new qfq\Database();
$this->dbArray[DB_INDEX_DEFAULT] = new Database();
}
/// Establish additional mysqli access
......
......@@ -3,9 +3,9 @@
* @author Carsten Rose <carsten.rose@math.uzh.ch>
*/
namespace qfq;
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../../core/exceptions/DbException.php');
/**
* Class DatabaseTest
......
......@@ -6,16 +6,9 @@
* Time: 8:47 AM
*/
//namespace qfq;
//
//use PHPUnit\Framework\TestCase;
//use qfq;
namespace qfq;
require_once(__DIR__ . '/AbstractDatabaseTest.php');
require_once(__DIR__ . '/../../core/form/Dirty.php');
require_once(__DIR__ . '/../../core/store/Sip.php');
require_once(__DIR__ . '/../../core/store/Session.php');
require_once(__DIR__ . '/../../core/database/Database.php');
require_once(__DIR__ . '/../database/AbstractDatabaseTest.php');
/*
* Open to check
......@@ -75,7 +68,7 @@ require_once(__DIR__ . '/../../core/database/Database.php');
/**
* Class DirtyTest
*/
class DirtyTest extends \AbstractDatabaseTest {
class DirtyTest extends AbstractDatabaseTest {
/*
* @var \qfq\Sip
......@@ -1042,9 +1035,9 @@ class DirtyTest extends \AbstractDatabaseTest {
parent::setUp();
$this->executeSQLFile(__DIR__ . '/fixtures/TestFormEditor.sql', true);
$this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/fixtures/TestDirty.sql', true);
$this->executeSQLFile(__DIR__ . '/../database/fixtures/TestFormEditor.sql', true);
$this->executeSQLFile(__DIR__ . '/../database/fixtures/Generic.sql', true);
$this->executeSQLFile(__DIR__ . '/../database/fixtures/TestDirty.sql', true);
$this->sip = new \qfq\Sip(true);
$this->sip->sipUniqId('badcaffee1234');
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment