From 8461519e587a43efc140e40054e1d6b9f262dd5c Mon Sep 17 00:00:00 2001 From: kenjis Date: Sat, 4 Feb 2023 09:36:59 +0900 Subject: [PATCH] test: replace deprecated assertObjectHasAttribute() --- tests/system/Commands/BaseCommandTest.php | 4 ++-- tests/system/Config/BaseConfigTest.php | 2 +- tests/system/Entity/EntityTest.php | 2 +- tests/system/Log/Handlers/ChromeLoggerHandlerTest.php | 5 +++-- tests/system/Test/FabricatorTest.php | 2 +- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/tests/system/Commands/BaseCommandTest.php b/tests/system/Commands/BaseCommandTest.php index e1b857e400..068a8d8329 100644 --- a/tests/system/Commands/BaseCommandTest.php +++ b/tests/system/Commands/BaseCommandTest.php @@ -35,14 +35,14 @@ final class BaseCommandTest extends CIUnitTestCase { $command = new AppInfo($this->logger, service('commands')); - $this->assertObjectHasAttribute('group', $command); + $this->assertTrue(isset($command->group)); } public function testMagicIssetFalse() { $command = new AppInfo($this->logger, service('commands')); - $this->assertObjectNotHasAttribute('foobar', $command); + $this->assertFalse(isset($command->foobar)); } public function testMagicGet() diff --git a/tests/system/Config/BaseConfigTest.php b/tests/system/Config/BaseConfigTest.php index 014deca6c3..3d1fe88c53 100644 --- a/tests/system/Config/BaseConfigTest.php +++ b/tests/system/Config/BaseConfigTest.php @@ -110,7 +110,7 @@ final class BaseConfigTest extends CIUnitTestCase // override config with shortPrefix ENV var $this->assertSame('hubbahubba', $config->delta); // incorrect env name should not inject property - $this->assertObjectNotHasAttribute('notthere', $config); + $this->assertFalse(property_exists($config, 'notthere')); // empty ENV var should not affect config setting $this->assertSame('pineapple', $config->fruit); // non-empty ENV var should overrideconfig setting diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 4ee74514a1..1e03157ab1 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -96,7 +96,7 @@ final class EntityTest extends CIUnitTestCase $this->assertSame(123, $entity->foo); $this->assertSame('bar:234:bar', $entity->bar); - $this->assertObjectNotHasAttribute('baz', $entity); + $this->assertSame(4556, $entity->baz); } /** diff --git a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php index 0587763bec..88a27b45b3 100644 --- a/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php +++ b/tests/system/Log/Handlers/ChromeLoggerHandlerTest.php @@ -66,10 +66,11 @@ final class ChromeLoggerHandlerTest extends CIUnitTestCase $config->handlers['CodeIgniter\Log\Handlers\TestHandler']['handles'] = ['critical']; $logger = new ChromeLoggerHandler($config->handlers['CodeIgniter\Log\Handlers\TestHandler']); + $result = $logger->setDateFormat('F j, Y'); - $this->assertObjectHasAttribute('dateFormat', $result); - $this->assertObjectHasAttribute('dateFormat', $logger); + $this->assertSame('F j, Y', $this->getPrivateProperty($result, 'dateFormat')); + $this->assertSame('F j, Y', $this->getPrivateProperty($logger, 'dateFormat')); } public function testChromeLoggerHeaderSent() diff --git a/tests/system/Test/FabricatorTest.php b/tests/system/Test/FabricatorTest.php index 7cadb350e0..6f92be2aaa 100644 --- a/tests/system/Test/FabricatorTest.php +++ b/tests/system/Test/FabricatorTest.php @@ -406,7 +406,7 @@ final class FabricatorTest extends CIUnitTestCase $this->assertIsInt($result->created_at); $this->assertIsInt($result->updated_at); - $this->assertObjectHasAttribute('deleted_at', $result); + $this->assertTrue(property_exists($result, 'deleted_at')); $this->assertNull($result->deleted_at); }