From 209e9ac5553b5b149b62b3828e429b733a75b6ad Mon Sep 17 00:00:00 2001 From: Stefan Leupold Date: Thu, 25 Jan 2018 10:41:19 +0100 Subject: [PATCH 1/4] NEW Codeception eingebunden --- Install/Pages/en/exface.core.test.json | 11 +++++ codeception.yml | 10 ++++ tests/_data/.gitkeep | 0 tests/_output/.gitignore | 2 + tests/_support/AcceptanceTester.php | 26 ++++++++++ tests/_support/FunctionalTester.php | 26 ++++++++++ tests/_support/Helper/Acceptance.php | 10 ++++ tests/_support/Helper/Functional.php | 10 ++++ tests/_support/Helper/Unit.php | 10 ++++ tests/_support/UnitTester.php | 26 ++++++++++ tests/_support/_generated/.gitignore | 2 + tests/acceptance.suite.yml | 12 +++++ tests/functional.suite.yml | 12 +++++ tests/unit.suite.yml | 9 ++++ tests/unit/DateTest.php | 66 ++++++++++++++++++++++++++ 15 files changed, 232 insertions(+) create mode 100644 Install/Pages/en/exface.core.test.json create mode 100644 codeception.yml create mode 100644 tests/_data/.gitkeep create mode 100644 tests/_output/.gitignore create mode 100644 tests/_support/AcceptanceTester.php create mode 100644 tests/_support/FunctionalTester.php create mode 100644 tests/_support/Helper/Acceptance.php create mode 100644 tests/_support/Helper/Functional.php create mode 100644 tests/_support/Helper/Unit.php create mode 100644 tests/_support/UnitTester.php create mode 100644 tests/_support/_generated/.gitignore create mode 100644 tests/acceptance.suite.yml create mode 100644 tests/functional.suite.yml create mode 100644 tests/unit.suite.yml create mode 100644 tests/unit/DateTest.php diff --git a/Install/Pages/en/exface.core.test.json b/Install/Pages/en/exface.core.test.json new file mode 100644 index 000000000..ad9882434 --- /dev/null +++ b/Install/Pages/en/exface.core.test.json @@ -0,0 +1,11 @@ +{ + "id": "0x445af28a949d11e79aa3028037ec0200", + "alias_with_namespace": "exface.core.test", + "menu_parent_page_alias": "exface.core.administration", + "menu_index": "3", + "menu_visible": true, + "name": "Test", + "short_description": "", + "replaces_page_alias": null, + "contents": "" +} \ No newline at end of file diff --git a/codeception.yml b/codeception.yml new file mode 100644 index 000000000..f0446cc8a --- /dev/null +++ b/codeception.yml @@ -0,0 +1,10 @@ +paths: + tests: tests + output: tests/_output + data: tests/_data + support: tests/_support + envs: tests/_envs +actor_suffix: Tester +extensions: + enabled: + - Codeception\Extension\RunFailed diff --git a/tests/_data/.gitkeep b/tests/_data/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/tests/_output/.gitignore b/tests/_output/.gitignore new file mode 100644 index 000000000..c96a04f00 --- /dev/null +++ b/tests/_output/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore \ No newline at end of file diff --git a/tests/_support/AcceptanceTester.php b/tests/_support/AcceptanceTester.php new file mode 100644 index 000000000..4c7dcbb6d --- /dev/null +++ b/tests/_support/AcceptanceTester.php @@ -0,0 +1,26 @@ +start(); + $this->date = new Date($exface); + } + + protected function _after() + { + $this->date = null; + } + + public function testFormatDate() + { + $formattedDate = $this->date->formatDate(self::TEST_DATE, self::TEST_FORMAT); + $this->assertEquals('11.01.2018', $formattedDate); + } + + public function testFormatDateFromEmptyFormat() + { + $formattedDate = $this->date->formatDate(self::TEST_DATE, ''); + $this->assertEquals('11.01.2018', $formattedDate); + + $formattedDate = $this->date->formatDate(self::TEST_DATE, null); + $this->assertEquals('11.01.2018', $formattedDate); + } + + public function testFormatDateFromInvalidFormat() + { + $formattedDate = $this->date->formatDate(self::TEST_DATE, 'cy.we.j'); + $this->assertEquals('11.01.2018', $formattedDate); + } + + public function testFormatDateFromEmptyDate() + { + $formattedDate = $this->date->formatDate('', self::TEST_FORMAT); + $this->assertEquals('11.01.2018', $formattedDate); + } + + public function testFormatDateFromInvalidDate() + { + $formattedDate = $this->date->formatDate(null, self::TEST_FORMAT); + $this->assertEquals('11.01.2018', $formattedDate); + } + + public function testRun() + { + $formattedDate = $this->date->run(self::TEST_DATE, self::TEST_FORMAT); + $this->assertEquals('11.01.2018', $formattedDate); + } +} \ No newline at end of file From 30dd0a60e104152f8c606a45160df2456bf36107 Mon Sep 17 00:00:00 2001 From: Stefan Leupold Date: Thu, 1 Feb 2018 09:15:14 +0100 Subject: [PATCH 2/4] NEW Zwischenstand --- codeception.yml | 2 ++ tests/unit/DateTest.php | 21 +++++++-------------- tests/unit/_bootstrap.php | 7 +++++++ 3 files changed, 16 insertions(+), 14 deletions(-) create mode 100644 tests/unit/_bootstrap.php diff --git a/codeception.yml b/codeception.yml index f0446cc8a..4d7027a97 100644 --- a/codeception.yml +++ b/codeception.yml @@ -8,3 +8,5 @@ actor_suffix: Tester extensions: enabled: - Codeception\Extension\RunFailed +settings: + bootstrap: _bootstrap.php diff --git a/tests/unit/DateTest.php b/tests/unit/DateTest.php index ecb1b8704..b02a9ce69 100644 --- a/tests/unit/DateTest.php +++ b/tests/unit/DateTest.php @@ -1,12 +1,9 @@ start(); + global $exface; $this->date = new Date($exface); } @@ -40,22 +36,19 @@ public function testFormatDateFromEmptyFormat() $this->assertEquals('11.01.2018', $formattedDate); } - public function testFormatDateFromInvalidFormat() - { - $formattedDate = $this->date->formatDate(self::TEST_DATE, 'cy.we.j'); - $this->assertEquals('11.01.2018', $formattedDate); - } - public function testFormatDateFromEmptyDate() { $formattedDate = $this->date->formatDate('', self::TEST_FORMAT); - $this->assertEquals('11.01.2018', $formattedDate); + $this->assertEquals((new DateTime())->format(self::TEST_FORMAT), $formattedDate); + + $formattedDate = $this->date->formatDate(null, self::TEST_FORMAT); + $this->assertEquals((new DateTime())->format(self::TEST_FORMAT), $formattedDate); } public function testFormatDateFromInvalidDate() { - $formattedDate = $this->date->formatDate(null, self::TEST_FORMAT); - $this->assertEquals('11.01.2018', $formattedDate); + $formattedDate = $this->date->formatDate('2018-13-12', self::TEST_FORMAT); + $this->assertEquals('2018-13-12', $formattedDate); } public function testRun() diff --git a/tests/unit/_bootstrap.php b/tests/unit/_bootstrap.php new file mode 100644 index 000000000..975858741 --- /dev/null +++ b/tests/unit/_bootstrap.php @@ -0,0 +1,7 @@ +start(); +} From 4dce415d2e0fcab11f0bbda93465370c5cd3dd8c Mon Sep 17 00:00:00 2001 From: Stefan Leupold Date: Thu, 20 Sep 2018 08:53:57 +0200 Subject: [PATCH 3/4] FIX repaired tests --- .../Contexts/Scopes/SessionContextScope.php | 23 ++++++++++++------- CommonLogic/Filemanager.php | 2 ++ composer.json | 3 +++ tests/unit/DateTest.php | 3 ++- 4 files changed, 22 insertions(+), 9 deletions(-) diff --git a/CommonLogic/Contexts/Scopes/SessionContextScope.php b/CommonLogic/Contexts/Scopes/SessionContextScope.php index e4b44ba36..169e01030 100644 --- a/CommonLogic/Contexts/Scopes/SessionContextScope.php +++ b/CommonLogic/Contexts/Scopes/SessionContextScope.php @@ -219,12 +219,10 @@ protected function sessionClose() */ protected function sessionIsOpen() { - if (php_sapi_name() !== 'cli') { - if (version_compare(phpversion(), '5.4.0', '>=')) { - return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; - } else { - return session_id() === '' ? FALSE : TRUE; - } + if (version_compare(phpversion(), '5.4.0', '>=')) { + return session_status() === PHP_SESSION_ACTIVE ? TRUE : FALSE; + } else { + return session_id() === '' ? FALSE : TRUE; } return FALSE; } @@ -236,7 +234,11 @@ protected function sessionIsOpen() */ protected function getSessionContextData() { - return $_SESSION['exface']['contexts']; + if (isset($_SESSION['exface']) && isset($_SESSION['exface']['contexts'])) { + return $_SESSION['exface']['contexts']; + } else { + return null; + } } /** @@ -259,7 +261,12 @@ protected function setSessionContextData($key, $value) */ protected function getSessionData(string $key) { - return $_SESSION['exface'][$key]; + + if (isset($_SESSION['exface']) && isset($_SESSION['exface'][$key])) { + return $_SESSION['exface'][$key]; + } else { + return null; + } } /** diff --git a/CommonLogic/Filemanager.php b/CommonLogic/Filemanager.php index bfb34e3fe..842292925 100644 --- a/CommonLogic/Filemanager.php +++ b/CommonLogic/Filemanager.php @@ -33,6 +33,8 @@ class Filemanager extends Filesystem implements WorkbenchDependantInterface private $path_to_config_folder = null; + private $path_to_translations_folder = null; + private $path_to_user_data_folder = null; private $path_to_backup_folder = null; diff --git a/composer.json b/composer.json index 81577e38b..e4db5e0ff 100644 --- a/composer.json +++ b/composer.json @@ -40,6 +40,9 @@ "kabachello/fileroute": "~0.2", "guzzlehttp/guzzle": "^6.2.2" }, + "require-dev": { + "codeception/codeception": "^2.3" + }, "suggest": { "npm-asset/workbox-sw": "Allows templates to use the tools from the AbstractServiceWorkerTemplate" }, diff --git a/tests/unit/DateTest.php b/tests/unit/DateTest.php index b02a9ce69..6549d87dd 100644 --- a/tests/unit/DateTest.php +++ b/tests/unit/DateTest.php @@ -1,5 +1,6 @@ date = new Date($exface); + $this->date = new Date(new FormulaSelector($exface, 'exface.Core.Date')); } protected function _after() From a263ab2554a7385fe7da1e472154f329b64b366b Mon Sep 17 00:00:00 2001 From: Stefan Leupold Date: Thu, 20 Sep 2018 08:57:49 +0200 Subject: [PATCH 4/4] FIX removed test page --- Install/Pages/en/exface.core.test.json | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Install/Pages/en/exface.core.test.json diff --git a/Install/Pages/en/exface.core.test.json b/Install/Pages/en/exface.core.test.json deleted file mode 100644 index ad9882434..000000000 --- a/Install/Pages/en/exface.core.test.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "id": "0x445af28a949d11e79aa3028037ec0200", - "alias_with_namespace": "exface.core.test", - "menu_parent_page_alias": "exface.core.administration", - "menu_index": "3", - "menu_visible": true, - "name": "Test", - "short_description": "", - "replaces_page_alias": null, - "contents": "" -} \ No newline at end of file