From bdfd54b52ad934a4b1f3d5bdb4ab224998d4fcfb Mon Sep 17 00:00:00 2001 From: Mark Rogoyski Date: Mon, 4 Mar 2019 22:13:37 -0800 Subject: [PATCH] Add unit test for assertObjectHasAttribute with a numeric attribute. --- tests/unit/Framework/AssertTest.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/unit/Framework/AssertTest.php b/tests/unit/Framework/AssertTest.php index 404e522b70e..612831090cf 100644 --- a/tests/unit/Framework/AssertTest.php +++ b/tests/unit/Framework/AssertTest.php @@ -966,6 +966,32 @@ public function testAssertObjectHasAttribute(): void $this->assertObjectHasAttribute('foo', $o); } + public function testAssertObjectHasAttributeNumericAttribute(): void + { + $object = (object) [ + '2016' => [ + 'hostCity' => 'Rio', + 'games' => 'summer', + ], + '2018' => [ + 'hostCity' => 'Pyeongchang', + 'games' => 'winter', + ], + '2020' => [ + 'hostCity' => 'Tokyo', + 'games' => 'summer', + ], + ]; + + $this->assertObjectHasAttribute('2016', $object); + $this->assertObjectHasAttribute('2018', $object); + $this->assertObjectHasAttribute('2020', $object); + + $this->expectException(AssertionFailedError::class); + + $this->assertObjectHasAttribute('foo', $object); + } + public function testAssertObjectNotHasAttribute(): void { $o = new \Author('Terry Pratchett');