mirror of
https://github.com/shlinkio/shlink.git
synced 2026-03-11 09:43:13 +08:00
Removed more functional-php usages
This commit is contained in:
@@ -27,9 +27,8 @@ use Shlinkio\Shlink\Core\Visit\Model\Visitor;
|
||||
use Shlinkio\Shlink\Core\Visit\Transformer\OrphanVisitDataTransformer;
|
||||
use Throwable;
|
||||
|
||||
use function array_walk;
|
||||
use function count;
|
||||
use function Functional\each;
|
||||
use function Functional\noop;
|
||||
|
||||
class NotifyVisitToRabbitMqTest extends TestCase
|
||||
{
|
||||
@@ -77,7 +76,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
{
|
||||
$visitId = '123';
|
||||
$this->em->expects($this->once())->method('find')->with(Visit::class, $visitId)->willReturn($visit);
|
||||
each($expectedChannels, function (string $method): void {
|
||||
array_walk($expectedChannels, function (string $method): void {
|
||||
$this->updatesGenerator->expects($this->once())->method($method)->with(
|
||||
$this->isInstanceOf(Visit::class),
|
||||
)->willReturn(Update::forTopicAndPayload('', []));
|
||||
@@ -153,7 +152,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
yield 'legacy non-orphan visit' => [
|
||||
true,
|
||||
$visit = Visit::forValidShortUrl(ShortUrl::withLongUrl('https://longUrl'), Visitor::emptyInstance()),
|
||||
noop(...),
|
||||
static fn () => null,
|
||||
function (MockObject & PublishingHelperInterface $helper) use ($visit): void {
|
||||
$helper->method('publishUpdate')->with(self::callback(function (Update $update) use ($visit): bool {
|
||||
$payload = $update->payload;
|
||||
@@ -170,7 +169,7 @@ class NotifyVisitToRabbitMqTest extends TestCase
|
||||
yield 'legacy orphan visit' => [
|
||||
true,
|
||||
Visit::forBasePath(Visitor::emptyInstance()),
|
||||
noop(...),
|
||||
static fn () => null,
|
||||
function (MockObject & PublishingHelperInterface $helper): void {
|
||||
$helper->method('publishUpdate')->with(self::callback(function (Update $update): bool {
|
||||
$payload = $update->payload;
|
||||
|
||||
@@ -32,8 +32,8 @@ use stdClass;
|
||||
use Symfony\Component\Console\Style\StyleInterface;
|
||||
|
||||
use function count;
|
||||
use function Functional\some;
|
||||
use function Shlinkio\Shlink\Core\contains;
|
||||
use function Shlinkio\Shlink\Core\some;
|
||||
use function sprintf;
|
||||
use function str_contains;
|
||||
|
||||
|
||||
@@ -20,8 +20,8 @@ use Shlinkio\Shlink\Importer\Model\ImportedShlinkUrl;
|
||||
use Shlinkio\Shlink\Importer\Sources\ImportSource;
|
||||
|
||||
use function array_map;
|
||||
use function Functional\every;
|
||||
use function range;
|
||||
use function Shlinkio\Shlink\Core\every;
|
||||
use function strlen;
|
||||
use function strtolower;
|
||||
|
||||
|
||||
@@ -16,9 +16,6 @@ use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Shlinkio\Shlink\Core\Options\UrlShortenerOptions;
|
||||
use Shlinkio\Shlink\Core\ShortUrl\Middleware\TrimTrailingSlashMiddleware;
|
||||
|
||||
use function Functional\compose;
|
||||
use function Functional\const_function;
|
||||
|
||||
class TrimTrailingSlashMiddlewareTest extends TestCase
|
||||
{
|
||||
private MockObject & RequestHandlerInterface $requestHandler;
|
||||
@@ -34,7 +31,10 @@ class TrimTrailingSlashMiddlewareTest extends TestCase
|
||||
ServerRequestInterface $inputRequest,
|
||||
callable $assertions,
|
||||
): void {
|
||||
$arg = compose($assertions, const_function(true));
|
||||
$arg = static function (...$args) use ($assertions): bool {
|
||||
$assertions(...$args);
|
||||
return true;
|
||||
};
|
||||
$this->requestHandler->expects($this->once())->method('handle')->with($this->callback($arg))->willReturn(
|
||||
new Response(),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user