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

Commit

Permalink
Merge branch 'feature/7' into develop
Browse files Browse the repository at this point in the history
Close #7
  • Loading branch information
weierophinney committed Dec 9, 2015
2 parents 11647cd + cabb20a commit 1fbfee4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 38 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"extra": {
"branch-alias": {
"dev-master": "2.5-dev",
"dev-develop": "2.6-dev"
"dev-develop": "3.0-dev"
}
},
"autoload-dev": {
Expand All @@ -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"
}
}
25 changes: 1 addition & 24 deletions src/Assertion/AssertionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
18 changes: 11 additions & 7 deletions test/Assertion/AssertionAggregateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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')
Expand All @@ -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')
Expand Down
9 changes: 5 additions & 4 deletions test/Assertion/AssertionManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,25 @@
namespace ZendTest\Permissions\Acl\Assertion;

use Zend\Permissions\Acl\Assertion\AssertionManager;
use Zend\ServiceManager\ServiceManager;

class AssertionManagerTest extends \PHPUnit_Framework_TestCase
{
protected $manager;

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

0 comments on commit 1fbfee4

Please sign in to comment.