Apply fixes for PHPUnit 13

This commit is contained in:
Alejandro Celaya
2026-02-09 12:35:39 +01:00
parent 03e9117f13
commit 197cfa8811
10 changed files with 20 additions and 23 deletions

View File

@@ -50,7 +50,7 @@ class CreateShortUrlCommandTest extends TestCase
$this->urlShortener->expects($this->once())->method('shorten')->withAnyParameters()->willReturn(
UrlShorteningResult::withoutErrorOnEventDispatching($shortUrl),
);
$this->stringifier->method('stringify')->with($shortUrl)->willReturn('stringified_short_url');
$this->stringifier->method('stringify')->willReturnMap([[$shortUrl, 'stringified_short_url']]);
$this->commandTester->execute([
'long-url' => 'http://domain.com/foo/bar',
@@ -70,7 +70,7 @@ class CreateShortUrlCommandTest extends TestCase
$this->urlShortener->expects($this->once())->method('shorten')->withAnyParameters()->willReturn(
UrlShorteningResult::withoutErrorOnEventDispatching($shortUrl),
);
$this->stringifier->method('stringify')->with($shortUrl)->willReturn('stringified_short_url');
$this->stringifier->method('stringify')->willReturnMap([[$shortUrl, 'stringified_short_url']]);
$this->commandTester->setInputs([$shortUrl->getLongUrl()]);
$this->commandTester->execute([]);
@@ -101,7 +101,7 @@ class CreateShortUrlCommandTest extends TestCase
return true;
}),
)->willReturn(UrlShorteningResult::withoutErrorOnEventDispatching($shortUrl));
$this->stringifier->method('stringify')->with($shortUrl)->willReturn('stringified_short_url');
$this->stringifier->method('stringify')->willReturnMap([[$shortUrl, 'stringified_short_url']]);
$this->commandTester->execute([
'long-url' => 'http://domain.com/foo/bar',

View File

@@ -113,7 +113,7 @@ class RedirectRuleHandlerTest extends TestCase
array $expectedConditions,
bool $continue = false,
): void {
$this->io->expects($this->any())->method('ask')->willReturnCallback(
$this->io->method('ask')->willReturnCallback(
fn (string $message): string|int => match ($message) {
'Rule priority (the lower the value, the higher the priority)' => 2, // Add in between existing rules
'Long URL to redirect when the rule matches' => 'https://example.com/new-two',
@@ -127,7 +127,7 @@ class RedirectRuleHandlerTest extends TestCase
default => '',
},
);
$this->io->expects($this->any())->method('choice')->willReturnCallback(
$this->io->method('choice')->willReturnCallback(
function (string $message) use (&$callIndex, $type): string {
$callIndex++;
@@ -241,7 +241,7 @@ class RedirectRuleHandlerTest extends TestCase
#[Test]
public function existingRulesCanBeReArranged(): void
{
$this->io->expects($this->any())->method('ask')->willReturnCallback(
$this->io->method('ask')->willReturnCallback(
fn (string $message): string|int => match ($message) {
'Rule priority (the lower the value, the higher the priority)' => 1,
default => '',

View File

@@ -4,7 +4,6 @@ declare(strict_types=1);
namespace ShlinkioTest\Shlink\CLI\Util;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\MockObject\Generator\Generator;
use PHPUnit\Framework\MockObject\Stub;
use Symfony\Component\Console\Application;
@@ -32,7 +31,6 @@ class CliTestUtils
$command->method('isEnabled')->willReturn(true);
$command->method('getAliases')->willReturn([]);
$command->method('getDefinition')->willReturn(new InputDefinition());
$command->method('setApplication')->with(Assert::isInstanceOf(Application::class));
return $command;
}