Skip to content
This repository has been archived by the owner on Jan 31, 2020. It is now read-only.

Commit

Permalink
zendframework/zendframework#6869 - public static properties should no…
Browse files Browse the repository at this point in the history
…t be hydrated by the `ObjectProperty` hydrator
  • Loading branch information
Ocramius committed Nov 29, 2014
1 parent cf786b9 commit 1ac56b0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/Hydrator/ObjectPropertyTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Zend\Stdlib\Hydrator\ObjectProperty;
use Zend\Stdlib\Exception\BadMethodCallException;
use ZendTest\Stdlib\TestAsset\ClassWithPublicStaticProperties;
use ZendTest\Stdlib\TestAsset\ObjectProperty as ObjectPropertyTestAsset;

/**
Expand Down Expand Up @@ -139,4 +140,19 @@ public function testCanHydrateGenericClassNonExistingProperties()

$this->assertAttributeSame('newPropertyValue', 'newProperty', $object);
}

/**
* Verify that hydration is skipped for class properties (it is an object hydrator after all)
*/
public function testSkipsPublicStaticClassPropertiesHydration()
{
$this->hydrator->hydrate(
array('foo' => '1', 'bar' => '2', 'baz' => '3'),
new ClassWithPublicStaticProperties()
);

$this->assertSame('foo', ClassWithPublicStaticProperties::$foo);
$this->assertSame('bar', ClassWithPublicStaticProperties::$bar);
$this->assertSame('baz', ClassWithPublicStaticProperties::$baz);
}
}

0 comments on commit 1ac56b0

Please # to comment.