From 849f308d7d504576a2165e97d0c22c19c48030cd Mon Sep 17 00:00:00 2001 From: Holger Woltersdorf Date: Sun, 10 Jul 2016 01:03:50 +0200 Subject: [PATCH] Adding global data mappers does not reserve the '*' key anymore, raised composer dev-dependency of tm/tooly-composer-script to ^1.0, Fixed author tags, Added changelog --- CHANGELOG.md | 7 +++++++ Vagrantfile | 2 +- composer.json | 20 ++------------------ composer.lock | 4 ++-- src/AbstractSession.php | 6 ++++++ tests/Unit/AbstractSessionTest.php | 12 ++++++++++++ 6 files changed, 30 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 815bbdf..a1057ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CHANGELOG](http://keepachangelog.com). +## [1.1.0] - 2016-07-10 + +### Added + +- `AbstractSession::clear()` method to clear all data from session + ## [1.0.1] - 2016-07-06 ### Added @@ -18,4 +24,5 @@ This project adheres to [Semantic Versioning](http://semver.org/) and [Keep a CH - First release +[1.1.0]: https://github.com/icehawk/session/compare/v1.0.1...v1.1.0 [1.0.1]: https://github.com/icehawk/session/compare/v1.0.0...v1.0.1 \ No newline at end of file diff --git a/Vagrantfile b/Vagrantfile index e241dca..83e50b6 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -11,7 +11,7 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| config.vm.box = "devops007" config.vm.box_url = "http://box.3wolt.de/devops007/" config.vm.box_check_update = true - config.vm.box_version = "~> 1.2.0" + config.vm.box_version = "~> 1.2.1" # network-config config.vm.network "public_network", type: "dhcp" diff --git a/composer.json b/composer.json index 2ef4d68..f7676a0 100644 --- a/composer.json +++ b/composer.json @@ -40,24 +40,8 @@ "url": "https://phar.phpunit.de/phpunit.phar", "only-dev": true }, - "phploc": { - "url": "https://phar.phpunit.de/phploc.phar", - "only-dev": true - }, - "pdepend": { - "url": "https://static.pdepend.org/php/latest/pdepend.phar", - "only-dev": true - }, - "phpmd": { - "url": "https://static.phpmd.org/php/latest/phpmd.phar", - "only-dev": true - }, - "phpcs": { - "url": "https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar", - "only-dev": true - }, - "phpcpd": { - "url": "https://phar.phpunit.de/phpcpd.phar", + "phpmetrics": { + "url": "https://github.com/phpmetrics/PhpMetrics/raw/master/build/phpmetrics.phar", "only-dev": true }, "phpdox": { diff --git a/composer.lock b/composer.lock index b16ae56..d60fced 100644 --- a/composer.lock +++ b/composer.lock @@ -4,8 +4,8 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "This file is @generated automatically" ], - "hash": "6e7a28bb6f9dfe788b0c667abc290df8", - "content-hash": "5adfeb7e3769dc3af06cfe676d658ed5", + "hash": "e51755e9235407beeabcd787ca3c2ad6", + "content-hash": "487a90847d3b85e713b64a465f5bfed0", "packages": [], "packages-dev": [ { diff --git a/src/AbstractSession.php b/src/AbstractSession.php index e722f91..2caa261 100644 --- a/src/AbstractSession.php +++ b/src/AbstractSession.php @@ -76,6 +76,7 @@ private function mapValueToSessionData( string $key, $value ) { $keyDataMappers = $this->keyDataMappers[ $key ] ?? [ ]; + /** @var MapsSessionData $keyDataMapper */ foreach ( $keyDataMappers as $keyDataMapper ) { $value = $keyDataMapper->toSessionData( $value ); @@ -129,4 +130,9 @@ final protected function unset( string $key ) { unset($this->sessionData[ $key ]); } + + public function clear() + { + $this->sessionData = [ ]; + } } \ No newline at end of file diff --git a/tests/Unit/AbstractSessionTest.php b/tests/Unit/AbstractSessionTest.php index 0eadc8e..74122fc 100644 --- a/tests/Unit/AbstractSessionTest.php +++ b/tests/Unit/AbstractSessionTest.php @@ -77,6 +77,7 @@ public function testSpecificMappingHappensFirst() $session = new Session( $sessionData ); $session->addDataMapper( new DataMapper( 'Globally ' ) ); $session->addDataMapper( new DataMapper( 'Mapped: ' ), [ Session::UNIT_TEST_KEY ] ); + $session->addDataMapper( new DataMapper( 'Mapped: ' ), [ Session::UNIT_TEST_KEY ] ); $session->addDataMapper( new DataMapper( 'Check ' ) ); $session->setUnitTestValue( 'Unit-Test' ); @@ -84,4 +85,15 @@ public function testSpecificMappingHappensFirst() $this->assertEquals( 'Check Globally Mapped: Unit-Test', $sessionData[ Session::UNIT_TEST_KEY ] ); $this->assertEquals( 'Unit-Test', $session->getUnitTestValue() ); } + + public function testCanClearSession() + { + $sessionData = [ Session::UNIT_TEST_KEY => 'value' ]; + $session = new Session( $sessionData ); + + $session->clear(); + + $this->assertNull( $session->getUnitTestValue() ); + $this->assertEmpty( $sessionData ); + } }