From b695405459d89a2f5cfe7a3f21c0cede94c2ae85 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Mon, 29 Apr 2024 16:31:15 +0200 Subject: [PATCH 1/2] Remove calls to `TestCase::iniSet()` and calls to deprecated methods of `MockBuilder` --- Tests/ApplicationTest.php | 5 ++++- .../MockableAppliationWithTerminalWidth.php | 22 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 Tests/Fixtures/MockableAppliationWithTerminalWidth.php diff --git a/Tests/ApplicationTest.php b/Tests/ApplicationTest.php index bf5652ccc..d58f28358 100644 --- a/Tests/ApplicationTest.php +++ b/Tests/ApplicationTest.php @@ -41,6 +41,7 @@ use Symfony\Component\Console\SignalRegistry\SignalRegistry; use Symfony\Component\Console\Terminal; use Symfony\Component\Console\Tester\ApplicationTester; +use Symfony\Component\Console\Tests\Fixtures\MockableAppliationWithTerminalWidth; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\EventDispatcher\EventDispatcher; use Symfony\Component\EventDispatcher\EventDispatcherInterface; @@ -876,7 +877,9 @@ public function testRenderExceptionEscapesLines() public function testRenderExceptionLineBreaks() { - $application = $this->getMockBuilder(Application::class)->addMethods(['getTerminalWidth'])->getMock(); + $application = $this->getMockBuilder(MockableAppliationWithTerminalWidth::class) + ->onlyMethods(['getTerminalWidth']) + ->getMock(); $application->setAutoExit(false); $application->expects($this->any()) ->method('getTerminalWidth') diff --git a/Tests/Fixtures/MockableAppliationWithTerminalWidth.php b/Tests/Fixtures/MockableAppliationWithTerminalWidth.php new file mode 100644 index 000000000..7f094ff3c --- /dev/null +++ b/Tests/Fixtures/MockableAppliationWithTerminalWidth.php @@ -0,0 +1,22 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Component\Console\Tests\Fixtures; + +use Symfony\Component\Console\Application; + +class MockableAppliationWithTerminalWidth extends Application +{ + public function getTerminalWidth(): int + { + return 0; + } +} From 58b1658518e195d83bd46b5a4659b1863057b1e0 Mon Sep 17 00:00:00 2001 From: Alexandre Daubois Date: Fri, 26 Apr 2024 10:58:17 +0200 Subject: [PATCH 2/2] Remove calls to `getMockForAbstractClass()` --- Tests/Question/QuestionTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Tests/Question/QuestionTest.php b/Tests/Question/QuestionTest.php index e6b6fbee0..bf2763d77 100644 --- a/Tests/Question/QuestionTest.php +++ b/Tests/Question/QuestionTest.php @@ -157,7 +157,7 @@ public function testSetAutocompleterValuesInvalid($values) public function testSetAutocompleterValuesWithTraversable() { $question1 = new Question('Test question 1'); - $iterator1 = $this->getMockForAbstractClass(\IteratorAggregate::class); + $iterator1 = $this->createMock(\IteratorAggregate::class); $iterator1 ->expects($this->once()) ->method('getIterator') @@ -165,7 +165,7 @@ public function testSetAutocompleterValuesWithTraversable() $question1->setAutocompleterValues($iterator1); $question2 = new Question('Test question 2'); - $iterator2 = $this->getMockForAbstractClass(\IteratorAggregate::class); + $iterator2 = $this->createMock(\IteratorAggregate::class); $iterator2 ->expects($this->once()) ->method('getIterator')