Skip to content

Commit

Permalink
Add unit test for assertObjectHasAttribute with a numeric attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
markrogoyski authored and sebastianbergmann committed Mar 6, 2019
1 parent 1d2ebea commit bdfd54b
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/unit/Framework/AssertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

0 comments on commit bdfd54b

Please sign in to comment.