From ba904a93e6d53610284a59022644033f55fde952 Mon Sep 17 00:00:00 2001
From: Dany Rafina
Date: Fri, 13 Jul 2018 13:37:34 +0200
Subject: [PATCH 1/3] - Add travis - Add phpunit xml
---
.travis.yml | 6 +
Core/Base/Http/HttpSession.php | 40 ++++--
Core/Base/Http/MetaBagRequest.php | 1 -
Core/Base/Http/SessionInterfaceRequest.php | 37 +-----
Core/Masters/MasterCore.php | 4 +-
phpunit.xml | 29 ++++
tests/HttpSessionTest.php | 148 ++++++++++++++++++++-
7 files changed, 215 insertions(+), 50 deletions(-)
create mode 100644 .travis.yml
create mode 100644 phpunit.xml
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..a560e34
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,6 @@
+language: php
+php:
+ - '7.2'
+before_script:
+ - composer install
+script: phpunit --configuration phpunit.xml
\ No newline at end of file
diff --git a/Core/Base/Http/HttpSession.php b/Core/Base/Http/HttpSession.php
index 9da8d69..9ead4ee 100755
--- a/Core/Base/Http/HttpSession.php
+++ b/Core/Base/Http/HttpSession.php
@@ -13,6 +13,7 @@
use iumioFramework\Core\Exception\Server\Server500;
use iumioFramework\Core\Requirement\Patterns\Singleton\SingletonClassicPattern;
+use Josantonius\Session\Session;
/**
* HttpSession class.
@@ -27,7 +28,7 @@
class HttpSession extends SingletonClassicPattern implements SessionInterfaceRequest
{
protected $session = null;
-
+ private static $id = null;
/**
* HttpSession constructor.
@@ -41,15 +42,18 @@ public function __construct()
public function start()
{
if (!$this->isStarted() && null === $this->session) {
- $_SESSION = [];
+ //@ob_start();
+
+ session_start();
$this->session = $_SESSION;
+
}
}
/**
* @return mixed
*/
- public function getId()
+ public static function getId()
{
return (session_id());
}
@@ -58,15 +62,16 @@ public function getId()
* @param string $id
* @return mixed
*/
- public function setId($id)
+ public static function setId($id)
{
+ self::$id = $id;
return (session_id($id));
}
/**
* @return mixed
*/
- public function getName()
+ public static function getName()
{
return (session_name());
}
@@ -75,7 +80,7 @@ public function getName()
* @param string $name
* @return mixed
*/
- public function setName($name)
+ public static function setName($name)
{
return (session_name($name));
}
@@ -104,7 +109,7 @@ public function migrate($destroy = false, $lifetime = null)
*/
public function save()
{
- $_SESSION = array_merge($this->session, $_SESSION);
+ $_SESSION = $this->session;
return (0 === count(array_diff($this->session, $_SESSION)))? true : false;
}
@@ -155,11 +160,23 @@ public function all()
/**
* @param array $attributes
- * @return mixed
+ * @return bool|null
+ * @throws Server500
*/
public function replace(array $attributes)
{
- // TODO: Implement replace() method.
+ $status = false;
+ foreach ($this->session as $one => $value) {
+ if (null !== $this->get($one)) {
+ $this->set($one, $value);
+ $status = true;
+ }
+ }
+ if (true === $status) {
+ $this->save();
+ return (true);
+ }
+ return (null);
}
/**
@@ -169,8 +186,8 @@ public function replace(array $attributes)
*/
public function remove($name)
{
- if (isset($_SESSION[$name])) {
- unset($_SESSION[$name]);
+ if (isset($this->session[$name])) {
+ unset($this->session[$name]);
$this->start();
return (true);
} else {
@@ -201,4 +218,5 @@ public function isStarted()
}
return (false);
}
+
}
diff --git a/Core/Base/Http/MetaBagRequest.php b/Core/Base/Http/MetaBagRequest.php
index 302b239..415af2f 100755
--- a/Core/Base/Http/MetaBagRequest.php
+++ b/Core/Base/Http/MetaBagRequest.php
@@ -17,7 +17,6 @@
* Adds metadata to the session.
*
* @author Fabien Potencier
- * @author Dany RAFINA
* @category Framework
* @licence MIT License
* @link https://framework.iumio.com
diff --git a/Core/Base/Http/SessionInterfaceRequest.php b/Core/Base/Http/SessionInterfaceRequest.php
index df16678..d6748f3 100755
--- a/Core/Base/Http/SessionInterfaceRequest.php
+++ b/Core/Base/Http/SessionInterfaceRequest.php
@@ -36,57 +36,28 @@ public function start();
*
* @return string The session ID
*/
- public function getId();
+ public static function getId();
/**
* Sets the session ID.
*
* @param string $id
*/
- public function setId($id);
+ public static function setId($id);
/**
* Returns the session name.
*
* @return mixed The session name
*/
- public function getName();
+ public static function getName();
/**
* Sets the session name.
*
* @param string $name
*/
- public function setName($name);
-
- /**
- * Invalidates the current session.
- *
- * Clears all session attributes and flashes and regenerates the
- * session and deletes the old session from persistence.
- *
- * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value
- * will leave the system settings unchanged, 0 sets the cookie
- * to expire with browser session. Time is in seconds, and is
- * not a Unix timestamp.
- *
- * @return bool True if session invalidated, false if error
- */
- public function invalidate($lifetime = null);
-
- /**
- * Migrates the current session to a new session id while maintaining all
- * session attributes.
- *
- * @param bool $destroy Whether to delete the old session or leave it to garbage collection
- * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value
- * will leave the system settings unchanged, 0 sets the cookie
- * to expire with browser session. Time is in seconds, and is
- * not a Unix timestamp.
- *
- * @return bool True if session migrated, false if error
- */
- public function migrate($destroy = false, $lifetime = null);
+ public static function setName($name);
/**
* Force the session to be saved and closed.
diff --git a/Core/Masters/MasterCore.php b/Core/Masters/MasterCore.php
index c248bfa..f30d000 100755
--- a/Core/Masters/MasterCore.php
+++ b/Core/Masters/MasterCore.php
@@ -24,7 +24,7 @@
use iumioFramework\Core\Requirement\FrameworkServices\GlobalCoreService;
use iumioFramework\Core\Base\Database\DatabaseAccess as IDA;
use iumioFramework\Core\Exception\Server\Server500;
-use iumioFramework\Core\Base\Http\Session\HttpSession;
+use iumioFramework\Core\Base\Http\HttpSession;
use iumioFramework\Core\Base\Json\JsonListener as JL;
/**
@@ -68,7 +68,7 @@ final protected function get(string $component)
return (FrameworkCore::getRuntimeParameters())->query;
break;
case 'session':
- return (new HttpSession());
+ return (HttpSession::getInstance());
break;
case 'service':
return (Services::getInstance());
diff --git a/phpunit.xml b/phpunit.xml
new file mode 100644
index 0000000..abb6b33
--- /dev/null
+++ b/phpunit.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+ tests
+
+
+
+
+
+ .
+
+ Core/Exception/Server/views
+
+
+
+
\ No newline at end of file
diff --git a/tests/HttpSessionTest.php b/tests/HttpSessionTest.php
index f1e209f..518cd48 100644
--- a/tests/HttpSessionTest.php
+++ b/tests/HttpSessionTest.php
@@ -14,7 +14,7 @@
namespace iumioFramework\Tests;
-
+error_reporting(E_ALL);
use iumioFramework\Core\Base\Http\HttpSession;
use PHPUnit\Framework\TestCase;
@@ -24,17 +24,159 @@
*/
class HttpSessionTest extends TestCase
{
+
+ /**
+ * Test if session is started
+ * @throws \Exception
+ */
+ public function testIsStarted()
+ {
+ $instance = HttpSession::getInstance();
+ $this->assertTrue($instance->isStarted());
+ }
+
/**
- * Test create an instance of HttpSession
+ * Test create session item
* @throws \Exception
*/
- public function testCreateInstance()
+ public function testCreate()
{
$instance = HttpSession::getInstance();
$instance->set("test", "value1");
$instance->save();
$this->assertInstanceOf("iumioFramework\Core\Base\Http\HttpSession", $instance);
+ $this->assertNotNull($instance->get("test"));
+ $this->assertEquals($instance->get("test"), "value1");
$this->assertTrue(isset($_SESSION["test"]));
$this->assertEquals($_SESSION["test"], "value1");
}
+
+ /**
+ * Test remove a session item
+ * @throws \Exception
+ */
+ public function testRemove()
+ {
+ $instance = HttpSession::getInstance();
+ $instance->set("test", "value1");
+ $instance->save();
+ $this->assertInstanceOf("iumioFramework\Core\Base\Http\HttpSession", $instance);
+ $this->assertNotNull($instance->get("test"));
+ $this->assertEquals($instance->get("test"), "value1");
+ $instance->remove("test");
+ $instance->save();
+ $this->assertNull($instance->get("test"));
+ $this->assertFalse(isset($_SESSION["test"]));
+ }
+
+ /**
+ * Test if a session item exist
+ * @throws \Exception
+ */
+ public function testHas()
+ {
+ $instance = HttpSession::getInstance();
+ $instance->set("test", "value1");
+ $instance->save();
+ $this->assertTrue($instance->has("test"));
+ $instance->remove("test");
+ $instance->save();
+ $this->assertFalse($instance->has("test"));
+ }
+
+ /**
+ * Test get all session item
+ * @throws \Exception
+ */
+ public function testAll()
+ {
+ $arr = ["test" => "val1", "test2" => "val2", "test3" => "val3"];
+ $instance = HttpSession::getInstance();
+ foreach ($arr as $one => $value) {
+ $instance->set($one, $value);
+ }
+ $instance->save();
+ $all = $instance->all();
+
+ foreach ($arr as $one => $value) {
+ $this->assertTrue(isset($all[$one]));
+ $this->assertEquals($value, $all[$one]);
+ $instance->remove($one);
+ }
+
+ $instance->save();
+ $this->assertEmpty($instance->all());
+ }
+
+ /**
+ * Test set id for a session
+ * @throws \Exception
+ */
+ public function testId()
+ {
+ HttpSession::setId("123");
+ $instance = HttpSession::getInstance();
+ $this->assertEquals("123", session_id());
+ $this->assertEquals("123", $instance->getId());
+ }
+
+ /**
+ * Test destroy a session
+ * @throws \Exception
+ */
+ public function testDestroy()
+ {
+ $instance = HttpSession::getInstance();
+ $this->assertTrue($instance->clear());
+ }
+
+
+ /**
+ * Test set name for session
+ * @throws \Exception
+ */
+ public function testName()
+ {
+ HttpSession::setName("test");
+ $instance = HttpSession::getInstance();
+ $this->assertEquals("test", session_name());
+ $this->assertEquals("test", $instance->getName());
+ }
+
+
+ /**
+ * Test replace a session item
+ * @throws \Exception
+ */
+ public function testReplace()
+ {
+ $arr = ["test" => "val1", "test2" => "val2", "test3" => "val3"];
+ $instance = HttpSession::getInstance();
+ foreach ($arr as $one => $value) {
+ $instance->set($one, $value);
+ }
+ $instance->save();
+ $all = $instance->all();
+
+ foreach ($arr as $one => $value) {
+ $this->assertTrue(isset($all[$one]));
+ $this->assertEquals($value, $all[$one]);
+ }
+
+ $arr = ["test" => "aze", "test2" => "azer", "test3" => "azert"];
+ foreach ($arr as $one => $value) {
+ $instance->set($one, $value);
+ }
+ $instance->save();
+ $all = $instance->all();
+
+ foreach ($arr as $one => $value) {
+ $this->assertTrue(isset($all[$one]));
+ $this->assertEquals($value, $all[$one]);
+ $instance->remove($one);
+ }
+
+ $instance->save();
+ $this->assertEmpty($instance->all());
+ }
}
From b9b177745f25bcaf4abc94f05dc4ddd95429592c Mon Sep 17 00:00:00 2001
From: Dany Rafina
Date: Mon, 23 Jul 2018 10:20:01 +0200
Subject: [PATCH 2/3] - Fix HttpSession bug [CLOSED] - Add units test for
HttpSession [OK] - Up
---
CHANGELOG.md | 19 +-
Core/Base/Http/HttpSession.php | 162 ++++++++++++------
Core/Base/Http/SessionInterfaceRequest.php | 9 +-
.../Environment/FrameworkEnvironment.php | 1 +
Core/Requirement/FrameworkCore.php | 4 +-
.../FrameworkServices/FrameworkTools.php | 2 +-
README.md | 3 +
phpunit.xml | 1 +
tests/HttpSessionTest.php | 24 ++-
9 files changed, 157 insertions(+), 68 deletions(-)
mode change 100755 => 100644 Core/Requirement/Environment/FrameworkEnvironment.php
mode change 100755 => 100644 Core/Requirement/FrameworkCore.php
mode change 100755 => 100644 Core/Requirement/FrameworkServices/FrameworkTools.php
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0345414..a14cf36 100755
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,15 +5,32 @@ All notable changes to this project will be documented in this file.
-iumio Framework, an iumio component[https://www.iumio.com]
+[iumio Framework, an iumio component]
========================================================
@ Let's create more simply
## [STABLE RELEASE]
+## [1.0.2] STS - 2018-07-23
+- Fixed :
+ - HttpSession : Causes by Phpunit PrinterClass
+- Added :
+ - Constant IUMIO_ROOT for root project directory path
+ - Session file on cache directory
+
+
+## [1.0.1] STS - 2018-07-01
+- Fixed :
+ - HttpSession
+
## [1.0.0] STS - 2018-06-01
+- Fixes :
+ - HttpSession
[STABLE RELEASE]: https://github.com/iumio-team/iumio-framework/
[1.0.0]: https://github.com/iumio-team/iumio-framework/releases/tag/v1.0.0
+[1.0.1]: https://github.com/iumio-team/iumio-framework/releases/tag/v1.0.1
+[1.0.2]: https://github.com/iumio-team/iumio-framework/releases/tag/v1.0.2
+[iumio Framework, an iumio component]: https://www.iumio.com
diff --git a/Core/Base/Http/HttpSession.php b/Core/Base/Http/HttpSession.php
index 9ead4ee..6a82cb8 100755
--- a/Core/Base/Http/HttpSession.php
+++ b/Core/Base/Http/HttpSession.php
@@ -13,7 +13,7 @@
use iumioFramework\Core\Exception\Server\Server500;
use iumioFramework\Core\Requirement\Patterns\Singleton\SingletonClassicPattern;
-use Josantonius\Session\Session;
+use iumioFramework\Core\Server\Server;
/**
* HttpSession class.
@@ -27,8 +27,20 @@
*/
class HttpSession extends SingletonClassicPattern implements SessionInterfaceRequest
{
+ /**
+ * @var null|array The session oject : Initialized to null firstly
+ */
protected $session = null;
- private static $id = null;
+
+ /**
+ * @var null|string The session identifier : Initialized to null firstly
+ */
+ private $id = null;
+
+ /**
+ * @var null|string The session name : Initialized to null firstly
+ */
+ private $name = null;
/**
* HttpSession constructor.
@@ -39,49 +51,53 @@ public function __construct()
$this->start();
}
+ /** Start the session
+ * @return void
+ * @throws Server500
+ * @throws \Exception
+ */
public function start()
{
if (!$this->isStarted() && null === $this->session) {
- //@ob_start();
-
+ $this->initSessionConfig();
session_start();
$this->session = $_SESSION;
-
}
}
- /**
- * @return mixed
+ /** Get the session id
+ * @return mixed The session id
*/
- public static function getId()
+ public function getId()
{
- return (session_id());
+ return ($this->id);
}
- /**
- * @param string $id
- * @return mixed
+ /** Set a new session id
+ * @param string $id The session id
+ * @return mixed Return the session id
*/
- public static function setId($id)
+ public function setId($id)
{
- self::$id = $id;
+ $this->id = $id;
return (session_id($id));
}
/**
* @return mixed
*/
- public static function getName()
+ public function getName()
{
- return (session_name());
+ return ($this->name);
}
/**
* @param string $name
* @return mixed
*/
- public static function setName($name)
+ public function setName($name)
{
+ $this->name = $name;
return (session_name($name));
}
@@ -105,27 +121,30 @@ public function migrate($destroy = false, $lifetime = null)
}
/**
- * @return mixed
+ * Save the modification about sessions items
+ * @return bool true if iumio session is the same as PHP SESSION, false for an error
+ * ($_SESSION & $this->session not the same)
*/
- public function save()
+ public function save():bool
{
$_SESSION = $this->session;
return (0 === count(array_diff($this->session, $_SESSION)))? true : false;
}
/**
- * @param string $name
- * @return mixed
+ * Check if a session key exist
+ * @param string $name The session key
+ * @return bool If exist or not
*/
- public function has($name)
+ public function has($name):bool
{
return ((isset($this->session[$name]) && null != $this->session[$name])? true : false);
}
- /**
- * @param string $name
+ /** Get a session key value
+ * @param string $name The session key
* @param mixed|null $default
- * @return mixed
+ * @return mixed The result (if null : not result)
*/
public function get($name, $default = null)
{
@@ -133,9 +152,10 @@ public function get($name, $default = null)
}
/**
- * @param string $name
- * @param mixed $value
- * @return bool
+ * Edit a session key
+ * @param string $name Key name
+ * @param mixed $value session item value
+ * @return bool If session exist or not
* @throws Server500
*/
public function set($name, $value)
@@ -151,19 +171,20 @@ public function set($name, $value)
}
/**
- * @return mixed
+ * Return all session items
+ * @return null|array Null if session are not initialized or an array with all session item
*/
- public function all()
+ public function all():?array
{
return ($this->session);
}
- /**
- * @param array $attributes
- * @return bool|null
+ /** Replace session items
+ * @param array $attributes Session item with key/value
+ * @return bool false if not session item has not edited or true if it has been edited
* @throws Server500
*/
- public function replace(array $attributes)
+ public function replace(array $attributes):bool
{
$status = false;
foreach ($this->session as $one => $value) {
@@ -174,49 +195,86 @@ public function replace(array $attributes)
}
if (true === $status) {
$this->save();
- return (true);
}
- return (null);
+
+ return ($status);
}
- /**
- * @param string $name
+ /** Remove a session item
+ * @param string $name Item name
* @return bool
* @throws Server500
+ * @throws \Exception
*/
- public function remove($name)
+ public function remove($name):bool
{
if (isset($this->session[$name])) {
unset($this->session[$name]);
- $this->start();
+ $this->save();
return (true);
} else {
throw new Server500(new \ArrayObject(array("explain" =>
- "iumio Session Error : Your session name is not defined", "solution" =>
- "Please check the session object with HttpSession::all instruction")));
+ "Session Error : The session name [$name] is not defined", "solution" =>
+ "Please check the session object with HttpSession::all instruction to remove".
+ " the correct session item")));
}
}
/**
- * @return mixed
+ * Clear the session
+ * @return bool If session is clear properly or not
+ * @throws Server500
+ */
+ public function clear():bool
+ {
+ if (true === $this->isStarted()) {
+ session_unset();
+ $this->setToDefault();
+ session_regenerate_id(true);
+ return (empty($_SESSION)? true : false);
+ }
+ throw new Server500(new \ArrayObject(array("explain" => "Cannot clear the session when is not started",
+ "solution" => "Please start a session instance before clear it")));
+ }
+
+ /**
+ * Set all value to default
+ */
+ private function setToDefault():void
+ {
+ $this->session = null;
+ $this->id = null;
+ $this->name = null;
+ }
+
+ /** Init the session configuration
+ * @throws Server500
+ * @throws \Exception
+ * @return void
*/
- public function clear()
+ private function initSessionConfig():void
{
- if ($this->isStarted()) {
- return (session_destroy());
+ if (!defined("IUMIO_ENV")) {
+ throw new Server500(new \ArrayObject(array("explain" => "Framework Environment is not defined",
+ "solution" => "Please initialize the framework environment")));
+ }
+ if (false === Server::exist(IUMIO_ROOT."/elements/cache/".strtolower(IUMIO_ENV)."/sessions")) {
+ Server::create(IUMIO_ROOT."/elements/cache/".
+ strtolower(IUMIO_ENV)."/sessions", "directory");
}
- return (false);
+
+ $this->id = session_id();
+ $this->name = session_name();
+ session_save_path(IUMIO_ROOT.'/elements/cache/'.strtolower(IUMIO_ENV).'/sessions');
+ ini_set('session.gc_probability', 1);
}
+
/** Check if session is started
* @return bool
*/
public function isStarted()
{
- if ('cli' !== php_sapi_name()) {
- return ((PHP_SESSION_ACTIVE === session_status()) ? true : false);
- }
- return (false);
+ return ((PHP_SESSION_ACTIVE === session_status()) ? true : false);
}
-
}
diff --git a/Core/Base/Http/SessionInterfaceRequest.php b/Core/Base/Http/SessionInterfaceRequest.php
index d6748f3..3367702 100755
--- a/Core/Base/Http/SessionInterfaceRequest.php
+++ b/Core/Base/Http/SessionInterfaceRequest.php
@@ -36,28 +36,28 @@ public function start();
*
* @return string The session ID
*/
- public static function getId();
+ public function getId();
/**
* Sets the session ID.
*
* @param string $id
*/
- public static function setId($id);
+ public function setId($id);
/**
* Returns the session name.
*
* @return mixed The session name
*/
- public static function getName();
+ public function getName();
/**
* Sets the session name.
*
* @param string $name
*/
- public static function setName($name);
+ public function setName($name);
/**
* Force the session to be saved and closed.
@@ -129,5 +129,4 @@ public function clear();
* @return bool
*/
public function isStarted();
-
}
diff --git a/Core/Requirement/Environment/FrameworkEnvironment.php b/Core/Requirement/Environment/FrameworkEnvironment.php
old mode 100755
new mode 100644
index e231195..631dad0
--- a/Core/Requirement/Environment/FrameworkEnvironment.php
+++ b/Core/Requirement/Environment/FrameworkEnvironment.php
@@ -47,6 +47,7 @@ public static function definer(string $env):int
$base = realpath(__DIR__ . "/../../../../../../")."/";
define('IUMIO_ENV', $env);
+ define('IUMIO_ROOT', $base);
$current = self::getProtocol()."://".$_SERVER['HTTP_HOST'].dirname($_SERVER['PHP_SELF']);
$current_temp = substr($current, 0, strpos($current, self::getFileEnv($env)));
diff --git a/Core/Requirement/FrameworkCore.php b/Core/Requirement/FrameworkCore.php
old mode 100755
new mode 100644
index b690ffd..4c71a79
--- a/Core/Requirement/FrameworkCore.php
+++ b/Core/Requirement/FrameworkCore.php
@@ -46,10 +46,10 @@ abstract class FrameworkCore extends GlobalCoreService
protected $environment;
private static $runtime_parameters = null;
- public const CORE_VERSION = '1.0.1';
+ public const CORE_VERSION = '1.0.2';
public const CORE_NAME = 'SUN';
public const CORE_STAGE = 'STS';
- public const CORE_BUILD = 201801;
+ public const CORE_BUILD = 201802;
protected static $edition = array();
/**
diff --git a/Core/Requirement/FrameworkServices/FrameworkTools.php b/Core/Requirement/FrameworkServices/FrameworkTools.php
old mode 100755
new mode 100644
index f521669..2f611f6
--- a/Core/Requirement/FrameworkServices/FrameworkTools.php
+++ b/Core/Requirement/FrameworkServices/FrameworkTools.php
@@ -115,7 +115,7 @@ final public static function detectFirstInstallation():int
header('Location: '.FEnv::get("host.current").'/setup/setup.php');
exit(1);
} else {
- throw new \RuntimeException("(Setup components does not exist in web directory => Please download".
+ throw new \RuntimeException("(Setup components does not exist in web directory => Please download ".
"the setup components on iumio Framework Website to fix this error and put him in web directory)");
}
}
diff --git a/README.md b/README.md
index bf46d4f..354118f 100644
--- a/README.md
+++ b/README.md
@@ -7,8 +7,11 @@ iumio Framework
@ Let's create more simply
+- CODACY :
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/b1b1beef4a244d25a2586c2cdf3a1cc5)](https://www.codacy.com/app/iumio-team/iumio-framework?utm_source=github.com&utm_medium=referral&utm_content=iumio/framework&utm_campaign=Badge_Grade)
+- TRAVIS : [![Build Status](https://travis-ci.org/iumio/framework.svg?branch=master)](https://travis-ci.org/iumio/framework)
+
Description
------------
diff --git a/phpunit.xml b/phpunit.xml
index abb6b33..4485409 100644
--- a/phpunit.xml
+++ b/phpunit.xml
@@ -6,6 +6,7 @@
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
+ processIsolation="true"
>
diff --git a/tests/HttpSessionTest.php b/tests/HttpSessionTest.php
index 518cd48..ace31e6 100644
--- a/tests/HttpSessionTest.php
+++ b/tests/HttpSessionTest.php
@@ -14,7 +14,7 @@
namespace iumioFramework\Tests;
-error_reporting(E_ALL);
+
use iumioFramework\Core\Base\Http\HttpSession;
use PHPUnit\Framework\TestCase;
@@ -24,7 +24,12 @@
*/
class HttpSessionTest extends TestCase
{
-
+ public function setUp()
+ {
+ define('IUMIO_ENV', 'dev');
+ $base = realpath(__DIR__ . "/../")."/";
+ define('IUMIO_ROOT', $base);
+ }
/**
* Test if session is started
* @throws \Exception
@@ -114,8 +119,8 @@ public function testAll()
*/
public function testId()
{
- HttpSession::setId("123");
$instance = HttpSession::getInstance();
+ $instance->setId("123");
$this->assertEquals("123", session_id());
$this->assertEquals("123", $instance->getId());
}
@@ -124,9 +129,14 @@ public function testId()
* Test destroy a session
* @throws \Exception
*/
- public function testDestroy()
+ public function testClear()
{
$instance = HttpSession::getInstance();
+ $arr = ["test" => "val1", "test2" => "val2", "test3" => "val3"];
+ foreach ($arr as $one => $value) {
+ $instance->set($one, $value);
+ }
+ $instance->save();
$this->assertTrue($instance->clear());
}
@@ -135,13 +145,13 @@ public function testDestroy()
* Test set name for session
* @throws \Exception
*/
- public function testName()
+ /*public function testName()
{
- HttpSession::setName("test");
$instance = HttpSession::getInstance();
+ $instance->setName("test");
$this->assertEquals("test", session_name());
$this->assertEquals("test", $instance->getName());
- }
+ }*/
/**
From 7a1318cd6623deb9f3b5af19d9ac25a16c175a9b Mon Sep 17 00:00:00 2001
From: Dany Rafina
Date: Mon, 23 Jul 2018 10:45:30 +0200
Subject: [PATCH 3/3] - Edited travis.yml to create element directory on unit
tests - Rename service.irt to service.merc
---
.travis.yml | 1 +
BaseApps/FServiceApp/Routing/{service.irt => service.merc} | 0
2 files changed, 1 insertion(+)
rename BaseApps/FServiceApp/Routing/{service.irt => service.merc} (100%)
diff --git a/.travis.yml b/.travis.yml
index a560e34..c20b8ae 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,5 +2,6 @@ language: php
php:
- '7.2'
before_script:
+ - mkdir elements && mkdir elements/cache && mkdir elements/cache/dev && mkdir elements/cache/prod
- composer install
script: phpunit --configuration phpunit.xml
\ No newline at end of file
diff --git a/BaseApps/FServiceApp/Routing/service.irt b/BaseApps/FServiceApp/Routing/service.merc
similarity index 100%
rename from BaseApps/FServiceApp/Routing/service.irt
rename to BaseApps/FServiceApp/Routing/service.merc