Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/71' into develop
Browse files Browse the repository at this point in the history
Forward port #73
  • Loading branch information
weierophinney committed Feb 12, 2016
2 parents 0de577d + db308cd commit 2eb9b52
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 4 deletions.
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ All notable changes to this project will be documented in this file, in reverse

- Nothing.

## 2.6.1 - TBD
## 2.6.1 - 2016-02-12

### Added

Expand All @@ -36,7 +36,11 @@ All notable changes to this project will be documented in this file, in reverse

### Fixed

- Nothing.
- [#73](https://github.com/zendframework/zend-cache/pull/73) fixes how the
`EventManager` instance is lazy-instantiated in
`Zend\Cache\Storage\Adapter\AbstractAdapter::getEventManager()`. In 2.6.0, it
was using the v3-specific syntax; it now uses syntax compatible with both v2
and v3.

## 2.6.0 - 2016-02-11

Expand Down
4 changes: 2 additions & 2 deletions src/Storage/Adapter/AbstractAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
use Zend\EventManager\EventManager;
use Zend\EventManager\EventManagerInterface;
use Zend\EventManager\EventsCapableInterface;
use Zend\EventManager\SharedEventManager;

abstract class AbstractAdapter implements StorageInterface, EventsCapableInterface
{
Expand Down Expand Up @@ -190,7 +189,8 @@ public function getCaching()
public function getEventManager()
{
if ($this->events === null) {
$this->events = new EventManager(new SharedEventManager(), [__CLASS__, get_class($this)]);
$this->events = new EventManager();
$this->events->setIdentifiers([__CLASS__, get_class($this)]);
}
return $this->events;
}
Expand Down
42 changes: 42 additions & 0 deletions test/Storage/Adapter/EventManagerCompatibilityTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2016 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_Cache
*/

namespace ZendTest\Cache\Storage\Adapter;

use PHPUnit_Framework_TestCase as TestCase;
use Zend\Cache\Storage\Adapter\AbstractAdapter;
use Zend\EventManager\EventManager;
use ZendTest\Cache\Storage\TestAsset\MockAdapter;

class EventManagerCompatibilityTest extends TestCase
{
public function setUp()
{
$this->adapter = new MockAdapter();
}

public function testCanLazyLoadEventManager()
{
$events = $this->adapter->getEventManager();
$this->assertInstanceOf(EventManager::class, $events);
return $events;
}

/**
* @depends testCanLazyLoadEventManager
*/
public function testLazyLoadedEventManagerIsInjectedProperlyWithDefaultIdentifiers(EventManager $events)
{
$this->assertEquals([
AbstractAdapter::class,
MockAdapter::class,
], $events->getIdentifiers());
}
}

0 comments on commit 2eb9b52

Please sign in to comment.