diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d5789f7 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,22 @@ +# Changelog + +All notable changes to this project will be documented in this file, in reverse chronological order by release. + +## 3.0.0 - TBD + +### Added + +- Nothing. + +### Deprecated + +- Nothing. + +### Removed + +- Nothing. + +### Fixed + +- [#7](https://github.com/zendframework/zend-permissions-acl/pull/7) updates the + component to work with zend-servicemanager v3. diff --git a/composer.json b/composer.json index 55f6e05..23fb32d 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "extra": { "branch-alias": { "dev-master": "2.5-dev", - "dev-develop": "2.6-dev" + "dev-develop": "3.0-dev" } }, "autoload-dev": { @@ -34,7 +34,7 @@ "require-dev": { "fabpot/php-cs-fixer": "1.7.*", "phpunit/PHPUnit": "~4.0", - "zendframework/zend-di": "~2.5", - "zendframework/zend-servicemanager": "~2.5" + "zendframework/zend-di": "dev-develop as 2.7.0", + "zendframework/zend-servicemanager": "dev-develop as 2.7.0" } } diff --git a/src/Assertion/AssertionManager.php b/src/Assertion/AssertionManager.php index 69e35e8..7f18bc5 100644 --- a/src/Assertion/AssertionManager.php +++ b/src/Assertion/AssertionManager.php @@ -9,33 +9,10 @@ namespace Zend\Permissions\Acl\Assertion; use Zend\ServiceManager\AbstractPluginManager; -use Zend\Permissions\Acl\Exception\InvalidArgumentException; class AssertionManager extends AbstractPluginManager { protected $sharedByDefault = true; - /** - * Validate the plugin - * - * Checks that the element is an instance of AssertionInterface - * - * @param mixed $plugin - * - * @throws InvalidArgumentException - * @return bool - */ - public function validatePlugin($plugin) - { - if (! $plugin instanceof AssertionInterface) { - throw new InvalidArgumentException( - sprintf( - 'Plugin of type %s is invalid; must implement Zend\Permissions\Acl\Assertion\AssertionInterface', - (is_object($plugin) ? get_class($plugin) : gettype($plugin)) - ) - ); - } - - return true; - } + protected $instanceOf = AssertionInterface::class; } diff --git a/test/Assertion/AssertionAggregateTest.php b/test/Assertion/AssertionAggregateTest.php index e210421..ac217a2 100644 --- a/test/Assertion/AssertionAggregateTest.php +++ b/test/Assertion/AssertionAggregateTest.php @@ -106,7 +106,9 @@ public static function getDataForTestSetMode() public function testManagerAccessors() { - $manager = $this->getMock('Zend\Permissions\Acl\Assertion\AssertionManager'); + $manager = $this->getMockBuilder('Zend\Permissions\Acl\Assertion\AssertionManager') + ->disableOriginalConstructor() + ->getMock(); $aggregate = $this->assertionAggregate->setAssertionManager($manager); $this->assertAttributeEquals($manager, 'assertionManager', $this->assertionAggregate); @@ -129,9 +131,10 @@ public function testCallingAssertWillFetchAssertionFromManager() ->method('assert') ->will($this->returnValue(true)); - $manager = $this->getMock('Zend\Permissions\Acl\Assertion\AssertionManager', [ - 'get' - ]); + $manager = $this->getMockBuilder('Zend\Permissions\Acl\Assertion\AssertionManager') + ->disableOriginalConstructor() + ->getMock(); + $manager->expects($this->once()) ->method('get') ->with('assertion') @@ -153,9 +156,10 @@ public function testAssertThrowsAnExceptionWhenReferingToNonExistentAssertion() 'test.resource' ]); - $manager = $this->getMock('Zend\Permissions\Acl\Assertion\AssertionManager', [ - 'get' - ]); + $manager = $this->getMockBuilder('Zend\Permissions\Acl\Assertion\AssertionManager') + ->disableOriginalConstructor() + ->getMock(); + $manager->expects($this->once()) ->method('get') ->with('assertion') diff --git a/test/Assertion/AssertionManagerTest.php b/test/Assertion/AssertionManagerTest.php index 856469d..3f613db 100644 --- a/test/Assertion/AssertionManagerTest.php +++ b/test/Assertion/AssertionManagerTest.php @@ -9,6 +9,7 @@ namespace ZendTest\Permissions\Acl\Assertion; use Zend\Permissions\Acl\Assertion\AssertionManager; +use Zend\ServiceManager\ServiceManager; class AssertionManagerTest extends \PHPUnit_Framework_TestCase { @@ -16,17 +17,17 @@ class AssertionManagerTest extends \PHPUnit_Framework_TestCase public function setUp() { - $this->manager = new AssertionManager(); + $this->manager = new AssertionManager(new ServiceManager); } public function testValidatePlugin() { $assertion = $this->getMockForAbstractClass('Zend\Permissions\Acl\Assertion\AssertionInterface'); - $this->assertTrue($this->manager->validatePlugin($assertion)); + $this->assertNull($this->manager->validate($assertion)); - $this->setExpectedException('Zend\Permissions\Acl\Exception\InvalidArgumentException'); + $this->setExpectedException('Zend\ServiceManager\Exception\InvalidServiceException'); - $this->manager->validatePlugin('invalid plugin'); + $this->manager->validate('invalid plugin'); } }