Skip to content
Merged
Show file tree
Hide file tree
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
Expand Up @@ -38,7 +38,7 @@
"roave/backward-compatibility-check": "^8.21.0",
"roave/security-advisories": "dev-master",
"webware/messagebus-event": "^2.0.0-beta.1",
"webware/webware-tools": "^1.0.0-rc.5"
"webware/webware-tools": "^1.0.0-rc.6"
},
"suggest": {
"laminas/laminas-view": "Required when the consuming application does not provide the HelperPluginManager service used by the SystemMessenger view helper"
Expand Down
14 changes: 7 additions & 7 deletions composer.lock

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

Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ public function factoryBuildsMiddlewareUsingHelperFromPluginManager(): void
);

$container = $this->createStub(ContainerInterface::class);
$container->method('get')
$container
->method('get')
->willReturnCallback(
static fn(string $id): mixed => HelperPluginManager::class === $id ? $helperManager : null,
);
Expand Down
3 changes: 2 additions & 1 deletion test/unit/Http/Middleware/MessageMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public function processInjectsMessengerIntoHelperAndRequestAttribute(): void
$response = $this->createStub(ResponseInterface::class);
$capturedMessenger = null;
$handler = $this->createMock(RequestHandlerInterface::class);
$handler->expects($this->once())
$handler
->expects($this->once())
->method('handle')
->willReturnCallback(
static function (ServerRequestInterface $request) use (
Expand Down
30 changes: 20 additions & 10 deletions test/unit/Http/Middleware/NotificationMiddlewareTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ public function processDoesNotNotifyWhenCommandIsNotNotificationCapable(): void
$messenger->expects($this->never())->method('sendNow');

$handler = $this->createMock(RequestHandlerInterface::class);
$handler->expects($this->once())
$handler
->expects($this->once())
->method('handle')
->willReturn($response);

$request = new ServerRequest()->withAttribute(SystemMessengerInterface::class, $messenger)
$request = new ServerRequest()
->withAttribute(SystemMessengerInterface::class, $messenger)
->withAttribute(
CommandResult::class,
new CommandResult($this->createStub(CommandInterface::class), MessageStatus::Success, null),
Expand All @@ -69,7 +71,8 @@ public function processPushesFailureNotification(): void
$capturedMessage = null;

$messenger = $this->createMock(SystemMessengerInterface::class);
$messenger->expects($this->once())
$messenger
->expects($this->once())
->method('sendNow')
->willReturnCallback(
static function (string $message, MessageLevel $key, ?int $hops = 0) use (
Expand All @@ -84,11 +87,13 @@ static function (string $message, MessageLevel $key, ?int $hops = 0) use (
);

$handler = $this->createMock(RequestHandlerInterface::class);
$handler->expects($this->once())
$handler
->expects($this->once())
->method('handle')
->willReturn($response);

$request = new ServerRequest()->withAttribute(SystemMessengerInterface::class, $messenger)
$request = new ServerRequest()
->withAttribute(SystemMessengerInterface::class, $messenger)
->withAttribute(
CommandResult::class,
new CommandResult($this->command('Role saved.', 'Role not saved.'), MessageStatus::Failure, null),
Expand All @@ -112,7 +117,8 @@ public function processPushesSuccessNotification(): void
$capturedMessage = null;

$messenger = $this->createMock(SystemMessengerInterface::class);
$messenger->expects($this->once())
$messenger
->expects($this->once())
->method('sendNow')
->willReturnCallback(
static function (string $message, MessageLevel $key, ?int $hops = 0) use (
Expand All @@ -127,11 +133,13 @@ static function (string $message, MessageLevel $key, ?int $hops = 0) use (
);

$handler = $this->createMock(RequestHandlerInterface::class);
$handler->expects($this->once())
$handler
->expects($this->once())
->method('handle')
->willReturn($response);

$request = new ServerRequest()->withAttribute(SystemMessengerInterface::class, $messenger)
$request = new ServerRequest()
->withAttribute(SystemMessengerInterface::class, $messenger)
->withAttribute(
CommandResult::class,
new CommandResult($this->command('Role saved.', 'Role not saved.'), MessageStatus::Success, null),
Expand All @@ -151,7 +159,8 @@ public function processReturnsHandlerResponseWhenMessengerAttributeIsMissing():
{
$response = $this->createStub(ResponseInterface::class);
$handler = $this->createMock(RequestHandlerInterface::class);
$handler->expects($this->once())
$handler
->expects($this->once())
->method('handle')
->willReturn($response);

Expand All @@ -171,7 +180,8 @@ public function processReturnsHandlerResponseWhenResultAttributeIsMissing(): voi
{
$response = $this->createStub(ResponseInterface::class);
$handler = $this->createMock(RequestHandlerInterface::class);
$handler->expects($this->once())
$handler
->expects($this->once())
->method('handle')
->willReturn($response);

Expand Down
12 changes: 8 additions & 4 deletions test/unit/SystemMessengerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -600,21 +600,25 @@ protected function setUp(): void
{
$this->storage = [];
$this->session = $this->createStub(SessionInterface::class);
$this->session->method('get')
$this->session
->method('get')
->willReturnCallback(
fn(string $name, mixed $default = null): mixed => $this->storage[$name] ?? $default,
);
$this->session->method('has')
$this->session
->method('has')
->willReturnCallback(
fn(string $name): bool => array_key_exists($name, $this->storage),
);
$this->session->method('set')
$this->session
->method('set')
->willReturnCallback(
function (string $name, mixed $value): void {
$this->storage[$name] = $value;
},
);
$this->session->method('unset')
$this->session
->method('unset')
->willReturnCallback(
function (string $name): void {
unset($this->storage[$name]);
Expand Down
6 changes: 4 additions & 2 deletions test/unit/View/Helper/SystemMessengerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,11 +111,13 @@ private function messengerWithMessages(array $messages): SystemMessenger
{
$storage = [SystemMessengerInterface::SESSION_KEY => $messages];
$session = $this->createStub(SessionInterface::class);
$session->method('get')
$session
->method('get')
->willReturnCallback(
static fn(string $name, mixed $default = null): mixed => $storage[$name] ?? $default,
);
$session->method('has')
$session
->method('has')
->willReturnCallback(
static fn(string $name): bool => array_key_exists($name, $storage),
);
Expand Down
Loading