Skip to content

Commit

Permalink
testPropertiesAreAlwaysSetIfClassHasMagicSet
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotchance committed Mar 9, 2015
1 parent 2fe0c00 commit efd38d7
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions tests/Concise/Mock/BuilderPropertyTest.php
Expand Up @@ -2,11 +2,19 @@

namespace Concise\Mock;

class MagicGetter
class MagicProperty
{
public function __get($name)
{
return 'foo';
if (!property_exists($this, $name)) {
return 'not_found';
}
return $this->$name;
}

public function __set($name, $value)
{
$this->$name = $value;
}
}

Expand Down Expand Up @@ -188,6 +196,13 @@ public function testNullPropertiesAreStillFound(MockBuilder $builder, $type)

public function testPropertiesAreAlwaysFoundIfClassHasMagicGet()
{
$this->assert($this->getProperty(new MagicGetter(), 'does_not_exist'), equals, 'foo');
$this->assert($this->getProperty(new MagicProperty(), 'does_not_exist'), equals, 'not_found');
}

public function testPropertiesAreAlwaysSetIfClassHasMagicSet()
{
$object = new MagicProperty();
$this->setProperty($object, 'foo', 'bar');
$this->assert($this->getProperty($object, 'foo'), equals, 'bar');
}
}

0 comments on commit efd38d7

Please sign in to comment.