Skip to content

Commit bdfd54b

Browse files
markrogoyskisebastianbergmann
authored andcommitted
Add unit test for assertObjectHasAttribute with a numeric attribute.
1 parent 1d2ebea commit bdfd54b

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

tests/unit/Framework/AssertTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,32 @@ public function testAssertObjectHasAttribute(): void
966966
$this->assertObjectHasAttribute('foo', $o);
967967
}
968968

969+
public function testAssertObjectHasAttributeNumericAttribute(): void
970+
{
971+
$object = (object) [
972+
'2016' => [
973+
'hostCity' => 'Rio',
974+
'games' => 'summer',
975+
],
976+
'2018' => [
977+
'hostCity' => 'Pyeongchang',
978+
'games' => 'winter',
979+
],
980+
'2020' => [
981+
'hostCity' => 'Tokyo',
982+
'games' => 'summer',
983+
],
984+
];
985+
986+
$this->assertObjectHasAttribute('2016', $object);
987+
$this->assertObjectHasAttribute('2018', $object);
988+
$this->assertObjectHasAttribute('2020', $object);
989+
990+
$this->expectException(AssertionFailedError::class);
991+
992+
$this->assertObjectHasAttribute('foo', $object);
993+
}
994+
969995
public function testAssertObjectNotHasAttribute(): void
970996
{
971997
$o = new \Author('Terry Pratchett');

0 commit comments

Comments
 (0)