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: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,3 @@ jobs:
uses: innmind/github-workflows/.github/workflows/psalm-matrix.yml@main
cs:
uses: innmind/github-workflows/.github/workflows/cs.yml@main
with:
php-version: '8.2'
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [Unreleased]

### Changed

- Requires PHP `8.4`
- Requires `innmind/foundation:~2.1`

## 4.0.0 - 2025-08-09

### Changed
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"issues": "http://github.com/Innmind/RabbitMQManagement/issues"
},
"require": {
"php": "~8.2",
"innmind/foundation": "^1.7.1"
"php": "~8.4",
"innmind/foundation": "~2.1"
},
"autoload": {
"psr-4": {
Expand All @@ -29,7 +29,7 @@
},
"require-dev": {
"innmind/black-box": "~6.5",
"innmind/static-analysis": "^1.2.1",
"innmind/static-analysis": "~1.3",
"innmind/coding-standard": "~2.0"
}
}
4 changes: 2 additions & 2 deletions src/Control/Permissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public function declare(
->flatMap(static fn($process) => $process->wait()->attempt(
static fn($error) => new \RuntimeException($error::class),
))
->map(static fn() => new SideEffect);
->map(SideEffect::identity(...));
}

/**
Expand All @@ -77,6 +77,6 @@ public function delete(string $vhost, string $user): Attempt
->flatMap(static fn($process) => $process->wait()->attempt(
static fn($error) => new \RuntimeException($error::class),
))
->map(static fn() => new SideEffect);
->map(SideEffect::identity(...));
}
}
4 changes: 2 additions & 2 deletions src/Control/Users.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function declare(string $name, string $password, string ...$tags): Attemp
->flatMap(static fn($process) => $process->wait()->attempt(
static fn($error) => new \RuntimeException($error::class),
))
->map(static fn() => new SideEffect);
->map(SideEffect::identity(...));
}

/**
Expand All @@ -69,6 +69,6 @@ public function delete(string $name): Attempt
->flatMap(static fn($process) => $process->wait()->attempt(
static fn($error) => new \RuntimeException($error::class),
))
->map(static fn() => new SideEffect);
->map(SideEffect::identity(...));
}
}
4 changes: 2 additions & 2 deletions src/Control/VHosts.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function declare(string $name): Attempt
->flatMap(static fn($process) => $process->wait()->attempt(
static fn($error) => new \RuntimeException($error::class),
))
->map(static fn() => new SideEffect);
->map(SideEffect::identity(...));
}

/**
Expand All @@ -67,6 +67,6 @@ public function delete(string $name): Attempt
->flatMap(static fn($process) => $process->wait()->attempt(
static fn($error) => new \RuntimeException($error::class),
))
->map(static fn() => new SideEffect);
->map(SideEffect::identity(...));
}
}
8 changes: 4 additions & 4 deletions src/Model/Channel.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Channel\Name,
Channel\Messages,
};
use Innmind\TimeContinuum\PointInTime;
use Innmind\Time\Point;
use Innmind\Immutable\Maybe;

/**
Expand All @@ -16,7 +16,7 @@
final class Channel
{
/**
* @param Maybe<PointInTime> $idleSince
* @param Maybe<Point> $idleSince
*/
private function __construct(
private Name $name,
Expand All @@ -36,7 +36,7 @@ private function __construct(
/**
* @psalm-pure
*
* @param Maybe<PointInTime> $idleSince
* @param Maybe<Point> $idleSince
*/
#[\NoDiscard]
public static function of(
Expand Down Expand Up @@ -128,7 +128,7 @@ public function transactional(): bool
}

/**
* @return Maybe<PointInTime>
* @return Maybe<Point>
*/
#[\NoDiscard]
public function idleSince(): Maybe
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Connection.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
Connection\AuthenticationMechanism,
Connection\Type,
};
use Innmind\TimeContinuum\PointInTime;
use Innmind\Time\Point;
use Innmind\Url\Authority\{
Host,
Port,
Expand All @@ -24,7 +24,7 @@ final class Connection
{
private function __construct(
private Name $name,
private PointInTime $connectedAt,
private Point $connectedAt,
private Timeout $timeout,
private VHost\Name $vhost,
private User\Name $user,
Expand All @@ -46,7 +46,7 @@ private function __construct(
#[\NoDiscard]
public static function of(
Name $name,
PointInTime $connectedAt,
Point $connectedAt,
Timeout $timeout,
VHost\Name $vhost,
User\Name $user,
Expand Down Expand Up @@ -85,7 +85,7 @@ public function name(): Name
}

#[\NoDiscard]
public function connectedAt(): PointInTime
public function connectedAt(): Point
{
return $this->connectedAt;
}
Expand Down
8 changes: 4 additions & 4 deletions src/Model/Queue.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Queue\Identity,
Queue\Messages,
};
use Innmind\TimeContinuum\PointInTime;
use Innmind\Time\Point;
use Innmind\Immutable\Maybe;

/**
Expand All @@ -16,7 +16,7 @@
final class Queue
{
/**
* @param Maybe<PointInTime> $idleSince
* @param Maybe<Point> $idleSince
*/
private function __construct(
private Identity $identity,
Expand All @@ -34,7 +34,7 @@ private function __construct(
/**
* @psalm-pure
*
* @param Maybe<PointInTime> $idleSince
* @param Maybe<Point> $idleSince
*/
#[\NoDiscard]
public static function of(
Expand Down Expand Up @@ -74,7 +74,7 @@ public function messages(): Messages
}

/**
* @return Maybe<PointInTime>
* @return Maybe<Point>
*/
#[\NoDiscard]
public function idleSince(): Maybe
Expand Down
22 changes: 11 additions & 11 deletions src/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
Server,
Server\Command,
};
use Innmind\TimeContinuum\{
use Innmind\Time\{
Clock,
Format,
};
Expand Down Expand Up @@ -177,10 +177,10 @@ public function connections(): Sequence
Is::int()
->map(static fn($value) => (string) (int) ($value / 1000))
->map(
$this
fn($date) => $this
->clock
->ofFormat(Format::of('U'))
->at(...),
->at($date, Format::of('U'))
->maybe(),
)
->and(Is::just()),
)
Expand Down Expand Up @@ -450,10 +450,10 @@ public function channels(): Sequence
Is::string()
->nonEmpty()
->map(
$this
fn($date) => $this
->clock
->ofFormat(Format::of('Y-m-d G:i:s'))
->at(...),
->at($date, Format::of('Y-m-d G:i:s'))
->maybe(),
),
)
->default('idle_since', Maybe::nothing())
Expand Down Expand Up @@ -581,10 +581,10 @@ public function queues(): Sequence
Is::string()
->nonEmpty()
->map(
$this
fn($date) => $this
->clock
->ofFormat(Format::of('Y-m-d G:i:s'))
->at(...),
->at($date, Format::of('Y-m-d G:i:s'))
->maybe(),
),
)
->default('idle_since', Maybe::nothing())
Expand Down Expand Up @@ -694,7 +694,7 @@ private function list(string $element): Sequence
static fn($success) => $success
->output()
->map(static fn($chunk) => $chunk->data())
->fold(new Concat)
->fold(Concat::monoid)
->toString(),
)
->map(static fn($output): mixed => \json_decode($output, true))
Expand Down
80 changes: 56 additions & 24 deletions tests/Control/PermissionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,32 @@
namespace Tests\Innmind\RabbitMQ\Management\Control;

use Innmind\RabbitMQ\Management\Control\Permissions;
use Innmind\Server\Control\Servers\Mock;
use Innmind\Immutable\SideEffect;
use Innmind\Server\Control\{
Server,
Server\Process\Builder,
};
use Innmind\Immutable\{
Attempt,
SideEffect,
};
use Innmind\BlackBox\PHPUnit\Framework\TestCase;

class PermissionsTest extends TestCase
{
public function testDeclare()
{
$server = Mock::new($this->assert())
->willExecute(fn($command) => $this->assertSame(
"rabbitmqadmin 'declare' 'permission' 'vhost=/' 'user=foo' 'configure=.{1}' 'write=.{2}' 'read=.{3}'",
$command->toString(),
));
$server = Server::via(
function($command) {
$this->assertSame(
"rabbitmqadmin 'declare' 'permission' 'vhost=/' 'user=foo' 'configure=.{1}' 'write=.{2}' 'read=.{3}'",
$command->toString(),
);

return Attempt::result(
Builder::foreground(2)->build(),
);
},
);
$permissions = Permissions::of($server);

$this->assertInstanceOf(
Expand All @@ -30,14 +43,20 @@ public function testDeclare()

public function testReturnNothingWhenFailToDeclare()
{
$server = Mock::new($this->assert())
->willExecute(
fn($command) => $this->assertSame(
$server = Server::via(
function($command) {
$this->assertSame(
"rabbitmqadmin 'declare' 'permission' 'vhost=/' 'user=foo' 'configure=.{1}' 'write=.{2}' 'read=.{3}'",
$command->toString(),
),
static fn($_, $builder) => $builder->failed(),
);
);

return Attempt::result(
Builder::foreground(2)
->failed()
->build(),
);
},
);
$permissions = Permissions::of($server);

$this->assertNull($permissions->declare('/', 'foo', '.{1}', '.{2}', '.{3}')->match(
Expand All @@ -48,11 +67,18 @@ public function testReturnNothingWhenFailToDeclare()

public function testDelete()
{
$server = Mock::new($this->assert())
->willExecute(fn($command) => $this->assertSame(
"rabbitmqadmin 'delete' 'permission' 'vhost=/' 'user=foo'",
$command->toString(),
));
$server = Server::via(
function($command) {
$this->assertSame(
"rabbitmqadmin 'delete' 'permission' 'vhost=/' 'user=foo'",
$command->toString(),
);

return Attempt::result(
Builder::foreground(2)->build(),
);
},
);
$permissions = Permissions::of($server);

$this->assertInstanceOf(
Expand All @@ -66,14 +92,20 @@ public function testDelete()

public function testReturnNothingWhenFailToDelete()
{
$server = Mock::new($this->assert())
->willExecute(
fn($command) => $this->assertSame(
$server = Server::via(
function($command) {
$this->assertSame(
"rabbitmqadmin 'delete' 'permission' 'vhost=/' 'user=foo'",
$command->toString(),
),
static fn($_, $builder) => $builder->failed(),
);
);

return Attempt::result(
Builder::foreground(2)
->failed()
->build(),
);
},
);
$permissions = Permissions::of($server);

$this->assertNull($permissions->delete('/', 'foo')->match(
Expand Down
Loading