Skip to content

Commit

Permalink
Adding global data mappers does not reserve the '*' key anymore, rais…
Browse files Browse the repository at this point in the history
…ed composer dev-dependency of tm/tooly-composer-script to ^1.0, Fixed author tags, Added changelog
  • Loading branch information
hollodotme committed Jul 9, 2016
1 parent ffd3620 commit 849f308
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 21 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
20 changes: 2 additions & 18 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions src/AbstractSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -129,4 +130,9 @@ final protected function unset( string $key )
{
unset($this->sessionData[ $key ]);
}

public function clear()
{
$this->sessionData = [ ];
}
}
12 changes: 12 additions & 0 deletions tests/Unit/AbstractSessionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,23 @@ 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' );

$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 );
}
}

0 comments on commit 849f308

Please sign in to comment.