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

Commit

Permalink
Merge cd6b582 into 3138073
Browse files Browse the repository at this point in the history
  • Loading branch information
franz-deleon committed Aug 15, 2013
2 parents 3138073 + cd6b582 commit cab019f
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Stdlib/Hydrator/ClassMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ public function hydrate(array $data, $object)
foreach ($data as $property => $value) {
$method = 'set' . ucfirst($property);
if ($this->underscoreSeparatedKeys) {
$method = preg_replace_callback('/(_[a-z])/', $transform, $method);
$method = preg_replace_callback('/(_[a-z])/i', $transform, $method);
}
if (is_callable(array($object, $method))) {
$value = $this->hydrateValue($property, $value, $data);
Expand Down
27 changes: 24 additions & 3 deletions tests/ZendTest/Stdlib/HydratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,8 +156,6 @@ public function testHydratorClassMethodsCamelCase()
$this->assertEquals($test->hasBar(), false);
}



public function testHydratorClassMethodsTitleCase()
{
$hydrator = new ClassMethods(false);
Expand Down Expand Up @@ -194,7 +192,6 @@ public function testHydratorClassMethodsTitleCase()
$this->assertEquals($test->getHasBar(), false);
}


public function testHydratorClassMethodsUnderscore()
{
$hydrator = new ClassMethods(true);
Expand Down Expand Up @@ -235,6 +232,30 @@ public function testHydratorClassMethodsUnderscore()
$this->assertEquals($test->hasBar(), false);
}

public function testHydratorClassMethodsUnderscoreWithUnderscoreUpperCasedHydrateDataKeys()
{
$hydrator = new ClassMethods(true);
$datas = $hydrator->extract($this->classMethodsUnderscore);
$test = $hydrator->hydrate(
array(
'FOO_BAR' => 'foo',
'FOO_BAR_BAZ' => 'bar',
'IS_FOO' => false,
'IS_BAR' => false,
'HAS_FOO' => false,
'HAS_BAR' => false,
),
$this->classMethodsUnderscore
);
$this->assertSame($this->classMethodsUnderscore, $test);
$this->assertEquals($test->getFooBar(), 'foo');
$this->assertEquals($test->getFooBarBaz(), 'bar');
$this->assertEquals($test->getIsFoo(), false);
$this->assertEquals($test->isBar(), false);
$this->assertEquals($test->getHasFoo(), false);
$this->assertEquals($test->hasBar(), false);
}

public function testHydratorClassMethodsOptions()
{
$hydrator = new ClassMethods();
Expand Down

0 comments on commit cab019f

Please sign in to comment.