Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 15 additions & 8 deletions CommonLogic/Contexts/Scopes/SessionContextScope.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
}

/**
Expand All @@ -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;
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions CommonLogic/Filemanager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions codeception.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
paths:
tests: tests
output: tests/_output
data: tests/_data
support: tests/_support
envs: tests/_envs
actor_suffix: Tester
extensions:
enabled:
- Codeception\Extension\RunFailed
settings:
bootstrap: _bootstrap.php
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Empty file added tests/_data/.gitkeep
Empty file.
2 changes: 2 additions & 0 deletions tests/_output/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
26 changes: 26 additions & 0 deletions tests/_support/AcceptanceTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;

/**
* Define custom actions here
*/
}
26 changes: 26 additions & 0 deletions tests/_support/FunctionalTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class FunctionalTester extends \Codeception\Actor
{
use _generated\FunctionalTesterActions;

/**
* Define custom actions here
*/
}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Acceptance.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Acceptance extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Functional.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Functional extends \Codeception\Module
{

}
10 changes: 10 additions & 0 deletions tests/_support/Helper/Unit.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php
namespace Helper;

// here you can define custom actions
// all public methods declared in helper class will be available in $I

class Unit extends \Codeception\Module
{

}
26 changes: 26 additions & 0 deletions tests/_support/UnitTester.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php


/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class UnitTester extends \Codeception\Actor
{
use _generated\UnitTesterActions;

/**
* Define custom actions here
*/
}
2 changes: 2 additions & 0 deletions tests/_support/_generated/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
12 changes: 12 additions & 0 deletions tests/acceptance.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Codeception Test Suite Configuration
#
# Suite for acceptance tests.
# Perform tests in browser using the WebDriver or PhpBrowser.
# If you need both WebDriver and PHPBrowser tests - create a separate suite.

actor: AcceptanceTester
modules:
enabled:
- PhpBrowser:
url: http://localhost/myapp
- \Helper\Acceptance
12 changes: 12 additions & 0 deletions tests/functional.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Codeception Test Suite Configuration
#
# Suite for functional tests
# Emulate web requests and make application process them
# Include one of framework modules (Symfony2, Yii2, Laravel5) to use it
# Remove this suite if you don't use frameworks

actor: FunctionalTester
modules:
enabled:
# add a framework module here
- \Helper\Functional
9 changes: 9 additions & 0 deletions tests/unit.suite.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Codeception Test Suite Configuration
#
# Suite for unit or integration tests.

actor: UnitTester
modules:
enabled:
- Asserts
- \Helper\Unit
60 changes: 60 additions & 0 deletions tests/unit/DateTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
use exface\Core\Formulas\Date;
use exface\Core\CommonLogic\Selectors\FormulaSelector;

class DateTest extends \Codeception\Test\Unit
{

private $date;

const TEST_DATE = '2018-01-11';

const TEST_FORMAT = 'd.m.Y';

protected function _before()
{
global $exface;
$this->date = new Date(new FormulaSelector($exface, 'exface.Core.Date'));
}

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 testFormatDateFromEmptyDate()
{
$formattedDate = $this->date->formatDate('', self::TEST_FORMAT);
$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('2018-13-12', self::TEST_FORMAT);
$this->assertEquals('2018-13-12', $formattedDate);
}

public function testRun()
{
$formattedDate = $this->date->run(self::TEST_DATE, self::TEST_FORMAT);
$this->assertEquals('11.01.2018', $formattedDate);
}
}
7 changes: 7 additions & 0 deletions tests/unit/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?php

global $exface;
if (! $exface) {
$exface = new exface\Core\CommonLogic\Workbench();
$exface->start();
}