diff --git a/core/modules/system/tests/src/Kernel/System/CronQueueTest.php b/core/modules/system/tests/src/Kernel/System/CronQueueTest.php index abedf8b4b57af2b55eff8b89f46a132665932b8b..e450e3a3837ef58630ae7f7c89d3b7e0a9134fbe 100644 --- a/core/modules/system/tests/src/Kernel/System/CronQueueTest.php +++ b/core/modules/system/tests/src/Kernel/System/CronQueueTest.php @@ -57,7 +57,7 @@ class CronQueueTest extends KernelTestBase { /** * A logger for testing. * - * @var \PHPUnit\Framework\MockObject\MockObject|\Psr\Log\LoggerInterface + * @var \Prophecy\Prophecy\ObjectProphecy|\Psr\Log\LoggerInterface */ protected $logger; @@ -66,7 +66,7 @@ class CronQueueTest extends KernelTestBase { */ protected function setUp(): void { // Setup logger before register() is called. - $this->logger = $this->createMock(LoggerInterface::class); + $this->logger = $this->prophesize(LoggerInterface::class); parent::setUp(); $this->connection = Database::getConnection(); @@ -173,23 +173,20 @@ public function testLeaseTime() { * @see \Drupal\cron_queue_test\Plugin\QueueWorker\CronQueueTestException */ public function testUncaughtExceptions() { - $this->logger->expects($this->atLeast(2)) - ->method('log') - ->withConsecutive( - [ - $this->equalTo(RfcLogLevel::ERROR), - $this->equalTo('%type: @message in %function (line %line of %file).'), - $this->callback(function ($args) { - return $args['@message'] === 'That is not supposed to happen.' && - $args['exception'] instanceof \Exception; - }), - ], - [ - $this->equalTo(RfcLogLevel::INFO), - $this->equalTo('Cron run completed.'), - $this->anything(), - ], - ); + $this->logger->log( + RfcLogLevel::ERROR, + '%type: @message in %function (line %line of %file).', + Argument::that(function ($args) { + return $args['@message'] === 'That is not supposed to happen.' + && $args['exception'] instanceof \Exception; + }) + )->shouldBeCalled(); + + $this->logger->log( + RfcLogLevel::INFO, + 'Cron run completed.', + Argument::cetera() + )->shouldBeCalled(); // Get the queue to test the normal Exception. $queue = $this->container->get('queue')->get(CronQueueTestException::PLUGIN_ID); @@ -226,22 +223,19 @@ public function testUncaughtExceptions() { * @covers \Drupal\Core\Queue\SuspendQueueException */ public function testSuspendQueueException(): void { - $this->logger->expects($this->atLeast(2)) - ->method('log') - ->withConsecutive( - [ - $this->equalTo(RfcLogLevel::DEBUG), - $this->equalTo('A worker for @queue queue suspended further processing of the queue.'), - $this->callback(function ($args) { - return $args['@queue'] === CronQueueTestSuspendQueue::PLUGIN_ID; - }), - ], - [ - $this->equalTo(RfcLogLevel::INFO), - $this->equalTo('Cron run completed.'), - $this->anything(), - ], - ); + $this->logger->log( + RfcLogLevel::DEBUG, + 'A worker for @queue queue suspended further processing of the queue.', + Argument::that(function ($args) { + return $args['@queue'] === CronQueueTestSuspendQueue::PLUGIN_ID; + }) + )->shouldBeCalled(); + + $this->logger->log( + RfcLogLevel::INFO, + 'Cron run completed.', + Argument::cetera() + )->shouldBeCalled(); // Get the queue to test the specific SuspendQueueException. $queue = \Drupal::queue(CronQueueTestSuspendQueue::PLUGIN_ID); @@ -348,9 +342,9 @@ public function testQueueWorkerDeriver(): void { */ public function register(ContainerBuilder $container) { parent::register($container); - $container->register('test_logger', get_class($this->logger)) + $container->register('test_logger', get_class($this->logger->reveal())) ->addTag('logger'); - $container->set('test_logger', $this->logger); + $container->set('test_logger', $this->logger->reveal()); } } diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon index e3790ef21ab895020923b50fa02f33e43e659078..5fcb52890e5110dde9154fa0d0a0813c31bb5f06 100644 --- a/core/phpstan-baseline.neon +++ b/core/phpstan-baseline.neon @@ -2298,11 +2298,6 @@ parameters: count: 2 path: modules/system/tests/src/Functional/Theme/ThemeUiTest.php - - - message: "#^Call to deprecated method withConsecutive\\(\\) of class PHPUnit\\\\Framework\\\\MockObject\\\\Builder\\\\InvocationMocker\\.$#" - count: 2 - path: modules/system/tests/src/Kernel/System/CronQueueTest.php - - message: "#^Call to deprecated constant REQUEST_TIME\\: Deprecated in drupal\\:8\\.3\\.0 and is removed from drupal\\:11\\.0\\.0\\. Use \\\\Drupal\\:\\:time\\(\\)\\-\\>getRequestTime\\(\\); $#" count: 1