From faec5d218b5a6f96e5029ed685706e1fd6232968 Mon Sep 17 00:00:00 2001 From: Carsten Rose <carsten.rose@math.uzh.ch> Date: Fri, 13 May 2016 15:57:52 +0200 Subject: [PATCH] AbstractDatabaseTest.php: source reformatted BuildFormPlainTest.php: fixed issue with double declared class FakeTSFE. ReportTest.php: initially created. --- .../tests/phpunit/AbstractDatabaseTest.php | 3 + .../qfq/tests/phpunit/BuildFormPlainTest.php | 4 +- extension/qfq/tests/phpunit/ReportTest.php | 62 +++++++++++++++++++ 3 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 extension/qfq/tests/phpunit/ReportTest.php diff --git a/extension/qfq/tests/phpunit/AbstractDatabaseTest.php b/extension/qfq/tests/phpunit/AbstractDatabaseTest.php index 07d2dc72b..cf71c6ffc 100644 --- a/extension/qfq/tests/phpunit/AbstractDatabaseTest.php +++ b/extension/qfq/tests/phpunit/AbstractDatabaseTest.php @@ -16,14 +16,17 @@ require_once(__DIR__ . '/../../qfq/store/Store.php'); * Class AbstractDatabaseTest */ abstract class AbstractDatabaseTest extends PHPUnit_Framework_TestCase { + /** * @var null */ static protected $mysqli = null; + /** * @var qfq\Database */ protected $db = null; + /* * @var qfq\Store */ diff --git a/extension/qfq/tests/phpunit/BuildFormPlainTest.php b/extension/qfq/tests/phpunit/BuildFormPlainTest.php index 1b6d4dc26..ca0614523 100644 --- a/extension/qfq/tests/phpunit/BuildFormPlainTest.php +++ b/extension/qfq/tests/phpunit/BuildFormPlainTest.php @@ -360,7 +360,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest { $this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true); // $this->executeSQLFile(__DIR__ . '/fixtures/TestFormEditor.sql', true); - $GLOBALS["TSFE"] = new FakeTSFE(); + $GLOBALS["TSFE"] = new FakeTSFEBuildPlain(); // $this->form = new \qfq\QuickFormQuery(['bodytext' => "form=form\nr=3", 'uid' => 1234], true); $form = new \qfq\QuickFormQuery(['bodytext' => "form=form\nr=3", 'uid' => 1234], true); @@ -371,7 +371,7 @@ class BuildFormPlainTest extends AbstractDatabaseTest { } } -class FakeTSFE { +class FakeTSFEBuildPlain { public $id = 1; public $type = 1; public $sys_language_uid = 1; diff --git a/extension/qfq/tests/phpunit/ReportTest.php b/extension/qfq/tests/phpunit/ReportTest.php new file mode 100644 index 000000000..f3579935b --- /dev/null +++ b/extension/qfq/tests/phpunit/ReportTest.php @@ -0,0 +1,62 @@ +<?php + +//namespace qfq; + +//use qfq; + +require_once(__DIR__ . '/AbstractDatabaseTest.php'); +require_once(__DIR__ . '/../../qfq/report/Report.php'); +require_once(__DIR__ . '/../../qfq/store/Store.php'); +require_once(__DIR__ . '/../../qfq/Evaluate.php'); + +/** + * Created by PhpStorm. + * User: crose + * Date: 2/2/16 + * Time: 10:07 PM + */ +class ReportTest extends AbstractDatabaseTest { + + /** + * @var Evaluate + */ + private $eval = null; + + /** + * @var Report + */ + private $report = null; + + /** + * + */ + public function testReportHead() { + + $bodyText = '10.head = Hello world'; + + $result = $this->report->process($bodyText); + + $this->assertEquals('', $result); + } + + /** + * @throws Exception + */ + protected function setUp() { + + parent::setUp(); + $GLOBALS["TSFE"] = new FakeTSFEReport(); + $this->eval = new qfq\Evaluate($this->store, $this->db); + $this->report = new qfq\Report(array(), $this->store->getVar(SYSTEM_SESSION_NAME, STORE_SYSTEM), $this->eval, true); + + $this->executeSQLFile(__DIR__ . '/fixtures/Generic.sql', true); + } + +} + + +class FakeTSFEReport { + public $id = 1; + public $type = 1; + public $sys_language_uid = 1; +} -- GitLab