Skip to content

Commit

Permalink
Merge pull request #3 from nulpunkt/isset-unset
Browse files Browse the repository at this point in the history
The Stub object now responds to isset and unset functions
  • Loading branch information
nulpunkt committed Sep 12, 2014
2 parents 24d98fb + e89145d commit 937e975
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Nulpunkt/PhpStub/Stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ public function __get($name)
return null;
}

public function __isset($property)
{
return isset($this->methods[$property]);
}

public function __unset($property)
{
unset($this->methods[$property]);
}

public function __toString()
{
return "";
Expand Down
13 changes: 13 additions & 0 deletions test/Nulpunkt/PhpStub/StubTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ public function testCanAccessAsProperty()
$this->assertSame(42, $stub->property);
}

public function testPropertiesCanBeSeenByIsset()
{
$stub = new Stub(['property' => 42]);
$this->assertTrue(isset($stub->property), 'Properies can be seen by isset');
}

public function testPropertiesCanBeUnset()
{
$stub = new Stub(['property' => 42]);
unset($stub->property);
$this->assertFalse(isset($stub->property), 'Properies can be unset');
}

public function testThatItWillCallAAnonomusCallable()
{
$identity = function ($argument) {
Expand Down

0 comments on commit 937e975

Please sign in to comment.