Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update composer.json #37

Merged
merged 2 commits into from
Mar 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -34,7 +34,7 @@
"psr/container": "^1.0|^2.0",
"yiisoft/definitions": "^1.0|^2.0|^3.0",
"yiisoft/factory": "^1.0",
"yiisoft/rbac": "^1.0"
"yiisoft/rbac": "^2.0"
},
"require-dev": {
"maglnet/composer-require-checker": "^4.2",
2 changes: 1 addition & 1 deletion tests/RulesContainerTest.php
Original file line number Diff line number Diff line change
@@ -40,7 +40,7 @@ public function testNotRuleInterface(): void
$rulesContainer = new RulesContainer(new SimpleContainer(), ['rule' => new stdClass()]);

$this->expectException(RuleInterfaceNotImplementedException::class);
$this->expectExceptionMessage('Rule "rule" should implement "' . RuleInterface::class . '".');
$this->expectExceptionMessage('Rule "rule" must implement "' . RuleInterface::class . '".');
$this->expectExceptionCode(0);
$rulesContainer->create('rule');
}
5 changes: 3 additions & 2 deletions tests/Support/AuthorRule.php
Original file line number Diff line number Diff line change
@@ -5,15 +5,16 @@
namespace Yiisoft\Rbac\Rules\Container\Tests\Support;

use Yiisoft\Rbac\Item;
use Yiisoft\Rbac\RuleContext;
use Yiisoft\Rbac\RuleInterface;

/**
* Checks if user ID matches `authorID` passed via parameters.
*/
final class AuthorRule implements RuleInterface
{
public function execute(string $userId, Item $item, array $parameters = []): bool
public function execute(?string $userId, Item $item, RuleContext $context): bool
{
return $parameters['authorID'] === $userId;
return $context->getParameterValue('authorId') === $userId;
}
}