Skip to content

Commit

Permalink
Merge pull request #21 from buu-lam/master
Browse files Browse the repository at this point in the history
fixbug expect($object)->(not)hasAttribute($attributeName)
  • Loading branch information
DavertMik authored Jul 13, 2016
2 parents 76e3090 + 26c309d commit dc19c87
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Codeception/Verify.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions tests/VerifyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit dc19c87

Please sign in to comment.