diff --git a/src/Codeception/Verify.php b/src/Codeception/Verify.php index 47dfc28..0d2d286 100644 --- a/src/Codeception/Verify.php +++ b/src/Codeception/Verify.php @@ -140,7 +140,7 @@ public function notInternalType($type) public function hasAttribute($attribute) { - if (is_string($attribute)) { + if (is_string($this->actual)) { a::assertClassHasAttribute($attribute, $this->actual, $this->description); } else { a::assertObjectHasAttribute($attribute, $this->actual, $this->description); @@ -149,7 +149,7 @@ public function hasAttribute($attribute) public function notHasAttribute($attribute) { - if (is_string($attribute)) { + if (is_string($this->actual)) { a::assertClassNotHasAttribute($attribute, $this->actual, $this->description); } else { a::assertObjectNotHasAttribute($attribute, $this->actual, $this->description); diff --git a/tests/VerifyTest.php b/tests/VerifyTest.php index 1279811..c999626 100644 --- a/tests/VerifyTest.php +++ b/tests/VerifyTest.php @@ -100,6 +100,10 @@ public function testHasAttribute() { expect('Exception')->hasAttribute('message'); expect('Exception')->notHasAttribute('fakeproperty'); + + $testObject = (object) array('existingAttribute' => true); + expect($testObject)->hasAttribute('existingAttribute'); + expect($testObject)->notHasAttribute('fakeproperty'); } public function testHasStaticAttribute()