test: replace deprecated assertObjectHasAttribute()

This commit is contained in:
kenjis 2023-02-04 09:36:59 +09:00
parent f7ab73667a
commit 8461519e58
No known key found for this signature in database
GPG Key ID: BD254878922AF198
5 changed files with 8 additions and 7 deletions

View File

@ -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()

View File

@ -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

View File

@ -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);
}
/**

View File

@ -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()

View File

@ -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);
}