From 63242f091355abb98857dff6e68eae4efc2c098c Mon Sep 17 00:00:00 2001 From: Jordi Date: Sat, 29 Aug 2020 11:16:11 +0200 Subject: [PATCH] fix test under php 8.0 --- tests/Admin/AdminTest.php | 13 +++++++++++-- tests/Command/SetupAclCommandTest.php | 10 ---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/tests/Admin/AdminTest.php b/tests/Admin/AdminTest.php index f56e2ae2df..b4a19b6721 100644 --- a/tests/Admin/AdminTest.php +++ b/tests/Admin/AdminTest.php @@ -694,11 +694,20 @@ public function testToString(): void $s = new FooToString(); $this->assertSame('salut', $admin->toString($s)); + $this->assertSame('', $admin->toString(false)); + } + + public function testToStringNull(): void + { + if (\PHP_VERSION_ID >= 80000) { + $this->markTestSkipped('PHP 8.0 does not allow __toString() method to return null'); + } + + $admin = new PostAdmin('sonata.post.admin.post', 'NewsBundle\Entity\Post', 'Sonata\NewsBundle\Controller\PostAdminController'); + // To string method is implemented, but returns null $s = new FooToStringNull(); $this->assertNotEmpty($admin->toString($s)); - - $this->assertSame('', $admin->toString(false)); } public function testIsAclEnabled(): void diff --git a/tests/Command/SetupAclCommandTest.php b/tests/Command/SetupAclCommandTest.php index 0d836543d9..8d5a520d75 100644 --- a/tests/Command/SetupAclCommandTest.php +++ b/tests/Command/SetupAclCommandTest.php @@ -77,14 +77,4 @@ public function testExecuteWithException1(): void $commandTester->getDisplay() ); } - - public function testExecuteWithException2(): void - { - $pool = new Pool($this->container, '', ''); - - $this->expectException(\TypeError::class); - $this->expectExceptionMessage(sprintf('Argument 2 passed to %s::__construct() must implement interface %s, instance of %s given', SetupAclCommand::class, AdminAclManipulatorInterface::class, \stdClass::class)); - - new SetupAclCommand($pool, new \stdClass()); - } }