Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add unit tests for wildcard

Add unit tests for wirldcard
  • Loading branch information...
commit e8e08e36477a8b05cb6c198f094714b0070f1951 1 parent dc754a3
@blanchonvincent blanchonvincent authored
Showing with 35 additions and 0 deletions.
  1. +35 −0 tests/ZendTest/Stdlib/HydratorTest.php
View
35 tests/ZendTest/Stdlib/HydratorTest.php
@@ -16,6 +16,8 @@
use ZendTest\Stdlib\TestAsset\ClassMethodsUnderscore;
use ZendTest\Stdlib\TestAsset\ClassMethodsCamelCaseMissing;
use ZendTest\Stdlib\TestAsset\Reflection as ReflectionAsset;
+use Zend\Stdlib\Hydrator\Strategy\DefaultStrategy;
+use Zend\Stdlib\Hydrator\Strategy\SerializableStrategy;
/**
* @category Zend
@@ -146,4 +148,37 @@ public function testHydratorClassMethodsDefaultBehaviorIsConvertUnderscoreToCame
$this->assertEquals($test->getFooBar(), 'foo');
$this->assertEquals($test->getFooBarBaz(), 'bar');
}
+
+ public function testRetrieveWildStrategyAndOther()
+ {
+ $hydrator = new ClassMethods();
+ $hydrator->addStrategy('default', new DefaultStrategy());
+ $hydrator->addStrategy('*', new SerializableStrategy('phpserialize'));
+ $default = $hydrator->getStrategy('default');
+ $this->assertEquals(get_class($default), 'Zend\Stdlib\Hydrator\Strategy\DefaultStrategy');
+ $serializable = $hydrator->getStrategy('*');
+ $this->assertEquals(get_class($serializable), 'Zend\Stdlib\Hydrator\Strategy\SerializableStrategy');
+ }
+
+ public function testUseWildStrategyByDefault()
+ {
+ $hydrator = new ClassMethods();
+ $datas = $hydrator->extract($this->classMethodsUnderscore);
+ $this->assertEquals($datas['foo_bar'], '1');
+ $hydrator->addStrategy('*', new SerializableStrategy('phpserialize'));
+ $datas = $hydrator->extract($this->classMethodsUnderscore);
+ $this->assertEquals($datas['foo_bar'], 's:1:"1";');
+ }
+
+ public function testUseWildStrategyAndOther()
+ {
+ $hydrator = new ClassMethods();
+ $datas = $hydrator->extract($this->classMethodsUnderscore);
+ $this->assertEquals($datas['foo_bar'], '1');
+ $hydrator->addStrategy('foo_bar', new DefaultStrategy());
+ $hydrator->addStrategy('*', new SerializableStrategy('phpserialize'));
+ $datas = $hydrator->extract($this->classMethodsUnderscore);
+ $this->assertEquals($datas['foo_bar'], '1');
+ $this->assertEquals($datas['foo_bar_baz'], 's:1:"2";');
+ }
}

0 comments on commit e8e08e3

Please sign in to comment.
Something went wrong with that request. Please try again.